Skip to content

Correctness fixes from the 2026-12-05 audit - #49

Open
phasenull wants to merge 7 commits into
mainfrom
fix/audit-2026-12-05-correctness
Open

phasenull wants to merge 7 commits into
mainfrom
fix/audit-2026-12-05-correctness

Conversation

@phasenull

Copy link
Copy Markdown
Member

Correctness fixes and one optimization from the 2026-12-05 audit (.audits/cli-2026-12-05.md, written by Gemini). Every finding was checked against the code first. The security findings are in the companion PR (fix/audit-2026-12-05). The two branches merge cleanly.

Findings

# Finding Verdict Why Done Tests
C1 keys rotate / resign re-sign from the local log only: possible prod rollback Confirmed readHistory is local-only resignHeads reads the kernel's DataStore heads first. A live head newer than the local one (higher seq, or same seq on another asset) is not re-signed: it fails with the fix. A live head that lags is fine. A prod branch that is live but missing from the local log gets a warning. Heads that can't be read with a deploy key make every branch fail closed. With no deploy key there is a warning, then the old behaviour. Forged heads can only block a re-sign, never cause one keys
C2 Remote Studio Claude Apply/Deploy/Discard/Cancel broken Confirmed body.id was prefixed with remote/<device>/ on every POST The prefix now applies to /tt/plugin/* only (as the query-string id already did). Prompt ownership still comes from the paired Roblox user serve-claude (remote deploy reaches the prompt)
C3 approve uses the stale proposal channel for --wait, rollback and backup Confirmed approvalChannel() is shared by approveProposal and approveCommand approval
C4 "minify": false dropped as an unknown key Confirmed (the README even documented it) Known boolean key on ProjectConfig; a non-boolean is an error; README updated args-config-env
C5 TOCTOU in stale-lock takeover Confirmed (narrow: two runs racing on a lock that has been stale for 10 or more minutes) removeStaleLock: rename aside atomically, check it is the lock that was judged stale, and put a live one back with a hard link build
C6 jsonMode leak fails bun test Partly (the bug is real, the culprit was wrong) progress.test.ts already resets. The leak came from the quiet() fixture, used by updatecheck.test.ts quiet() restores the previous mode; the bless test sets its own full run: 0 fail
O1 Second rojo build per build Deferred Valid, but it changes how the ArtifactId hash is stamped on signed payload bytes none none
O2 Lazy-load command modules Deferred Large refactor of index.ts none none
O3 Tunnel temp folders never removed Confirmed serve's QuickTunnel removes its folder on stop (and rewrites the config on each spawn). backend run removes each start's folder when cloudflared exits serve-tunnel
O4 rbxm Writer byte-by-byte Not worth it now It only encodes small attribute chunks none none
M2/M3 readHistory naming, duplicated helpers Deferred Cosmetic none none

Needs your call

  1. O1 (a single rojo build) and O2 (lazy command loading): worth doing, but each is a design change. O1 touches how the signed payload's ArtifactId is stamped.
  2. C1 follow-up: approving a resign proposal still checks only the local log at approval time (approveProposal). The live-head check runs when the proposal is created. Adding it at approval too would need the deploy key there, which approval already uses.
  3. CHANGELOG.md is gitignored and lives only in the main checkout, which I left alone. It is not updated.

Test results

  • bunx tsc --noEmit: pass
  • bun test: 912 pass, 4 skip, 0 fail (the bless test that fails on main passes here)
  • bun run build: pass. node scripts/smoke.mjs: all smoke checks passed.

🤖 Generated with Claude Code

phasenull and others added 7 commits December 5, 2026 02:37
The kernel-luau fixture's quiet() switched the process to --json and left it there, so updatecheck.test.ts (which uses
it and has no reset) left json mode on for init-backend.test.ts, whose bless test then took the JSON path and failed
in the full run. (The audit blamed progress.test.ts, which already resets in afterEach.)

Audit 2026-12-05, C6.

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

The remote gateway prefixed body.id with remote/<device>/ on every POST, including /tt/claude/deploy and
/tt/claude/cancel, where it is the dev-server's prompt id: the request failed (over 64 chars, or a 404 upstream). The
prefix now applies to plugin routes only, as the query-string id already did. Prompt ownership stays with the
paired Roblox user (claudeUser).

Audit 2026-12-05, C2.

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

approveProposal signs with the stricter of the proposal's channel and typetorch.json's current one, but approveCommand
passed the proposal's stale channel to waitSeconds, waitAfterRelease and autoRefreshBackup: a branch moved to prod
after proposing got no default wait, no backup refresh, and an unsigned (refused) auto-rollback. Both now use
approvalChannel().

Audit 2026-12-05, C3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build.ts honoured project.config.minify and the darklua warning suggested it, but config.ts didn't know the key: it
warned `unknown key "minify" (ignored)` and dropped it, so prod payloads were minified anyway. Now a known boolean
key on ProjectConfig (a non-boolean is an error); README updated.

Audit 2026-12-05, C4.

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

Two runs that saw the same stale lock both rmSync'd "it"; the second could delete the lock the first had just
created, and both ran. removeStaleLock moves the file aside atomically, checks it is the lock it judged stale (each
lock's text holds its pid and creation time), and puts a live one back with a hard link (never over a newer lock).

Audit 2026-12-05, C5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serve's QuickTunnel removes its temp folder on stop (and writes the empty config again on each spawn); backend run
removes each tunnel start's folder once its cloudflared exits.

Audit 2026-12-05, O3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resignHeads took each prod branch's head from this machine's deployments.jsonl only. On a machine whose log is
behind (CI or another PC deployed since), it re-signed and published the older asset with a new seq: a rollback.
It now reads the kernel's DataStore heads first:
- a live head with a higher seq (or the same seq on another asset) than the local one: that branch is not re-signed
  (failed, with the fix: run keys resign where it was deployed); a live head that lags (no server since) is fine
- a prod branch live in the DataStore but absent from the local log: a warning (it isn't re-signed here)
- heads unreadable with a deploy key: every branch fails closed (keys resign retries)
- no deploy key: a warning, then the old behaviour (proposals; approving needs the key)

Stored heads are unsigned data, so a game-written one can only block a re-sign, never cause one.
Audit 2026-12-05, C1.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant