Repository navigation
test: add x509 key rotation - #5593
coriolinus wants to merge 18 commits into
Conversation
039593f to
77f7269
Compare
|
Claude's comments follow: The two tests in Test.MLS.CredentialRotation cover a client that rotates its x509 credential properly, meaning a new certificate with a new signature keypair, as CoreCrypto 10 does by default. That client should still be treated as the same client. Both tests fail on all four ciphersuites at the first step: PUT /clients/:id with the new key returns 400 mls-duplicate-public-key. The x509 identity really is taken from the certificate's SAN. But brig also binds each client to the first signature key it registers: mls_public_keys is written with INSERT … IF NOT EXISTS (Wire/ClientStore/Cassandra.hs, addMLSPublicKey), and that stored key is checked again in three places:
So once a client's key is compromised, it can never replace that key, even by getting a fresh certificate. We don't think the fix is simply to allow overwriting. The insert-only binding is what keeps a stolen access token from silently swapping the key behind a device that other users have already verified, and that protection must stay in place for basic credentials. Instead, we propose that brig accept a key replacement only together with proof of authority: an x509 certificate for the new key that chains to the team's E2EI trust anchor and whose SAN matches the client's identity (wireapp://!@). CoreCrypto can already produce such a certificate during rotation. On a successful replacement, brig should invalidate all of the client's key packages for the affected ciphersuites. The DeleteAllMlsKeyPackages operation for this already exists. Basic-credential clients would keep the current insert-only behaviour. This probably means a new version of the client-update endpoint (or a separate endpoint) that takes the certificate chain. Brig doesn't currently validate x509 chains (see the FUTUREWORK in Wire/API/MLS/Validation.hs), so it would need chain validation and access to the trust anchor. Open questions for you:
Rough size: the storage and key-package changes are about a hundred lines. Certificate validation, API versioning and tests probably bring the total to a few hundred lines. |
|
Unfortunately, the logs of the failing CI runs have been rotated out. I've restarted the related CI jobs to get a clear picture. |
d4d6100 to
d56dec5
Compare
These currently fail and will cause CI to go red. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The backend never verifies application message signatures, so sending one does not prove that the rotated key is accepted. An empty commit carries an update path, whose leaf signature key galley checks against the key registered in brig.
rotateX509Credential discards the client's key store, which would leave the group states of an existing member referencing a missing signer. Fail early instead, and document that the new certificate is self-signed.
Add an optional mls_key_rotations field to the body of PUT /clients/{client}:
for each signature scheme, a proof of possession allowing the key given in
mls_public_keys to replace the registered one. The proof is a key package
signed with the new key, carrying an x509 credential for the client, and a
SignWithLabel signature ("WireMLSKeyRotation") with the registered key over
the client identity, the registered key and the new key.
The field is only serialised when non-empty, and ignored by the schemas of
the update-client routes of versions 6 and 7. Also add the corresponding
errors, and unit tests pinning the signed format.
cql-io's batch fails on any result other than void, while a conditional batch (a lightweight transaction spanning several statements) returns rows carrying [applied]. transBatch sends the batch with cql-io's request and returns these rows. It is not retried. lwtOutcomeUnknown tells the errors after which a lightweight transaction may or may not have been applied (write timeouts), and paramsSerial is for the serial read which then tells whether it was.
…ssession When updating a client, check the whole request before writing anything: every proof of possession, duplicate keys, prekeys and capabilities. Then write all MLS key changes at once with ClientStore.setMLSPublicKeys, each on the condition that the key is still the one checked (a single LWT, or a conditional batch within the user's partition): a concurrent change makes the whole update fail, and nothing is applied. When the outcome of the write is unknown, a serial read tells whether it was applied. The update is idempotent, so that a client can retry it after a failure: a rotation to the key already registered, and a key already registered, change nothing. Key packages not signed with the new key are deleted after the key write, and again on a retry. Refused rotations are logged with their reason, while the client only gets a generic error; conflicts and rotations are logged too. Unit tests use key packages generated with mls-test-cli as fixtures.
A client update replacing MLS signature keys requires MLS to be enabled.
Rotate keys with a proof of possession built independently of wire-api from the documented format, using the private key from the mls-test-cli store. Add negative tests: missing proof by the registered key, key package of another client, basic credential, another user's client, unregistered key, a key in mls_public_keys other than the one of the key package, and a proof for another signature scheme. Check that a refused update applies nothing, that a rotation can be retried but not replayed after a further rotation, that the keys and key packages of other schemes are left alone, and that a rotation and an added key are written together.
900f20d to
9ab7a89
Compare
These currently fail and will cause CI to go red. However, we want these tests to succeed, so that users can correctly rotate their x509 credentials.
Checklist
changelog.d