Skip to main content

P8. Limits, errors, and edge cases

Work in progress — not audited

Normative protocol documentation for the current implementation. Not independently audited.

P8.1 Size limits

LimitValueApplies to
Max JSON PDU (data channel)16 MiBAny single JSON object; MUST reject larger
Cascade chunk size8192 bytesfinalCiphertext over data channel
Fast transfer chunk (initial)8 MiBFast file path
Fast transfer chunk range1 MiB – 16 MiBAdaptive
Fast per-message metadata cap256 KiBSome fast paths
WebRTC buffer threshold8 MiBbufferedAmount backpressure

Oversized cascade payloads MUST use chunking (P5); senders MUST NOT truncate without chunking.

P8.2 Error handling — Profile-v0 (current)

ConditionReceiver behavior
JSON parse errorMUST drop PDU
PDU size > 16 MiBMUST drop before full parse if possible
Unknown typeMUST drop; MAY log at debug only
Decrypt/auth failureMUST NOT deliver plaintext
Missing chunkMUST wait or timeout; MUST NOT decrypt partial
Handshake PDU after fatal errorSHOULD ignore
Encrypt failureMAY fallback MLS-only; SHOULD log

Profile-v0 has no application-level error codes on the wire.

Implementations MAY use other values until Profile-v1. Recommended SHOULD values:

TimerRecommendedApplies to
Chunk reassembly120 sPer messageId
Handshake stall300 sFrom data channel open to encryptionReady

P8.4 Denial of service

Receivers SHOULD cap:

  • 4096 chunks per messageId
  • 64 concurrent messageId reassemblies per remote peer

Additional mitigations:

  • Reject excessive JSON array lengths before allocation.
  • Signaling rate limits: broker policy (out of band).

P8.5 Security considerations

This profile addresses mitigations for:

  • Chunk flooding / reassembly DoS (P8.4 caps).
  • Oversize JSON / memory exhaustion (16 MiB cap).
  • Signaling MITM via broker compromise (P2.8).
  • Malicious peer (invalid PDUs, spam) — drop on failure.
  • Application-layer replay — dedup by messageId (product layer).
  • Supply-chain / subverted JS — see ch. 8.

P8.6 Edge cases

CaseRule
Cascade disabled mid-sessionMUST re-handshake or send cleartext only if encryption off
Peer ID changeMUST full handshake
MLS fallback after cascade failencryptedMessage uses envelope not cascadedPayload
Empty plaintextAllowed; still encrypted
Duplicate messageIdApplication-layer dedup; not protocol-forbidden

P8.7 Versioning (v0)

Until EnkryptedChat-Profile-v1 is published, implementations MAY add JSON fields without breaking single-codebase deployments. Third parties MUST NOT assume stability.

Profile-v0 implements protocol-error PDUs in p2p (MLSProvider, PeerProvider). Receivers MUST still drop failing PDUs if no error PDU is received.

P8.8 protocol-error PDU (implemented)

FieldTypeRequiredDescription
typestringMUST"protocol-error"
codenumberMUSTSee table below
messageIdstringMAYRelated message
detailstringMAYDebug text; MUST NOT contain secrets
CodeNameWhen
1DECRYPT_FAILEDAEAD/auth failure
2UNKNOWN_PDUUnknown type
3CHUNK_TIMEOUTReassembly timeout
4OVERSIZEPDU over limit
5HANDSHAKE_REQUIREDE2EE before encryptionReady

Senders SHOULD emit protocol-error on the paths implemented in Profile-v0 (MLSProvider, PeerProvider); receivers MUST still drop failing PDUs if no error PDU is received.