I’m working on a web app, and I know little about security/cryptography (for now, still learning) but I’m trying to set up a front-end where:
At the very beginning, the user puts in their private key.
Any time the user does anything to interact with the backend, the key is used to sign or encrypt whatever data it needs to, the data is sent, and when the user is done with everything, they close the browser.
Is this a secure way of doing this? Can anything but my JS code access this key in the process?
(P.S. it’s gonna be RSA or ECC so asymmetric, private key is only known by front end user)
Let $ S$ be a sequence of $ k$ many numbers. The position of the number in the $ S$ matters. In the $ S$ there are only $ j$ many different numbers are there means $ S$ contains many duplicates. Position is a query which needed to be answered, position(i) returns the element at position $ i$ in $ S$ .
Trivial way to store them is using array which will takes $ O(S)$ space and position can be solved in $ O(1)$ time.
I am looking for a representation that takes $ O(j)$ space (or somewhere near to it) and such that position can be solved in $ O(1)$ (even in more time is also ok)?
Please suggest some papers also.
My client wants to gather some sensitive info via an app. I don’t want to store it on the server. Is this a good plan?
- Encrypt it on the phone using a public key embedded in the app.
- Send it to the server.
- Without saving it, email it to the client.
- They copy the base64 into a desktop app that decrypts it using a private key stored on the machine.
They already have such data in-house. So I figure this wouldn’t be any less secure.
The app requires that the user be prompted for some kind of identifying information whenever it is launched, but for ease of use this need not be their full username and password. Password entry in particular (and especially on mobile devices) will be too cumbersome to make this feasible. Therefore, we are considering a once-off login procedure where the full credentials are supplied, followed by a “setup” step where the user creates a PIN for future access. This could, in future, be extended to allow a fingerprint/face scan to also “unlock” the app on supported devices.
My initial thoughts on implementation are:
- The user submits a valid username/password combination to a
login/ endpoint of the API and receives an “ID token” in response.
- During the “setup” phase, the PIN chosen by the user is used to encrypt the ID token.
- The encrypted ID token is stored in
- A secondary request is made to an
authorise/ endpoint of the API, including the plaintext ID token. Assuming the token validates, a second token is issued to the app.
- This second token is what is used in all subsequent requests to the API to prove the user is trusted, has a relatively short expiry, and is not stored in any persistent manner by the application.
- Upon returning to the app at a later date, the user need only provide their chosen PIN.
- It can be used to decrypt the stored ID token, which is then used in the
authorise/ request to generate and return a new short-lived session token.
The internet abounds with articles advising against the use of
LocalStorage for anything sensitive, due to its exposure in the event of XSS attacks. The threat is that a token in
LocalStorage could be stolen when the same token in an httpOnly cookie could not. It is worth noting that in both cases, a malicious script running within the app could successfully issue fraudulent requests to the backend API.
I believe the XSS threat of the ID token being stolen is mitigated by it being encrypted under the user’s PIN, and neither the decrypted value nor the PIN itself being stored or used beyond the
I think the above sounds like a secure way to implement our requirements, but I am no security expert. Am I missing any obvious weaknesses here? Does this actually sound secure?
I understand how JWTs work and that with my secret anyone can issue new tokens. I control the server that my node website runs on and am considering different options for hosting the key.
- In code – Not acceptable because my code is in a github repo
- ENV variable – seperate secrets for dev and production while not leaking to github
- Store in database – Seems more like #2 with more work, being that an on-machine attacker can find access to the db anyways
2 looks like the best method for a simple website (no super sensitive user info like credit cards or SSNs). Is this a good solution?
Starting at about 9:00 in this lecture https://www.youtube.com/watch?v=FNeL18KsWPc&t=540s Erik Demaine talks about calculating the height of a node in an AVL tree in terms of doing a constant time local operation on its children. He then goes on to talk about a general theorem for this pattern that would allow to store the height in constant time.
1) If you know what Erik is talking about, how is the height stored in constant time?
2) In a related question someone asked how to compute the height of AVL as efficiently as possible (Compute height of AVL tree as efficiently as possible). All answers except one agreed that the best possible way is in $ O(\lg n)$ , but that’s not constant time. The only answer that suggested storing the height was dismissed. Could someone explain why?
Email clients like Spark for macOS have a feature where a user can send an email later, at any given time, even when the computer is turned off. An SMTP server needs a password based authentication, though.
Does that mean that if I use Spark to send an email later, my password gets sent over to Spark servers in plaintext, so that they can authorize on the SMTP server later? Or is there a different method?
Say I have a hypothetical PHP application which will store hashed passwords in a file in the same directory. At first, this seems like it would be very insecure, since one could guess at the name of the file and open it via a web browser (
However, I was wondering about the level of security this would provide using a few different methods:
- Security through obscurity: giving the text file a nonsense name that would be hard to guess (
- Giving the text file a certain file extension (
hashed_password.secret), and instructing the web server to return a 403 when it is requested
- Encrypting the text file with a key hard-coded into the PHP application
- Storing the information in a commented-out part of a PHP file, so it can only be read from the back end (and will return a blank file in a web browser)
Compared to a database, are any of these methods more or less secure, and could they provide a reasonable level of security (about that of a database) against attackers?
I tend to avoid putting my master keychain password in the keychain itself (in OSX, for example), but sometimes with federation of accounts and things, it would be convenient to do so.
Am I right to avoid this? I can’t really think of a good reason. Perhaps if you have multiple federated systems with different keychains, storing them on multiple keychains for the convenience increases chances of a problem just by nature of having multiple storage places. But other than that?