feat(security): add host origin allowlist on start - #170
Open
yashranaway wants to merge 2 commits into
Open
Conversation
Restrict agent navigation with repeatable `headless start --allow PATTERN`. The matcher is an extra conjunct in agentMayNavigate; ping reports the active list, and changing it on a running host requires stop first.
Collaborator
Author
|
Please review this one first. #169 (file upload) was branched from the same |
Collaborator
Author
|
macOS CI failed on the runner SDK, not the allowlist: |
agentMayNavigate now references NavigationAllowlist. The macOS SDK selection typechecks Protocol.swift in isolation, so every SDK looked incompatible and CI reported a missing toolchain.
Collaborator
Author
|
The macOS failure was the SDK probe, not the runner. |
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
Adds a host-enforced origin allowlist so a prompt-injected agent cannot leave the app under test.
headless start --allow PATTERNrestricts visit, top-frame navigation, and in-page clicks; omitting--allowkeeps today's unrestricted HTTP(S) behavior.Contract
--allow; comma-separated values in one flag also accepted.--allowcannot addfile:,javascript:, credentials, or blocked extensions.normalizedWebURLis unchanged; the allowlist is an extra conjunct inagentMayNavigate.--allowis a parse error.*alone, paths, schemes, credentials, non-ASCII, and unexpected characters fail closed. Cap 32 patterns; case-insensitive DNS; IPv4 literals as exact hosts.*.example.commatches subdomains, not the apex, and notexample.com.evil.test.localhostmatches any port;localhost:3000matches only that port.UNSAFE_NAVIGATION.status/ ping includesnavigationAllowlist(empty array means unrestricted).NAVIGATION_ALLOWLIST_CONFLICT— stop first). Matching list orstartwithout--allowagainst a running host is a no-op.HEADLESS_NAVIGATION_ALLOWLISTon the spawned host. The injected runtime gets a JSON-encoded copy as defense in depth; host policy is authoritative.Tests
*/ schemes / credentials / empty--allow/ too many patterns, matcher (wildcard non-match, apex vs subdomain, port exactness, unrestricted when empty), visit still validatesexample.comas a URL, host-side deny viaagentMayNavigate, ping reports the list.__headlessNavigationAllowlist.start --allow 127.0.0.1, fixture visit OK,https://example.comand off-list click failUNSAFE_NAVIGATION, mismatch requires stop, restore unrestricted host.pnpm test:runtimepassed. Localpnpm testcannot run Swift on this Linux box (exit 69); the Linux Docker builder ran 46/46 protocol tests and Linux P2 E2E passed, including the new allowlist block.Review
@SarthakWade please review before morning.
Closes #167