Skip to content

fix(extension): respect host-only cookie domains - #3465

Closed
Kelvin-Waititu wants to merge 1 commit into
browserbase:mainfrom
Kelvin-Waititu:fix/host-only-cookie-matching
Closed

Kelvin-Waititu wants to merge 1 commit into
browserbase:mainfrom
Kelvin-Waititu:fix/host-only-cookie-matching

Conversation

@Kelvin-Waititu

@Kelvin-Waititu Kelvin-Waititu commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3464.

context.cookies("https://sub.example.com/") returned host-only cookies for example.com, even though those cookies do not apply to the requested host. Preserve the original domain's leading-dot distinction: host-only cookies require an exact hostname, while dotted domains also match subdomains on a dot boundary.

Add focused regression tests for exact hosts, subdomains and nested subdomains, unrelated suffixes, dotted domain cookies, secure URLs, path boundaries, and multiple/empty URL filters. Include patch changesets for the extension and TypeScript/Python SDKs that bundle it. No protocol or API changes.

Validation

  • Before the production fix: cookie suite had 3 failed / 20 passed; the failures reproduce host-only cookies matching subdomains.
  • After the fix: cookie suite 23 passed.
  • Full extension unit suite: 75 files passed; 1,229 tests passed, 9 TODO.
  • Extension TypeScript check: node_modules/.bin/tsc --noEmit -p packages/extension/tsconfig.json passed.
  • Extension build: node_modules/.bin/vite build --config packages/extension/vite.config.ts passed.
  • Targeted oxlint, oxfmt check, changeset validation, and git diff --check passed.

The first broader test run was blocked by sandbox restrictions on local HTTP listeners and missing build artifacts. After building the extension and rerunning outside the sandbox, the entire extension suite passed. No live-browser integration test or full monorepo/Python suite was run. pnpm and just were unavailable on PATH, so checks used the installed workspace executables directly.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c008c29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-code Patch
@browserbasehq/stagehand-integrations-codex Patch
@browserbasehq/stagehand-integrations-cursor Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-fx Patch
@browserbasehq/stagehand-integrations-mastra Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch
@browserbasehq/stagehand-integrations-eve-harness Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 16, 2026
@github-actions github-actions Bot added external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. and removed external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was approved by @shrey150 and mirrored to #3468. All further discussion should happen on that PR.

@github-actions github-actions Bot closed this Nov 16, 2026
shrey150 pushed a commit that referenced this pull request Nov 16, 2026
Mirrored from external contributor PR #3465 after approval by @shrey150.

Original author: @Kelvin-Waititu
Original PR: #3465
Approved source head SHA: `c008c299ceadac61d672538f6f90bf8b9387e095`

@Kelvin-Waititu, please continue any follow-up discussion on this
mirrored PR. When the external PR gets new commits, this same internal
PR will be marked stale until the latest external commit is approved and
refreshed here.

## Original description
## Summary

Fixes #3464.

`context.cookies("https://sub.example.com/")` returned host-only cookies
for `example.com`, even though those cookies do not apply to the
requested host. Preserve the original domain's leading-dot distinction:
host-only cookies require an exact hostname, while dotted domains also
match subdomains on a dot boundary.

Add focused regression tests for exact hosts, subdomains and nested
subdomains, unrelated suffixes, dotted domain cookies, secure URLs, path
boundaries, and multiple/empty URL filters. Include patch changesets for
the extension and TypeScript/Python SDKs that bundle it. No protocol or
API changes.

## Validation

- Before the production fix: cookie suite had 3 failed / 20 passed; the
failures reproduce host-only cookies matching subdomains.
- After the fix: cookie suite 23 passed.
- Full extension unit suite: 75 files passed; 1,229 tests passed, 9
TODO.
- Extension TypeScript check: `node_modules/.bin/tsc --noEmit -p
packages/extension/tsconfig.json` passed.
- Extension build: `node_modules/.bin/vite build --config
packages/extension/vite.config.ts` passed.
- Targeted oxlint, oxfmt check, changeset validation, and `git diff
--check` passed.

The first broader test run was blocked by sandbox restrictions on local
HTTP listeners and missing build artifacts. After building the extension
and rerunning outside the sandbox, the entire extension suite passed. No
live-browser integration test or full monorepo/Python suite was run.
`pnpm` and `just` were unavailable on PATH, so checks used the installed
workspace executables directly.

<!-- external-contributor-pr:owned source-pr=3465
source-sha=c008c299ceadac61d672538f6f90bf8b9387e095 claimer=shrey150 -->

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes #3464 by correcting cookie domain matching in the extension so
host-only cookies no longer match subdomains they don't apply to.

Previously, `filterCookies` normalized every cookie domain with a
leading dot, causing host-only cookies like `example.com` to be matched
against `sub.example.com`. Now host-only cookies require an exact
hostname match, while dotted domains (`.example.com`) still match
subdomains on a dot boundary.

**Bug Fixes**
- Adds regression tests covering exact hosts, subdomains, nested
subdomains, suffix boundaries, dotted domains, secure URLs, path
boundaries, and multiple/empty URL filters.
- Adds patch changesets for the extension and the TypeScript/Python SDKs
that bundle it.

No protocol or API changes.

<sup>Written for commit c008c29.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3468?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3468?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3468&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Kelvin-Waititu <[email protected]>
@github-actions github-actions Bot added external-contributor:completed The mirrored PR has been merged and the external contributor flow is complete. and removed external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The mirrored PR #3468 has been merged into main. This original external contributor PR will stay closed as completed.

shrey150 added a commit that referenced this pull request Nov 20, 2026
…3496)

Changesets merged through a mirrored external contributor PR currently
show `Thanks @github-actions!` in release notes, because the mirror PR
is authored by the bot.

This wraps `@changesets/changelog-github` in `.changeset/changelog.cjs`.
For each changeset, if its commit came from a merged PR authored by
`github-actions[bot]` that carries the `external-contributor-pr:owned
source-pr=` marker, it adds `pr:`, `commit:` and `author:` overrides
pointing at the original PR and its author (read from the GitHub API,
not from the PR body text). Changesets that already have overrides, and
every non-mirrored PR, are left unchanged.

Checked locally against the three pending mirrored changesets (#3463,
#3422, #3465 now credit their authors) and a regular PR (#3450 is
unchanged).

If a GitHub lookup fails, the wrapper logs a warning and falls back to
the default credit, so it can't block a release PR.

Dry run (Nov 19) against the live repo with
`@changesets/changelog-github` 0.7.0: `empty-response-header-values` now
credits #3422 / @aryansahai22, `host-only-cookie-matching` credits #3465
/ @Kelvin-Waititu, a regular changeset (`eve-1-0-upgrade`, #3409) is
unchanged, and a simulated API failure falls back to the default line.

No tests added: the failure mode is attribution in release notes, not
publishing, and the release PR diff shows the output before anything
ships.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes release notes so changesets merged through mirrored external
contributor PRs credit the original author instead of
`github-actions[bot]`.

- Wraps `@changesets/changelog-github` in `.changeset/changelog.cjs` to
detect mirrored PRs via the `external-contributor-pr:owned` marker and
add `pr:`, `commit:`, and `author:` overrides from the GitHub API.
- Takes the last marker occurrence, since the mirror body quotes the
original PR description before the trusted marker.
- Leaves changesets that already have overrides and non-mirrored PRs
unchanged, and falls back to the default credit when the GitHub lookup
fails so a release can't be blocked.

<sup>Written for commit 72b02d0.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3496?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3496?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3496&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Shrey Pandya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:completed The mirrored PR has been merged and the external contributor flow is complete. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

context.cookies(url) returns host-only cookies for subdomains

2 participants