-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add certificatesRequests store validation #1893
Comments
How would overwriting others' usernames work? Do you mean submitting a request for the name alice right after someone else submits a request for the name alice? I think we can't stop that with an access controller. Or do you mean something else? |
@holmesworcester I added additional details to the issue. Basically, if we don't check CSR signatures then I think anyone can put someone else's public key and a random username in a CSR (the CSR signature won't be valid, but we don't check that) then get a certificate issued for it, thus changing another user's username. The signature of the CSR needs to match the CSR data and be signed by the public key included in the CSR data, otherwise you can just include any public key in the CSR. |
Note: we would do this together with #1892 |
In order to validate a CSR, we need to check:
To implement this validation, we could use an access controller, but it looks like access controllers only check heads and we need to validate each entry. As an alternative, we can create a new validation function With this approach we will still be caching and replicating invalid entries in IPFS, however when we implement permanent deletion, we can revisit that. This approach also involves re-validating invalid entries when iterating over the log successively. That's not ideal, but I think we can optimize it in the future. It might be nice to encapsulate everything in a |
I think the validation should lowercase letters only, hyphens allowed, and numbers |
Desktop: [email protected] |
We should verify that each CSR is signed by pubKey (see: #1892) and validate usernames, etc.
This prevents users from forging other users' CSRs, overwriting other users' username requests and from adding invalid usernames.
Currently, with the additions of #1843, CSRs are replicated:
quiet/packages/backend/src/nest/storage/storage.service.ts
Line 404 in e019b86
And via RESPONSE_GET_CSRS, these CSRs are sent to the frontend:
quiet/packages/backend/src/nest/connections-manager/connections-manager.service.ts
Lines 562 to 569 in e019b86
CSRs are indexed by public key:
quiet/packages/state-manager/src/sagas/users/users.selectors.ts
Line 48 in e019b86
Where the public key is extracted from the decoded cert:
quiet/packages/identity/src/extractPubKey.ts
Line 14 in 277f966
quiet/packages/identity/src/extractPubKey.ts
Line 22 in e019b86
These CSRs are then used for associating username with users:
quiet/packages/state-manager/src/sagas/users/users.selectors.ts
Line 76 in e019b86
It appears that the CSR isn't validated in this example, so you could BER encode a CSR with someone else's public key and since we don't check the signature, we wouldn't notice.
Following the other path that CSRs take, they get signed by the owner via REGISTER_USER_CERTIFICATE. In this path, first they are decoded:
quiet/packages/identity/src/common.ts
Lines 92 to 95 in 277f966
They are then filtered so only CSRs with unregistered names are prepared for signing:
quiet/packages/backend/src/nest/registration/registration.functions.ts
Line 29 in e019b86
Then each filtered CSR is signed:
quiet/packages/backend/src/nest/registration/registration.functions.ts
Line 72 in e019b86
Inside issueCertificate, there is a
validateCsr
function, but that only appears to validate the BER encoding and basic structural properties:quiet/packages/backend/src/nest/registration/registration.functions.ts
Lines 62 to 67 in e019b86
quiet/packages/backend/src/nest/registration/registration.functions.ts
Lines 11 to 16 in e019b86
generateUserCert also doesn't appear to validate the CSR signature before signing:
quiet/packages/identity/src/generateUserCertificate.ts
Line 24 in 277f966
So it looks like anyone could send a CSR with another user's public key in the CSR and an invalid signature (because they don't control that public key) and thus change another user's username.
The text was updated successfully, but these errors were encountered: