Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

1.2.5 security notes: what the three fixes were, in the changelog and the decision log (#578)

nyblnet4b1e05adb5be
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4bce968..cda4c177 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,8 +58,33 @@ pre-1.0.
## [1.2.5] — 2026-09-28
- **Security: update this file. This release closes three security issues
- found in our own review.** None needs anything from you beyond updating. What
- each one was is described here once people have had time to update.
+ found in our own review.** None needs anything from you beyond updating.
+ - **A slide could quietly phone home when opened.** A deck carrying a vector
+ drawing could, through a corner of the styling it is allowed to use, make
+ your browser fetch a web address the author chose the moment the slide was
+ shown — a silent read receipt with your IP and the time you opened it, the
+ very thing a self-contained file is meant not to do. No code ran and
+ nothing looked wrong on screen; every route that carries a drawing (a
+ mailed file, a paste, a live edit) could carry it. Drawing styles are now
+ checked by the browser's own parser instead of by pattern-matching, so the
+ disguises that slipped past — an address written with escape codes, or as
+ one of CSS's image functions — no longer do.
+ - **Another local file could hijack "Restore your unsaved changes."** On a
+ desktop browser, local files opened from disk share one storage area (the
+ same quirk behind the 1.2.2 fix). A malicious `.bento.html` opened from
+ disk could plant a fake recovery snapshot for one of your decks; the next
+ time you opened that deck, the "Restore your unsaved changes?" prompt would
+ offer it, and restoring it could move the deck into a live session the
+ attacker controlled — later edits syncing to them, their keys written into
+ your file on save. Restored snapshots now pass through the same safety
+ check as pasted JSON, and the deck's identity and live-session keys always
+ come from the real file, never from a snapshot.
+ - **A malformed Office file could freeze the tab.** Importing a crafted
+ `.pptx` or `.xlsx` (bento/slides' import page, bento/dash's spreadsheet
+ import) could exhaust memory and hang the browser: a tiny compressed part
+ that expands without bound. Imports now stop unpacking a part the moment it
+ grows past its declared size, so a decompression bomb is refused instead of
+ swallowing the tab.
- **Orange text can be read in dark mode again.** The armed comment tool, the
tick beside your language, your own name in a comment thread and the labels
on slide and point comments were drawn in a dark brown meant for text on the
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 4495564d..c577426c 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -7944,3 +7944,66 @@ version writes and no renderer can draw. Verified: 9 real decks pass through
byte-identical with every element kept, and a document from a "newer version"
keeps its unknown keys and element type through boot.
`scripts/test-slides-minimal-doc-browser.mjs` guards it (mutation-checked).
+
+## 2026-09-28 — the svg style sanitizer matches the browser's parse, not text
+
+`sanitizeSvgCss` removed external `url(...)` with a regex over the raw CSS.
+CSS decodes escapes in an ident BEFORE deciding a token is `url(`, so
+`\75 rl(https://…)` is a url the regex never sees; and the string-form image
+functions (`image-set("https://…" 1x)`, `-webkit-image-set`) carry a fetch
+with no `url(` at all. Either reached the network when an svg element was
+rendered — a read receipt (reader IP + timing) on open, exactly what PLATFORM
+§1 and the remote-image consent rule exist to prevent. No script execution.
+Reachable by every route that carries an svg element (file, paste, collab op,
+Replace-from-JSON). Fixed by parsing instead of matching: decode escapes,
+allowlist CSS function names (image functions other than `url(#…)` /
+`url(data:image/…)` refused), and confirm with a constructed `CSSStyleSheet`
+and an `element.style` oracle that canonicalise both families back to `url()`
+on read-back — so the check is the browser's own parse, not a spelling.
+Measured before and after in Chromium against a request-logging server (every
+escape/image-set/nested family plus the positive control), and end to end
+through a built deck with a zero-request network log; mutation-verified.
+Rule: a text scan can never enumerate the ways a browser spells a fetch;
+sanitize CSS by parsing it the way the browser will, and assert egress, not
+substrings. (Note: `scopeCss` corrupts every at-rule but `@keyframes`, so a
+nested `@media` was not live-exploitable through the css path; the sanitizer
+neutralises it anyway.)
+
+## 2026-09-28 — a restored snapshot is untrusted input; identity comes from the file
+
+Autosave recovery and version history are keyed only by `docId` in the shared
+`file://` store, and Restore applied the stored JSON with a raw `replaceDoc` —
+outside the untrusted-input gate that paste and Replace-from-JSON use. A local
+file could plant a snapshot under a victim deck's `docId`; on Restore the deck
+adopted the snapshot's `collab` (moving it into a room and key the planter
+chose — later edits sync there, and ⌘S writes those credentials into the real
+file) and its `readonly` flag. Content substitution behind a trustworthy
+prompt, escalating to live exfiltration; no user action beyond clicking
+"Restore your unsaved changes." Fixed: a new gate rebuilds a restored snapshot
+through the untrusted.ts sanitizers (`sanitizeSlide`/`sanitizeAssets`/
+`sanitizeFonts`, non-model keys dropped, settings shape-checked), and `docId`,
+`collab` and `readonly` are ALWAYS the open file's, never the snapshot's; a
+snapshot that is not a document after the gate is never offered; the recovery
+banner AND version-history restore both gate. Rule: anything read back from
+browser storage on a shared origin is foreign input — sanitize its content and
+take identity and capability from the live file, never from the stored copy.
+The durable fix (a per-file key so a forged entry is not even offered) is the
+local-storage programme.
+
+## 2026-09-28 — decompression stops at the declared size
+
+`readZip` bounded the compressed input to the entry's `csize` but inflated the
+whole stream into memory before checking the result against `usize`; the
+convert preflight trusted the declared sizes. A crafted archive that
+under-declares inflates far past its stated size (deflate reaches ~1032:1)
+before any guard fires — a client-side memory-exhaustion DoS on opening a
+`.pptx` (import page) or `.xlsx` (dash). Fixed once in `readZip`: a bounded
+reader over the `DecompressionStream` aborts the moment cumulative output
+passes `min(declared usize, 256 MiB)`, so the output is never fully allocated;
+dash, convert and the import page inherit it. Verified by running a real
+under-declared bomb — refused with ~2.5 MB peak allocation, versus ~73 MB when
+the cap is neutered, proving the bounded reader (not the post-hoc size check)
+does the work — with legitimate `.pptx`/`.xlsx` imports unaffected. Rule: a
+size limit must be enforced DURING decompression, never after; the declared
+size in a container header is an attacker input, and the primitive, not the
+caller's preflight, must hold the ceiling.