Skip to content

Fix interpreter sandbox escape + clear build-time advisories - #32

Closed
victor-hugo-dc wants to merge 2 commits into
mainfrom
security/interpreter-sandbox-hardening
Closed

victor-hugo-dc wants to merge 2 commits into
mainfrom
security/interpreter-sandbox-hardening

Conversation

@victor-hugo-dc

Copy link
Copy Markdown
Collaborator

Summary

Security review of the client-side interpreter and dependencies. One critical fix plus a dependency cleanup.

Critical: interpreter sandbox escape → arbitrary JS execution

The AST interpreter evaluated obj[key] and obj.key directly against live host values with no key filtering (src/language/interpreter.ts):

  • Reading "s"["constructor"]["constructor"] returned the host Function constructor.
  • Writing to __proto__ / a built-in prototype could overwrite a method the interpreter itself calls (e.g. String.prototype.split) with Function.

Chained, interpreted code could break out of the AST walker and run arbitrary JavaScript on the page's origin. Programs arrive from untrusted share/embed links (?code=…), so a crafted link could — once a victim clicks Run — read localStorage (Google session token, Keycloak access/refresh tokens, cleartext BYOK API key) and exfiltrate it. This is a sandbox escape, not just a footgun.

Fix: reject the keys __proto__, constructor, and prototype at every read/write sink via a small assertSafeKey() guard. Ordinary indexing and attribute access are unaffected. Adds tests/security.test.ts pinning the guard.

Dependency advisories

npm audit fix clears the four high + one moderate advisories (vite, source-map-js, brace-expansion, zod, csv-parse) within existing semver ranges — only package-lock.json changes. Two moderate @vitest/mocker advisories remain; their fix needs a breaking vitest major bump, they are dev-only and not reachable here, so they're left for a deliberate upgrade.

Testing

  • npm run test:run — 616 passed, 4 skipped (includes the new tests/security.test.ts)
  • npx tsc --noEmit — clean
  • npm run build — succeeds

Not included (flagged separately for maintainers)

  • Backend secrets (GOOGLE_CLIENT_SECRET, SESSION_SECRET, credentials.json) sit in this frontend repo's working tree. They are gitignored, never committed, and not in the bundle — but they belong out of this repo, and should be rotated if there's any doubt they were exposed.
  • Auth tokens + BYOK key persisted in localStorage (defense-in-depth).

🤖 Generated with Claude Code

victor-hugo-dc and others added 2 commits October 29, 2026 08:05
The AST interpreter evaluated obj[key] and obj.key directly against live
host values with no key filtering. A program could read
"s"["constructor"]["constructor"] to reach the host Function constructor,
or write to __proto__ / a built-in prototype to overwrite a method the
interpreter itself calls (e.g. String.prototype.split) — either path lets
interpreted code run arbitrary JavaScript on the page's origin.

Programs arrive from untrusted share/embed links (?code=...), so a crafted
link could, once Run is clicked, read localStorage (Google session token,
Keycloak access/refresh tokens, the cleartext BYOK API key) and exfiltrate
it. This is a sandbox escape, not just a footgun.

Reject the keys __proto__, constructor, and prototype at every read/write
sink via assertSafeKey(). Ordinary indexing and attribute access are
unaffected. Adds tests/security.test.ts pinning the guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolves the four high and one moderate advisories (vite, source-map-js,
brace-expansion, zod, csv-parse) within existing semver ranges — only
package-lock.json changes. Tests and production build pass.

Two moderate @vitest/mocker advisories remain; their fix needs a breaking
vitest major bump that `npm audit fix` won't apply on its own. They are
dev-only (test mock registration) and not reachable in this project, so
left for a deliberate vitest upgrade.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ChrisMayfield
ChrisMayfield deleted the security/interpreter-sandbox-hardening branch December 2, 2026 14:54
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.

2 participants