Skip to content

Security fixes from the 2026-12-05 audit - #48

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

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

Conversation

@phasenull

Copy link
Copy Markdown
Member

Security fixes from the 2026-12-05 audit (.audits/cli-2026-12-05.md, written by Gemini). Every finding was checked against the code first; this PR holds the security ones. Correctness and optimizations are in the companion PR (fix/audit-2026-12-05-correctness). The two branches merge cleanly.

Threat model used: game code (any script in the place, dev-branch payloads included), other collaborators, and a leaked Open Cloud key with DataStore scope can all write TypeTorch/settings and heads without signing. That matches what settings.ts already assumes. Note that the record's own backend.key and Basin token can be read by that same attacker, so leaking those two adds little. The admin token, the signing keys and a redirected history export are the real stakes.

Findings

# Finding Verdict Why Done Tests
S1 Unverified settings record: secrets sent to its URLs Confirmed for the admin token (doctor's owner check, experiment list) and for migrate --to-basin (all history plus BASIN_SEND_TOKEN streamed to the record's URLs). Partly for backend setup: the game key and Basin token already sit in the record, but a forged Basin URL could be checked and then signed into the record The record is game-writable New settingsTrust / verifySettingsTrusted / trustedBody (typetorch.json signingPublicKeys minus revokedKeys, fallbackPublicKey, plus the key files when they load). doctor sends the admin token to the record's URL only when the record verified, and now also verifies with typetorch.json's keys when no key files load. experiment list uses typetorch.json backend.url only. backend setup treats an unverified record as empty (with a warning). migrate --to-basin takes the record's streams only from a verified record endpoints, backend-move (forged record: no probes, no token, no start)
S2 Junk seq near MAX_SAFE_INTEGER blocks deploys and --force Partly The deploy DoS and the --force failure are real. A "signed-looking" stored head only skips the CLI's durable-head write, and the kernel verifies heads itself, so the impact is limited to the no-server window SEQ_SANE_MAX = 2^40: larger values from heads, deployments and the counter are ignored. Such a stored head never blocks a new one. --force caps an untrusted record's seq seqstore, durablehead, settings
S3 Spawns that skip childEnv Partly Real for init (Claude Code), update (postinstall scripts) and the cloudflared installer. The dev-server already scrubs every child environment itself, so it is only defence in depth there New inheritedEnv(): the real environment minus NEVER_CHILD_VARS, secret values, and what Bun auto-loaded from .env* files (.env.local too). Used for those three spawns and for the dev-server, which keeps only the Open Cloud key variables it hands to its deploys. darkluaVersion now uses childEnv args-config-env
S4 Bless link in debug logs / argv Not a bug The link is meant to be shown: --no-open prints it and --json emits it. --verbose writes to the user's own terminal. Any URL opened in a browser shows up in argv none none
S5 .env 0644; key-file mode not checked Confirmed (multi-user hosts) upsertDotEnv writes 0600 and tightens an existing file. readKeyFile warns once per path when a key file is group- or world-readable, naming chmod 600 init, keys
S6 Unescaped paths in login tasks Partly The slug is already slugified, and the paths are the user's own, so this is robustness, not injection % is doubled in systemd units and .cmd files. Line breaks are refused, and so is " in Windows paths init-backend
S7 OpenCloud redirects / absolute URLs / unredacted debug Partly No caller passes an absolute URL, and a cross-origin redirect from apis.roblox.com is hypothetical Absolute URLs off https://apis.roblox.com are refused before sending. The network-error debug line is redacted. The redirect mode is unchanged (see below) kernel-luau
S8 ssh without -- Not a bug user is validated ^[a-z_]…, so user@host never starts with - -- added anyway (one token) init-backend

Maintainability M1 ("readSettings is unsafe by default") is partly covered by the trustedBody helper. The rename is left for later.

Needs your call

  1. Full signature checks on stored heads in the CLI (readSharedSeq, headReplaces). This would mean porting the kernel's head canonical string and bootstrap-head rules. For now: the 2^40 cap, and the kernel stays the verifier.
  2. redirect: "error" / "manual" on Open Cloud requests. Left out because I can't rule out a legitimate redirect on some endpoint without live testing.
  3. A Basin stream host allowlist (*.ingest.cloudflare.com). Signature verification already covers the forged-record case. An allowlist would break any custom host.
  4. A record that verifies with neither typetorch.json's keys nor local key files (for example a project with no signingPublicKeys and no key files on this machine) is now "untrusted" for these paths: doctor warns, migrate --to-basin needs --events/--recordings, and backend setup re-checks from scratch. The write path is unchanged: it still refuses such a record without --force.
  5. The Windows .vbs launcher: WshShell.Run expands %VAR% in the .cmd path, and that has no escape. This only matters if the game folder contains %.
  6. 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: 913 pass, 4 skip, 1 fail. The failure is backend bless > … opens the single-use link, which already fails on main (a test-isolation leak). The companion PR fixes it, and with it its full run is 912 pass, 0 fail.
  • bun run build: pass. node scripts/smoke.mjs: all smoke checks passed.

🤖 Generated with Claude Code

phasenull and others added 6 commits December 5, 2026 02:30
Game code can write the TypeTorch/settings entry, so its URLs are only trusted when the record verifies with
typetorch.json's public keys (signingPublicKeys minus revokedKeys, fallbackPublicKey) or the local key files:
- doctor: the owner-list check sends the admin token to the record's backend.url only when the record verified
  (it now also verifies with typetorch.json's keys when the key files don't load here)
- experiment list: the admin token goes to typetorch.json backend.url only
- backend setup: the kept ingest address and Basin streams come from a verified record only (an unverified one
  counts as empty, with a warning), so TYPETORCH_API_KEY / BASIN_SEND_TOKEN never reach a forged address
- backend migrate --to-basin: the record's streams are used only from a verified record

Audit 2026-12-05, S1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Game code can write TypeTorch/heads, deployments, seq and settings unsigned. A seq near Number.MAX_SAFE_INTEGER made
the next seq unsafe, so every signed deploy threw in canonicalString and settings push --force couldn't recover.
- seqstore: values above SEQ_SANE_MAX (2^40) are ignored as junk (heads, deployments, the counter's answer)
- durablehead: a stored head with such a seq never blocks a real one (even with a dummy sig field)
- settings --force over an untrusted record caps its seq, so seq + 1 still signs

Full signature checks on stored heads stay with the kernel (Registry.luau); see the PR's "Needs your call".
Audit 2026-12-05, S2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
childEnv (allowlist) was skipped by a few spawns. Children that need the user's own setup now get inheritedEnv: the
real environment minus NEVER_CHILD_VARS, any value equal to a known secret, and what Bun auto-loaded from .env*
files (.env.local included):
- init: Claude Code (plugin add + the session)
- update: the package manager (postinstall scripts)
- serve: the cloudflared installer
- remote-claude: the dev-server keeps only the Open Cloud key variables it hands to its deploys
darkluaVersion now runs with childEnv like the other darklua calls.

Audit 2026-12-05, S3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- upsertDotEnv (init) writes the game's .env with mode 0600 and tightens an existing one on POSIX
- readKeyFile warns once per path when a signing key file is group/other readable, naming chmod 600

Audit 2026-12-05, S5.

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

A game folder or Bun path with % was expanded (systemd specifiers, %NAME% in .cmd), and a line break would start a new
directive or command. % is now doubled there; line breaks (and " in Windows paths) are refused. The paths are the
user's own, so this is robustness more than a security boundary.

Audit 2026-12-05, S6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- OpenCloud.request throws before sending when an absolute URL isn't on https://apis.roblox.com (no caller passes
  one today; defense in depth), and the network-error debug line is redacted like the thrown error
- ssh / the Coolify panel forward put `--` before user@host

Audit 2026-12-05, S7 (partly) and S8.

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