Skip to content

feat(security): what the worker serves to code is faked (ruling 133) - #2219

Open
wanderdev0 wants to merge 15 commits into
mainfrom
feat/code-reads-fakes
Open

wanderdev0 wants to merge 15 commits into
mainfrom
feat/code-reads-fakes

Conversation

@wanderdev0

@wanderdev0 wanderdev0 commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What the worker serves to code now reaches it with each registered value replaced by the session's same-length fake (ruling 133, Shane 2026-11-29). Code here means a Python cell, a survey, or an approved exec. A cell that reverses, splits or encodes a value now transforms the fake. Spec: SECRET_HANDLES.md, "What the worker serves to code is faked (ruling 133)".

Where the mask sits:

  • The wire's answers (ml-wire-serve.ts answerOf through ctx.fake, sw-ml-wire.ts wireFake). This is the catch-all: the first answer and the one after an ask, values, object keys and a pointer's label.
  • workerReadonlyMl's members (fakedMember), and an isolated exec's ml.settings.
  • derefWhole. Every read is faked before any pipe runs, through a mask the run's resolver applies (tokenSink's optional fourth argument). The model's dereference tool passes none.
  • readStoredColumns takes the forms as a required argument, and each of its three callers passes its run's.
  • The main world's pre-reads (preReadsFor).
  • The offscreen document's read of a stored table (table-fake.ts):
    • delimited text and Arrow are faked in place, with every Arrow column decided by its type from an enumerated list;
    • Parquet is handed over as it is unless a string or binary cell holds a value, and then it goes to the cell as an Arrow IPC stream built from typed arrays;
    • the read is refused, naming the column, when a value sits where a fake cannot be put (a column type with no lossless Arrow form, a view type, a column name, metadata).
  • A page-started cell's inputTables are the tables as the cell read them (sw-python.ts hoistedAsRead).

The key is the run's session. A wire client with no run uses page:<handle>, and a page-hosted run's column read uses page:<tab id>. Forms that cannot be read fail every read.

Model-facing text (new; no prompt or tool description changed):

  • "the registered secrets could not be read, so this read is withheld."
  • "ml.table: the registered secrets could not be read, so this read is withheld."
  • "ml.table(): column is , which cannot be served with registered values replaced, so this table is not read." Here is faked, and is the column name, given faked when the name itself holds a value.
  • "the answer has two keys at that read the same once registered values are replaced, so it is not read"

Tests:

  • e4's red-team rows, written failing first: tests/e2e/redteam-code-reads-fakes.spec.mjs.
    • 8 passes when run alone; it timed out only late in the 19-minute full local run, so CI's full e2e run decides it.
    • 1h is ruled a stated limit (a page-hosted run's pointers live in the page), and e4 rewrote it to pin the limit on both sides.
    • 4a (a Parquet BYTE_ARRAY column) failed in CI at 25a664d and 70f8fc6, both attempts each, with a null read: the cell's stdout was absent. The cause is inferred, not confirmed.
      • Measured: a cell that runs past python_exec's 15 s default detaches, and the tool's answer is then the Detached: notice with no stdout. A copy of the row with a 16 s busy loop gave exactly that answer locally. Unmodified, the row's python_exec step takes 8.6 s locally, and the faking held: the same row printed the fake at its length, the other row and every row.
      • Not measured: CI's runner speed, or how long the cell ran there. Crossing 15 s needs a runner about 1.75 times slower. Test durations do not settle it: on CI the Arrow Binary variant passed at 32.1 s (8.9 s locally), and the Parquet variant failed at about the same 32 s.
      • What confirms it: e4's changed row (an expect_ms, an assertion that the answer is not a detach, the cell's output recorded) green on CI at this head. If it is red there, the output it records goes to the coordinator before any rerun.
    • A page's own ml.pythonExec can test a list of candidate strings against the registered values in one call (each registered one comes back as a fake, with no name). Stated under "The cost (stated)". It stays a stated limit (Shane, 2026-12-01), and e4's oracle row pins it.
  • The builder's rows: tests/code-reads-fakes.test.mjs, 25, in the secrets genre. They cover:
    • joining and its fallbacks;
    • wire form;
    • key clash;
    • unchanged answers;
    • structural rows for every door;
    • ml.sh markers;
    • a pipe over the fake;
    • Arrow in each carrier, a dictionary, Binary, FixedSizeBinary, adjacent cells, names and metadata;
    • Parquet clean, held, Decimal refused, and key-value metadata;
    • delimited text;
    • upgrade.
  • byteString in tests/secret-mask.test.mjs: one character per byte on both paths, 0x80 to 0x9f, a leading 0xfe 0xff, and a megabyte each of ASCII, ASCII with one high byte, and mixed text.
  • Changed call shapes in tests/readonly-current.test.mjs, tests/dereference.test.mjs and tests/table-answer.test.mjs.
  • The 114 files that reach src/secret-mask.ts pass locally (2133 pass, 0 fail, the known todo rows). CI's full run is the full-suite result.

The cost, measured 2026-12-01 (figures and method in the spec's "The cost"):

  • Faking a megabyte of text costs 0.8 ms for ASCII, 1.8 ms with a non-ASCII character, and 2.6 ms with 100 matches. byteString (src/secret-mask.ts) built its one-character-per-byte string from character codes at about 12 ms a megabyte, so tests/ml-wire.test.mjs's loop of unpiped dereferences of a stored megabyte ran past its 30 s cap on CI (1.2 s on main). It now decodes natively: ASCII as it is, any other bytes widened to UTF-16 code units 0 to 255.
  • ml.table of a 300,000-row table with a binary column takes 4.2 s with a value registered and 1.7 s without for Parquet (about 8.5 µs a row), and 2.3 s and 1.6 s for Arrow (about 2.3 µs a row). The whole python_exec step on the Parquet table is 8.6 s against 6.1 s, and a one-line cell is 4.3 s, so faking is about a third of the step. On a runner about 1.75 times slower, such a cell crosses the 15 s default and detaches; no runner's speed was measured against this one.

The offscreen bundle grows from 270 KB (main at f750ae3) to 997 KB: apache-arrow and hyparquet are bundled in, and evaluated only when a stored table is read. The table below gives the offscreen document's start time, from chrome.offscreen.createDocument to its first answered message. Each figure is a median over 10 to 20 starts in one browser, and the runs alternate main and branch. The machine was shared with other sessions' runs, which is the spread.

Run main (ms) this branch (ms)
1 34.3 40.6
2 40.6 64.6
3 39.6 74.8
4 130.7 90.2
5 79.1 109.6
6 71.3 92.4

Read as about 20 to 30 ms more per start, within this noise.

Found, not repaired here. Shane decided both (2026-12-01), and the next PR in this lane builds them: the approval card marks a loopback or private-address target, and the self-approval words add "your machine and network" beside logins. A self-approving site is not made to ask; SITE_ACCESS.md states that as a limit in that PR.

  • A loopback or private-address target is treated as any other URL. fetchUrlFor (src/sw/sw-fetch-url.ts:70) refuses only non-http(s) schemes (:83), and fetchTarget (:50) only resolves the URL. So an uncredentialed fetch of http://localhost/…, 127.0.0.1 or 192.168.x.x goes ahead once the URL is approved (:145), and on a self-approving site with no approval at all. The worker's fetch runs under the extension's host permissions, so it reaches hosts the page itself cannot. The approval card does not mark such a target.
  • A page's credentials: true fetch is made with credentials: "include" (src/sw/sw-fetch.ts:137). Cross-origin, it needs only the person's per-URL grant (src/sw/sw-fetch-url.ts:125), and on a self-approving site none. The self-approval grant's words name logins and do not name the person's machine and network.

Drafted by Claude Code · work: python-packages · session 19f583d1 · claude-opus-5-5

🤖 Generated with Claude Code

wanderdev0 and others added 4 commits November 30, 2026 18:50
What the worker serves to code must reach it with each registered value replaced by its same-length fake,
before code sees it. These rows plant a registered value in each input and each code kind and assert the
cell prints the fake (RDCT, the value's length), whose reversal holds no window of the value; the stored
table rows 250,000 of 300,000 across delimited, Arrow file, Arrow stream and Parquet; typed and binary
columns; a registry value holding U+0000; the whole-text deref; a page-started cell's stdout, value and
inputTables; unreadable forms failing closed; a cell's realm reaching no browser JavaScript; and the spec's
stated live-page limit.

Fail-first at de7f424: 20 rows red, each printing today's [REDACTED:NAME]/[REDACTED]/[server] marker or the
raw value; 3b (no forms, exact read) and 7 (unreadable forms) are guards that pass today and must keep passing.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Every value the worker serves to a Python cell, a survey or an approved exec reaches it with each registered value
replaced by the session's same-length fake: the wire's answers (a catch-all, first answer and after an ask),
workerReadonlyMl's members, derefWhole (faked before any pipe runs, through a mask the run's resolver applies),
readStoredColumns (forms required), the main world's pre-reads, and the offscreen document's read of a stored table
(delimited text and Arrow faked in place, Parquet holding a value handed over as an Arrow stream, or refused naming a
column that cannot carry a fake). A page-started cell's inputTables are the tables as the cell read them.

Spec: SECRET_HANDLES.md, "What the worker serves to code is faked (ruling 133)".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mes and metadata searched, the page-hosted limit stated

Each Arrow column is decided by its type, from an enumerated list: text and bytes (FixedSizeBinary included) faked in
place, nested ones through their containers, view types searched and refused when holding a value, numbers, decimals,
dates and booleans not searched (a stated limit), and any other type refused. A column name or a metadata string
(Arrow schema and field, Parquet key-value) holding a value refuses the read. The key-clash refusal says the answer is
not read, and a table refusal's source is faked. The spec states the byte-length invariant, that a match never spans
two cells, and that a page-hosted run's pointers are not faked (ruled a limit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wanderdev0 wanderdev0 added @agent The agent loop, its tools, approvals, runs and where they start @exec The read-only exec dialect, pointers, ml.pipe and the other members a survey may call @python python_exec, the Pyodide sandbox, the Python bench @security Trust boundaries: consent, site access, privileged fetches, what a page or model reaches labels Dec 1, 2026
@wanderdev0

Copy link
Copy Markdown
Owner Author

Spec text and the four model-facing strings read at 5acd418 (docs/spec/SECRET_HANDLES.md, the new section and the known-limits pointer; docs/spec/ML_TABLE.md's bullet; the PR body). Reviewed at 5acd418, change asked. The code is janitor-3's.

  1. "A cell a page started" and "The cost (stated)" omit what the fake gives a page. A page's own ml.pythonExec gets back stdout, value and inputTables faked, so a page that hoists a table of candidate strings and prints it reads, in one call, which candidates equal a registered value: each comes back as a fake. That is a bulk confirmation oracle for an approved page, with no model in the loop. The scrub's known limits state the one-guess form (a page's own text quoted back in an error); this one tests a whole list per call. State it under "The cost (stated)": what the page learns (that a candidate of 8 or more characters is registered, never its name, and whether two candidates are the same registered value), that attempts are unbounded, and that it needs an approved origin. Ask e4 for a row that pins it as a stated limit, including that the fake carries no name. Whether it stays a limit or the page's own hoisted rows are served unfaked is Shane's decision; I am taking it to them. Do not change the behaviour in this PR.
  2. "A page-hosted run's pointers are not faked ... e4's row 1h pins both": true only once e4's rewrite is on the branch. Keep the sentence; the PR does not merge before that commit.
  3. "Rows": add e4's per-type rows and the oracle row when they land, by title.
  4. "Dependencies": the section gives 995 KB against about 263 KB, the PR body 997 KB against 270 KB at f750ae3. Use the body's measured pair and its date, and add the measured start time in one sentence (about 20 to 30 ms more per start of the offscreen document, medians of six alternating runs on a shared machine).
  5. "The cost (stated)", the unmarked fake: "Marking it for the person is an open design, owner small-fixes" names an owner who has not been asked. Write "owner to be assigned by the coordinator" and I assign it.
  6. docs/dev/: nothing there says code reads fakes. Add one line with a pointer to this section in docs/dev/pointers.md (a dereference or pipe from code runs over the fake; the model's own dereference does not) and in docs/dev/python-sandbox.md (a cell's ml.table and wire answers are faked; a stored table's carrier may be Arrow where the store holds Parquet).

Accepted as written: the type lists, the refusals, metadata refusing, the join and its fallbacks, the adjacent-cells statement, the unsearched number columns as a stated limit, ml.sh unchanged, the upgrade paragraph, ML_TABLE.md's bullet, and all four strings.

Drafted by Claude Code · work: repl-specs · session 7a8ce8b6 · claude-fable-5-2

…racle stated, the measured bundle pair, dev-doc pointers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wanderdev0

Copy link
Copy Markdown
Owner Author

Delta 5acd418...25a664d read (docs/spec/SECRET_HANDLES.md, docs/dev/pointers.md, docs/dev/python-sandbox.md, the PR body). Reviewed at 25a664d, change asked: point 3 only.

Points 1, 2, 4, 5 and 6 of the earlier comment are applied and accepted. The oracle paragraph's correction is accepted: two forms of one value get different fakes, checked against candidate in src/secret-fake.ts (the HMAC message carries the form's index, and the name enters the message, never the output).

Open: point 3. Add e4's rewritten 1h, the per-type rows and the oracle row to "Rows" by title when they are on the branch. That delta comes to me; the PR does not merge before it.

Drafted by Claude Code · work: repl-specs · session 7a8ce8b6 · claude-fable-5-2

wanderdev0 and others added 10 commits December 1, 2026 18:16
…page's candidate-list oracle as a stated limit

Row 1h, rewritten to the ruling (packages, 2026-12-01; docs/spec/SECRET_HANDLES.md
"a page-hosted run's pointers are not faked"): a PAGE-hosted run's pointer read in its main
world returns the raw value, and the same read of the same pointer in a WORKER-hosted run
returns the session fake. Today's behaviour on both sides, not a defect row.

Row 11: a page's own ml.pythonExec hoists a table column of candidate strings and learns
which candidates equal a registered form. Pins the stated limit: each matching candidate
comes back as a session fake that carries no name, two forms of one value get different
fakes, a re-read gets different fakes again, an unregistered candidate is unchanged, and a
value under REGISTRY_MIN_VALUE (8) cannot be registered so the only `*` a page list meets is
a GitHub token's own mask.

Co-Authored-By: Claude Code <noreply@anthropic.com>
… about 1 ms, not 12 (ruling 133)

Every read served to code is faked through `byteString`, which built its string from character codes at about 12 ms a
megabyte. A cell's loop of unpiped dereferences of a stored megabyte fakes each read twice, so
tests/ml-wire.test.mjs's budget row ran past its 30 s cap on CI (1.2 s on main). All-ASCII bytes now decode as they
are, and any other bytes are widened to UTF-16 code units 0 to 255 and decoded natively: 0.8 ms a megabyte for ASCII,
1.8 ms with one non-ASCII character. A row pins both paths, 0x80 to 0x9f, a leading 0xfe 0xff and a mixed megabyte
to one character per byte. The spec states the measured cost and that the page's candidate-list oracle stays a stated
limit (Shane, 2026-12-01).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…library

src/python/table-fake.ts decides a stored table's columns by Arrow type id; these rows pin that decision for
every type id apache-arrow 21 can write, with the ids enumerated from the library's own classes rather than
sampled. Text (Utf8, LargeUtf8) and bytes (Binary, LargeBinary, FixedSizeBinary) are faked where they lie and
the value's bytes are gone from the buffer; a view type (Utf8View, BinaryView) holding a value refuses, naming
the column and type and never the value, while a clean one is served as it is; containers (List, LargeList,
FixedSizeList, Struct, Map, a Dictionary through its dictionary, nested shapes at any depth) are searched
through their children; the unsearched types (Null, ints, floats, Bool, Decimal, dates, times, timestamps,
durations, intervals) are served byte-identical as the stated limit, including a Decimal holding the value's
own bytes, which only a table someone wrote with the value in it can carry.

Two ids cannot be driven and say why: 22 (RunEndEncoded) does not exist in this library, and a Union (14) —
a container by id — cannot enter a Schema here (its type carries type ids where fields belong), so no cell can
receive one.

Co-Authored-By: Claude Code <noreply@anthropic.com>
… empty answer says so

CI failed rows reading the 300,000-row table at about 32 s: the cell ran past the 15 s attach deadline and
detached, so the tool's answer carried no stdout and a setup assertion read `printed(py, …)` as null with
nothing to show. Every python_exec reading such a table (1c, 2, 3, 3b, 4a, 4b) now passes expect_ms 120000,
each raises `assertAttached` on an answer starting `Detached:` with the answer in its message, and row 4a
attaches the cell's whole output to the test so a failure carries it.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…ell, with and without a value registered (ruling 133)

Measured in Chromium: `ml.table` of a Parquet BYTE_ARRAY table takes 4.2 s with the value registered and 1.7 s
without (about 8.5 µs a row), an Arrow Binary table 2.3 s and 1.6 s (about 2.3 µs a row). The whole python_exec step
on the Parquet table is 8.6 s against 6.1 s, and a one-line cell is 4.3 s, so faking is about a third of the step. The
spec states that such a cell can cross python_exec's 15 s default on a slower runner and detach, as e4's row 4a did on CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…asured timing (ruling 133)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w rows and the byteString row with them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a registry value, a config field's shorter form or a GitHub token (ruling 133)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@agent The agent loop, its tools, approvals, runs and where they start @exec The read-only exec dialect, pointers, ml.pipe and the other members a survey may call @python python_exec, the Pyodide sandbox, the Python bench @security Trust boundaries: consent, site access, privileged fetches, what a page or model reaches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant