Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit bbacb2f

Browse files
committed
decouple api version & spec version, wording changes, challenge string behaviour definition, other changes
1 parent 9a8683b commit bbacb2f

File tree

2 files changed

+74
-28
lines changed

2 files changed

+74
-28
lines changed

docs/Protocol Specifications/P2 Extensions/mls.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The version number specified here also applies to the API documentation.
1919
- [1.1.1 Last resort KeyPackages](#111-last-resort-keypackages)
2020
- [1.2 Initial authentication](#12-initial-authentication)
2121
- [1.3 Multi-device support](#13-multi-device-support)
22+
- [6.1.3 Key rotation](#613-key-rotation)
2223

2324
The following sections describe the additional behavior that polyproto implementations must implement
2425
to support encryption via the Messaging Layer Security (MLS) protocol.
@@ -147,4 +148,15 @@ upon reconnection.
147148
A `LOW_KEY_PACKAGES` event is only sent by servers which use MLS encryption. Server/Clients not
148149
implementing MLS encryption can safely ignore this event.
149150
150-
```
151+
```
152+
153+
#### 6.1.3 Key rotation
154+
155+
A session can choose to rotate their ID-Cert at any time. This is done by generating a new identity
156+
key pair, using the new private key to generate a new CSR, and sending the new Certificate Signing
157+
Request to the home server, along with at least one new KeyPackage and a corresponding 'last resort'
158+
KeyPackage, if encryption is offered. The home server will then generate the new ID-Cert, given that
159+
the CSR is valid and that the server accepts the creation of new ID-Certs at this time.
160+
161+
TODO ^ I copied this paragraph over from core.md. The important part here is the fact that a keypackage
162+
and last resort keypackage should be sent when rotating keys. i posted the entire paragraph for context

docs/Protocol Specifications/core.md

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ weight: 0
55

66
# polyproto Specification
77

8-
**v0.1.0-alpha.1** - Treat this as an unfinished draft.
8+
Version of this specification document: **v0.1.0-alpha.1** - Treat this as an unfinished draft.
99

10-
[Semantic versioning v2.0.0](https://semver.org/spec/v2.0.0.html) is used to version this specification.
11-
The version number specified here also applies to the [API documentation](https://apidocs.polyproto.org).
10+
Version of the [API documentation](https://apidocs.polyproto.org) applicable for this version
11+
of the specification document: **v0.1.0-alpha.1**
12+
13+
[Semantic versioning v2.0.0](https://semver.org/spec/v2.0.0.html) is used to version this specification
1214

1315
- [polyproto Specification](#polyproto-specification)
1416
- [1. Terminology used in this document](#1-terminology-used-in-this-document)
@@ -263,7 +265,7 @@ APIs for this purpose are defined in the [API documentation](/APIs).
263265

264266
!!! warning
265267

266-
Sensitive actions should require a second factor of authentication, apart from the actors'
268+
Sensitive actions require a second factor of authentication, apart from the actors'
267269
private key. This second factor can be anything from a password to TOTP or hardware keys, depending
268270
on the authentication method or standard used.
269271

@@ -278,10 +280,16 @@ Sensitive actions include, but are not limited to:
278280
- Changing the actors' federation ID
279281
- Changing the actors' other factors of authentication
280282
- Server administration actions
283+
- Deleting encrypted private key material from a home server
284+
285+
HTTP API routes marked as sensitive actions require a header `X-P2-Sensitive-Solution`, where the
286+
header value represents the second factor of authentication chosen.
287+
288+
!!! example
281289

282-
Clients should be prepared to gracefully handle the case where a sensitive action fails due to
283-
a lack of a second factor of authentication, and should prompt the user to provide the second
284-
factor of authentication.
290+
If the chosen second factor of authentication is TOTP, the value of this header is the current
291+
TOTP verification code. If the chosen second factor of authentication is a password, then the
292+
value of this header is to be that password.
285293

286294
### 4.2 Challenge strings
287295

@@ -291,6 +299,11 @@ UTF-8 characters, have a UNIX timestamp lifetime. If the current timestamp surpa
291299
lifetime, the challenge fails. The actor signs the string, sending the signature and their
292300
ID-Cert to the server, which then verifies the signature's authenticity.
293301

302+
!!! warning
303+
304+
Challenge strings provide a different set of security guarantees than [sensitive actions](#412-sensitive-actions)
305+
do. They are not to be used interchangably.
306+
294307
All challenge strings and their responses created must be made
295308
public to ensure that a chain of trust can be maintained. A third party should be able to verify that
296309
the challenge string, which authorized a specific change in data, was signed by the
@@ -307,6 +320,31 @@ correct private key. The API routes needed to verify challenges as an outsider a
307320
Challenge strings can counteract replay attacks. Their uniqueness ensures that even identical requests
308321
have different signatures, preventing malicious servers from successfully replaying requests.
309322

323+
Accessing a challenge string protected route is done as follows:
324+
325+
```mermaid
326+
sequenceDiagram
327+
autonumber
328+
329+
actor a as Client A
330+
participant s as Server
331+
332+
note over a: Clients have to provide session<br/>token to request challenge string
333+
a->>s: Request challenge string
334+
s->>s: Note, that Client A requests challenge<br/>string for given session identified by token
335+
s->>a: Challenge string
336+
a->>a: Complete challenge by signing<br/>string with private key associated<br/>with pubkey of this session
337+
a->>s: Call challenge string protected route with<br/>`X-P2-Challenge-String-Solution` header,<br/>where the value is equal to the challenge string solution
338+
s->>s: Verify challenge
339+
alt
340+
note over s: Challenge string solution is valid
341+
s->>s: Let Client A perform the challenge string protected action
342+
else
343+
note over s: Challenge string solution is invalid
344+
s->>s: Return 403, indicating that<br/>the challenge string solution is invalid,<br/>with optional RetryAfter header to indicate how<br/>long the client should wait before making a<br/>follow-up request.
345+
end
346+
```
347+
310348
### 4.3 Protection against misuse by malicious home servers
311349

312350
To protect users from misuse by malicious home servers, a mechanism is needed to prevent home
@@ -513,36 +551,32 @@ malicious server cannot generate an identity key pair for Alice, which is signed
513551

514552
#### 6.1.3 Key rotation
515553

516-
A session can choose to rotate their ID-Cert at any time. This is done by generating a new identity
517-
key pair, using the new private key to generate a new CSR, and sending the new Certificate Signing
518-
Request to the home server, along with at least one new KeyPackage and a corresponding 'last resort'
519-
KeyPackage, if encryption is offered. The home server will then generate the new ID-Cert, given that
520-
the CSR is valid and that the server accepts the creation of new ID-Certs at this time.
521-
522-
Rotating keys is done by using an API route, which requires authorization.
523-
524-
!!! note
525-
526-
Sessions can request a new ID-Cert for any session of the same actor. Most other, currently existing
527-
services also allow for this, as it is a common use case for user to want to, perhaps, log out of
528-
devices they no longer use. Depending on your use case, this might be a security concern. Whether
529-
and how this risk is mitigated is up to concrete implementations.
554+
A session can choose to re-generate their ID-Cert at any time. This is done by taking an identity
555+
key pair, using the private key to generate a new CSR, and sending the new Certificate Signing
556+
Request to the home server. The home server will then generate the new ID-Cert, given that
557+
the CSR is valid. Actors can only re-generate ID-Certs for their current session, identified by their
558+
session ID and session token. Other sessions can only be invalidated by [revoking them](#614-early-revocation-of-id-certs).
559+
Re-generating an ID-Cert is a [sensitive action](#412-sensitive-actions), performed by using the
560+
appropriate API route.
530561

531562
Home servers must keep track of the ID-Certs of all users (and their clients) registered on them,
532563
and must offer a clients' ID-Cert for a given timestamp on request. This is to ensure messages
533564
sent by users, even ones sent a long time ago, can be verified by other servers and their users.
534565
This is because the public key of an actor likely changes over time and users must sign all messages
535-
they send to servers. Likewise, a client should also keep all of its own ID-Certs stored
536-
perpetually, to potentially verify its identity in case of a migration.
566+
they send to servers.
537567

538568
Users must hold on to all of their past key pairs, as they might need them to
539569
[migrate their account in the future](#7-migrations). How this is done is specified in
540570
[section 6.3: Private key loss prevention and private key recovery](#63-private-key-loss-prevention-and-private-key-recovery).
541571

542572
The lifetime of an actor ID-Cert should be limited to a maximum of 60 days. This is to ensure that even
543-
in a worst-case scenario, a compromised ID-Cert can only be used for a limited amount of time. The
544-
renewal of an ID-Cert is considered a [sensitive action](#412-sensitive-actions) and should require
545-
a second factor of authentication. A client that has this second factor of authentication stored
573+
in a worst-case scenario, a compromised ID-Cert can only be used for a limited amount of time. "Renewing"
574+
an ID-Cert consists of:
575+
576+
1. Revoking the old ID-Cert
577+
2. Requesting a new ID-Cert with the same [session ID](#6113-session-ids) as the old ID-Cert.
578+
579+
A client that has this second factor of authentication stored
546580
should renew the ID-Cert of the authenticated actor without further interaction.
547581

548582
Server ID-Certs should be rotated way less often (every 1-3 years). Only rotate a server ID-Cert
@@ -588,7 +622,7 @@ of the key change, it must be informed of the change upon reconnection.
588622
keep up with demand, while introducing potential privacy concerns.
589623

590624
polyproto inherently mitigates some of the possible misuse of a revoked certificate, as the validity
591-
of a certificate is usually checked by many parties. Especially, if the revocation process is
625+
of a certificate is usually checked by many parties. Especially, vocation process is
592626
initiated by the actor themselves, the actor already lets all servers they are connected to know
593627
that the certificate in question is no longer valid.
594628

0 commit comments

Comments
 (0)