Repository navigation
Protect local web APIs with launch tokens and strict request validation - #6
Merged
Merged
Conversation
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.
The local web server previously accepted foreign-origin
text/plainrequests that could invoke learner-data deletion or provider-backed commands. All API reads and writes now require a fresh launch token, validated loopback Host/Origin headers, and strict bounded JSON before state or provider work begins. The served browser UI sends the token automatically; Electron IPC and CLI stdin remain compatible.The patch also handles malformed length headers and excessive JSON nesting with structured errors, prevents token-page framing/caching, and documents migration for local HTTP scripts and embedded servers. HTTP clients must bootstrap the token and reload after a server restart; remote binding and tokenless requests are intentionally refused.
Validation: 145 Python tests, JavaScript renderer/IPC/token regressions, Ruff, mocked smoke, independent malformed-request probes, and actual IPv4/IPv6 server startup checks passed. Requests rejected by the security gates caused no state/provider/dispatch effects. Opus lead and Codex adversarial checker agreed on this exact patch.
Acceptance limits: the RP loopback page was unreachable from the shared browser preview. Browser-shaped real HTTP requests and executable JavaScript VM checks passed; native Electron, camera and paid providers were not exercised.