Repository navigation
fix(matrix): block plaintext attachments in encrypted rooms - #118609
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 7:19 AM ET / 11:19 UTC. ClawSweeper reviewWhat this changesThe branch makes Matrix classify encrypted rooms before outbound sends and attachment or thumbnail uploads, rejecting plaintext media when encryption is unavailable or the room state changes during preparation. Merge readiness⛔ Blocked until real behavior proof is added - 5 items remain This PR remains necessary: current main can still take the media-upload path without first enforcing the encrypted-room boundary, while this branch moves that decision to the Matrix client owner and rechecks it at upload and wire-dispatch boundaries. The patch has no concrete correctness finding from source review, but the protected Priority: P0 Review scores
Verification
How this fits togetherThe Matrix channel resolves a room, creates message and media content, uploads attachments to the homeserver, and then sends the event through matrix-js-sdk. The changed decision point determines whether those media bytes may be uploaded plaintext or must be encrypted and sent only after the room is ready. flowchart LR
A[Outbound Matrix request] --> B[Resolve destination room]
B --> C[Classify room encryption]
C --> D[Prepare encrypted room]
D --> E[Upload media or thumbnail]
E --> F[Dispatch Matrix event]
C --> G[Reject unsafe plaintext media]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +39, Tests +601. Total +640 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical encrypted-room decision in the Matrix client owner, preserve normal plaintext-room delivery, and add redacted real-runtime proof that encrypted media is rejected before any plaintext upload while the fail-closed recovery message tells the operator what to do next. Do we have a high-confidence way to reproduce the issue? No, not at high confidence from this read-only environment: current-main source exposes the unsafe optional-crypto upload decision and the branch provides targeted regression tests, but no local execution or inspectable real Matrix run was available. Is this the best way to solve the issue? Yes at the architectural level: moving encrypted-room classification to the outbound client owner and rechecking at upload and dispatch boundaries is safer than relying on a late SDK rejection. Merge confidence remains incomplete until the direct SDK contract and real after-fix behavior are evidenced. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e87fb689b533. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Merged via squash.
|
…#118609) * fix(matrix): block plaintext uploads to encrypted rooms * test(matrix): spy on room encryption detection safely * fix(matrix): enforce encrypted room confidentiality at outbound owner * test(matrix): keep delivery trace client aligned with send owner
Summary
404 M_NOT_FOUND; preserve persistent crypto-state downgrade protection and require a hydrated SDK room/backend.Exact-head real Matrix homeserver and authenticated Gateway proof
Reviewed head:
6ddbffc783029d6223af5eac810e1b5ecc1c1ba9.A real pinned Tuwunel homeserver, its actual HTTP recording proxy, three ephemeral accounts, an encrypted and normal Matrix room, and an actual token-authenticated running OpenClaw Gateway were used. The Matrix account deliberately had encryption disabled. The actual running Gateway was independently verified to load the reviewed bundled source plugin—not stale built artifacts—before every scenario.
Literal redacted runtime transcript:
{"phase":"authoritative-room-state","encryptedStatus":200,"encryptedAlgorithm":"m.megolm.v1.aes-sha2","plainStatus":404,"plainErrcode":"M_NOT_FOUND"} {"phase":"reviewed-plugin-runtime","id":"matrix","status":"loaded","origin":"bundled","source":"extensions/matrix/index.ts","preuploadOwnerGuard":true,"legacyUploadHelper":false} {"phase":"actual-gateway-plugin-loader","sameProcessSourceProvenance":true,"origin":"bundled","source":"extensions/matrix/index.ts","packageLocalBuiltArtifacts":false} {"phase":"actual-gateway-live-registry","matrixLoaded":true,"origin":"bundled","failurePhase":null} {"phase":"actual-gateway-matrix-account","configured":true,"enabled":true,"running":true,"connected":true,"lifecycle":"ready","lastError":null} {"case":"encrypted-room-attachment","cliExit":1,"actionableGuidance":true,"mediaUploads":0,"plaintextTimelineSends":0,"encryptedTimelineSends":0,"routes":[]} {"case":"encrypted-room-text","cliExit":1,"actionableGuidance":true,"mediaUploads":0,"plaintextTimelineSends":0,"encryptedTimelineSends":0,"routes":[]} {"case":"ordinary-room-attachment","cliExit":0,"mediaUploads":1,"plaintextTimelineSends":1,"encryptedTimelineSends":0,"routes":[{"method":"POST","route":"/_matrix/media/v3/upload","status":200},{"method":"PUT","route":"/_matrix/client/v3/rooms/{roomId}/send/m.room.message/{transactionId}","status":200}]} {"case":"ordinary-room-text","cliExit":0,"mediaUploads":0,"plaintextTimelineSends":1,"encryptedTimelineSends":0,"routes":[{"method":"PUT","route":"/_matrix/client/v3/rooms/{roomId}/send/m.room.message/{transactionId}","status":200}]} {"result":"PASS","cases":4,"providerCalls":0,"actualHomeserver":"pinned-tuwunel","actualGatewayAuth":"token"}The two encrypted-room actions both fail visibly with guidance to enable encryption before any homeserver media upload or timeline send. The ordinary-room controls prove real attachment upload and normal plaintext delivery still work. No provider calls or real user credentials were involved.
Security owner boundaries
404 M_NOT_FOUNDproves a plaintext room. Network errors, authentication failures, generic 404s, and malformed state fail closed.application/octet-streamwithout exposing original filename.sendMessage, genericsendEvent, and actual pending retry payloads reject plaintext attachment or thumbnail references, including standard location thumbnails; committed SENT retries preserve idempotency.m.room.encryptedor redaction wire types to trick the installed SDK into skipping encryption.m.reactionremain unchanged. Reactions intentionally remain plaintext under the Matrix dependency contract; the only shipped reaction producer constructs the canonical safe annotation shape.Verification
Maintainer decision: accept fail-closed behavior for unknown encrypted state; any lookup outcome except an authenticated SDK MatrixError with HTTP 404 and M_NOT_FOUND intentionally blocks plaintext sends with actionable operator guidance.