[verified] sanitize peer chat/control/bidi before store and TUI render
Some checks failed
ci / test (pull_request) Failing after 2m2s

Strip C0 (except tab/newline), DEL, C1, and bidi/format marks at ingest
and render; keep ZWJ; lossy UTF-8 stays U+FFFD. Reject the same set in
fil names. Docs match the policy.
This commit is contained in:
Sirius DevOps 2026-09-11 23:42:48 -04:00
commit e3738c51f7
No known key found for this signature in database
9 changed files with 181 additions and 5 deletions

View file

@ -213,7 +213,7 @@ fil <xfer_id_hex>\n<filename>\n<sha256_hex>\n<idx>/<total>\n<raw bytes>
```
- `xfer_id` — 16 random bytes (32 hex)
- `filename` — 1–128 bytes, no `/`, NUL, newline, `.`, or `..`
- `filename` — 1–128 bytes, no `/`, NUL, newline, `.`, or `..`; no C0/C1 controls or bidi/format marks (U+202A–U+202E, U+2066–U+2069, U+200E, U+200F, U+200B, U+200C)
- `sha256` — SHA-256 of the **entire** file (64 hex), repeated on every chunk
- `idx` is 0-based; `total` ≥ 1; `idx < total`
- last line is raw chunk bytes (not hex), length chosen so the framed Noise
@ -225,7 +225,13 @@ is a chat line `[file] name (N bytes)`, never the raw frame.
### Chat
UTF-8 (this implementation does not enforce UTF-8). Displayed as a line.
UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the
implementation does not drop the row). Control and bidi formatting
characters are stripped at ingest and at render: C0 0x00–0x1F except
tab and newline, DEL (0x7F), C1 U+0080–U+009F, U+202A–U+202E,
U+2066–U+2069, U+200E, U+200F, U+200B, U+200C. U+200D (ZWJ) is kept
so emoji sequences stay intact. `fil ` filenames must not contain
those characters (tab and newline included). Displayed as a line.
No length limit beyond the frame cap.
## Invite (out of band)

View file

@ -52,6 +52,17 @@ intentional clearnet socket is optional `monero-wallet-rpc` on **loopback TCP**
Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback, or “direct TCP when
the onion is slow.” Those are the Tox-over-Tor leak class.
## Peer text is untrusted display data
Chat bodies and `fil ` names come from a Noise peer, not from the local user.
They are display data, not terminal commands. A friend (or anyone who stole
that session) can put ESC/CSI/OSC, C1 controls, or bidi overrides in a
payload. OnionWire strips those at ingest (so sqlite history is clean) and
again at TUI render (so rows written before this rule stay inert). Filenames
that contain the same characters are rejected, not rewritten. This is a
UI-redressing / terminal-injection boundary, not a confidentiality control:
the peer already knows the plaintext they sent.
## Out of v1
Prosody, XMPP, s2s, MAM, carbons, outbox, multi-device, DHT / name server,