Repository navigation
Fix interpreter sandbox escape + clear build-time advisories - #32
Closed
victor-hugo-dc wants to merge 2 commits into
Closed
victor-hugo-dc wants to merge 2 commits into
victor-hugo-dc wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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]andobj.keydirectly against live host values with no key filtering (src/language/interpreter.ts):"s"["constructor"]["constructor"]returned the hostFunctionconstructor.__proto__/ a built-inprototypecould overwrite a method the interpreter itself calls (e.g.String.prototype.split) withFunction.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 — readlocalStorage(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, andprototypeat every read/write sink via a smallassertSafeKey()guard. Ordinary indexing and attribute access are unaffected. Addstests/security.test.tspinning the guard.Dependency advisories
npm audit fixclears the four high + one moderate advisories (vite, source-map-js, brace-expansion, zod, csv-parse) within existing semver ranges — onlypackage-lock.jsonchanges. Two moderate@vitest/mockeradvisories remain; their fix needs a breakingvitestmajor 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 newtests/security.test.ts)npx tsc --noEmit— cleannpm run build— succeedsNot included (flagged separately for maintainers)
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.localStorage(defense-in-depth).🤖 Generated with Claude Code