Skip to content

security: track cookie-imported domains and scope cookie imports#615

Open
halbert04 wants to merge 1 commit intogarrytan:mainfrom
halbert04:security/scoped-cookie-imports
Open

security: track cookie-imported domains and scope cookie imports#615
halbert04 wants to merge 1 commit intogarrytan:mainfrom
halbert04:security/scoped-cookie-imports

Conversation

@halbert04
Copy link
Copy Markdown

Summary

  • Adds cookie origin tracking to BrowserManager — every cookie import path now records which domains were imported
  • The cookie-import-browser direct CLI mode now requires either --domain <domain> (scoped) or --all (explicit opt-in) for non-interactive use
  • The cookie-import (JSON file) path also tracks imported domains
  • The --all flag works but emits a warning recommending --domain for tighter scoping

Why this matters

When cookies are imported without domain scoping, the headless browser gets access to every authenticated session in the user's real browser — Gmail, GitHub, banking, corporate SSO. A prompt injection via web page content could instruct the agent to navigate to a sensitive domain and exfiltrate data.

By tracking which domains had cookies imported, downstream commands can restrict operations to those origins. This PR is the foundation for origin-pinned JS execution (separate PR) — the BrowserManager now knows which domains have imported cookies.

Changes

File What changed
browse/src/browser-manager.ts Added cookieImportedDomains set + trackCookieImportDomains(), getCookieImportedDomains(), hasCookieImports() methods
browse/src/write-commands.ts cookie-import-browser: added --all flag with warning, domain tracking on import. cookie-import: added domain tracking

Backward compatibility

  • cookie-import-browser chrome --domain .example.com — works as before, now also tracked
  • cookie-import-browser chrome (no flags) — opens picker UI as before (unchanged)
  • cookie-import-browser chrome --all — new explicit opt-in for all cookies
  • cookie-import cookies.json — works as before, now also tracked

No breaking changes. The --all flag is additive.

Test plan

  • cookie-import-browser chrome --domain .github.com imports only github cookies and tracks the domain
  • cookie-import-browser chrome --all imports all cookies with a warning
  • cookie-import-browser chrome (no flags) opens the picker UI as before
  • cookie-import cookies.json tracks domains from the JSON file
  • bm.hasCookieImports() returns true after any import, false before

Made with Cursor

- Add cookie origin tracking to BrowserManager (trackCookieImportDomains,
  getCookieImportedDomains, hasCookieImports). Every cookie import path
  now records which domains were imported.

- cookie-import-browser direct mode already required --domain; this adds
  --all as the explicit opt-in for importing all cookies. Without either
  flag, the interactive picker UI opens instead.

- cookie-import (JSON file) now tracks imported domains on BrowserManager.

- The --all flag works but emits a warning recommending --domain for
  tighter scoping.

This is the foundation for origin-pinned JS execution (separate PR) —
the BrowserManager now knows which domains have imported cookies, so
downstream commands can restrict operations to those origins.

Made-with: Cursor
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