Skip to content

docs: the recipe for decoding in a box - #10

Merged
stephen-masters merged 1 commit into
mainfrom
docs/boxed-decoding
Nov 1, 2026
Merged

stephen-masters merged 1 commit into
mainfrom
docs/boxed-decoding

Conversation

@stephen-masters

Copy link
Copy Markdown
Contributor

Summary

  • A Decoding in a box page: the recipe the README has promised under "what it does not do", for the flaw in a reader you allow that no check can see. Two files, a parent and a worker. The parent runs the check, then the worker in a fresh Python with no environment, a scratch working directory, nothing on stdin and a wall-clock limit; the worker sets RLIMIT_AS, RLIMIT_CPU, RLIMIT_FSIZE and no core dump on itself, opens with only the allowed readers, decodes, and writes a PNG of its own making. A dead worker becomes a sentence naming the signal or the exception.
  • The allowance is sized from the policy (a baseline plus bytes per pixel), stated as a starting point to measure against.
  • What systemd-run, bwrap and a container add on Linux; what macOS does not enforce (RLIMIT_AS) and what that leaves; what the box is not.
  • The README's bullet now links the page instead of saying a recipe is planned.

Stage 4 of brief 022.

Test plan

  • Both files run on Linux (python:3.12-slim in Docker, Pillow and sillybos 3.0.0): a normal scan decodes; a 445 KB PNG that decodes to 432 MB RGB is refused by the check under the default policy, and under a loosened policy is refused by a 512 MiB box with MemoryError in 0.1 s; a normal scan decodes under the same box. The output quoted on the page is that run's
  • zensical build --clean --strict, ruff format --check (the page's code blocks are formatted), ruff check

🤖 Generated with Claude Code

Stage 4 of brief 022: what to do about a flaw in the reader you allow,
which the check cannot know about. Two files, a parent and a worker: the
check first, then the decode in a fresh process that has set its own
memory, processor, output and core-dump limits, with a wall-clock limit
and a scrubbed environment from outside, and a sentence back for
whatever ends it. Run on Linux in a container before writing up: a
445 KB PNG that decodes to 432 MB failed inside a 512 MiB box in a tenth
of a second, and a real scan decoded under the same box. The page says
what systemd-run, bubblewrap and a container add, what macOS does not
enforce, and what the box is not. The README's "what it does not do"
now points at it instead of promising it.

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@stephen-masters
stephen-masters merged commit e59b474 into main Nov 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant