Skip to content

chore(goto): better autoconsent setup#712

Merged
Kikobeats merged 4 commits into
masterfrom
next
Apr 6, 2026
Merged

chore(goto): better autoconsent setup#712
Kikobeats merged 4 commits into
masterfrom
next

Conversation

@Kikobeats
Copy link
Copy Markdown
Member

@Kikobeats Kikobeats commented Apr 6, 2026

Based on duckduckgo/autoconsent#1152 feedback


Note

Medium Risk
Touches in-page autoconsent message/eval plumbing by adding nonce validation and timeouts, which could affect cookie-consent handling across sites if misconfigured. Changes are scoped and covered by new unit tests for throw/hang/iframe cases.

Overview
Improves autoconsent integration used by goto’s adblock flow by enabling additional rule modes (enableGeneratedRules, enableHeuristicAction) and hardening the message bridge.

eval requests are now nonce-gated to the top frame (preventing child-frame triggered eval) and time-bounded via p-timeout, returning evalResp with result: false on errors/timeouts instead of hanging. Adds unit tests covering thrown evals, hung evals, and iframe-originated eval rejection.

Reviewed by Cursor Bugbot for commit 79e86fa. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 6, 2026

Coverage Status

coverage: 88.85%. first build
when pulling 79e86fa on next
into 972e3d2 on master.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5702427. Configure here.

Comment thread packages/goto/src/adblock.js
Comment thread packages/goto/src/adblock.js
`page.evaluate(message.code)` can throw (runtime errors, navigation
during evaluation, invalid code) but had no try/catch, so sendMessage
was never called and autoconsent never received the evalResp — stalling
the consent-detection flow.  Fall back to `result: false` on failure,
matching the defensive `.catch(() => {})` pattern already used by
sendMessage.

Made-with: Cursor
page.exposeFunction propagates bindings to every frame, including
cross-origin iframes.  A malicious iframe could call
autoconsentSendMessage({type:'eval', code:'…'}) and page.evaluate
would execute that code in the main frame's context, bypassing the
Same-Origin Policy (same pattern as the DuckDuckGo Android UXSS,
CVSS 8.6).

Generate a per-page random nonce and wrap the binding in the top frame
only (window.self === window.top) so every legitimate message carries
it.  Child frames keep the raw CDP binding which lacks the nonce, so
their messages are silently rejected by the handler.

Made-with: Cursor
@Kikobeats Kikobeats merged commit bf4ecb1 into master Apr 6, 2026
22 checks passed
@Kikobeats Kikobeats deleted the next branch April 6, 2026 11:11
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.

2 participants