Skip to content

fix(broker-protection): read the captcha profile from the client - #2979

Draft
madblex wants to merge 1 commit into
mainfrom
fix/captcha-solve-reads-native-profile
Draft

madblex wants to merge 1 commit into
mainfrom
fix/captcha-solve-reads-native-profile

Conversation

@madblex

@madblex madblex commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Asana: https://app.asana.com/1/137249556945/task/1217611870578214

This PR:

  • removes the profile we keep in memory between getCaptchaInfo and solveCaptcha, because Apple and Android now send it with the token and the held copy was only standing in for that.
  • keeps the scoped solve and the error when a scoped action arrives without a profile, because solving the first widget on the page removes a stranger's record and leaves our user's in place.

Merge this only after the Apple and Android changes that send the profile reach a release. Until then both clients send the token alone and every scoped solve would fail.

@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Build Branch

Branch pr-releases/fix/captcha-solve-reads-native-profile
Commit 4264d0b20e
Updated September 7, 2026 at 10:58:40 AM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/fix/captcha-solve-reads-native-profile

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/fix/captcha-solve-reads-native-profile")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/fix/captcha-solve-reads-native-profile
git -C submodules/content-scope-scripts checkout origin/pr-releases/fix/captcha-solve-reads-native-profile
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#4264d0b20e0eaafad6f30bb8592513f6fcca68a6

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "4264d0b20e0eaafad6f30bb8592513f6fcca68a6")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/fix/captcha-solve-reads-native-profile
git -C submodules/content-scope-scripts checkout 4264d0b20e0eaafad6f30bb8592513f6fcca68a6

@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Mon, 07 Sep 2026 10:59:07 GMT

Android
    - android/autofillImport.js
  • android/brokerProtection.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Cursor review was not successful.

This PR requires a manual review and approval from a member of one of the following teams:

  • @duckduckgo/content-scope-scripts-owners
  • @duckduckgo/apple-devs
  • @duckduckgo/android-devs
  • @duckduckgo/team-windows-development
  • @duckduckgo/extension-owners
  • @duckduckgo/config-aor
  • @duckduckgo/breakage-aor
  • @duckduckgo/breakage

@madblex
madblex force-pushed the fix/captcha-solve-reads-native-profile branch from 2ba1527 to baf4707 Compare September 6, 2026 11:49

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Web Compatibility Assessment

File Lines Severity Finding
injected/src/features/broker-protection/captcha-services/captcha.service.js 72–178 info Broker-protection captcha logic runs only during native-driven PIR automation, not on arbitrary third-party pages. No browser API overrides, prototype patches, or general DOM timing changes — no general web-compat surface.
injected/src/features/broker-protection/captcha-services/captcha.service.js 137–141 info Profile-scoped solve guard is preserved (action.parent && !userData → error). This prevents solving the first widget on a multi-record page, which would remove a stranger's record — the critical compat/safety invariant from the PR description.
injected/integration-test/broker-protection-tests/broker-protection-captcha.spec.js 161–169 info Replaces the "held profile after page load" scenario with a direct "no profile on solve" test. Aligns with removing module-level state; no web-compat regression.
injected/integration-test/page-objects/broker-protection.js 307–309 info Test helper now returns only response[0] instead of matching by actionID. Test-only; acceptable for sequential flows but would not catch out-of-order multi-action completions.

Security Assessment

File Lines Severity Finding
injected/src/features/broker-protection/captcha-services/captcha.service.js (removed pendingCaptchaContext) info Removing module-level pendingCaptchaContext is a security improvement: eliminates stale profile/token retention across navigations, failed solves, and retries. Client now supplies profile and token explicitly on each solveCaptcha, tightening the trust boundary.
injected/src/features/broker-protection/captcha-services/captcha.service.js 137–138 info Profile scoping error path retained. Prevents captcha token injection into the wrong DOM subtree when multiple user records exist on a broker page.
injected/src/features/broker-protection/captcha-services/captcha.service.js 160–165 warning The explicit no token available to solve the captcha guard was removed. A null/undefined token now flows into injectToken, which coerces to an empty input value and may return success with an empty token instead of a clear error. Low exploitability (native-controlled input), but weaker fail-closed behavior.
(all changed files) — info No changes to messaging transports, nativeData handling, captured globals, message-bridge checks, or postMessage usage.

Risk Level

Low Risk — Broker-protection captcha state-management refactor only; no API shims, messaging, or captured-globals changes; profile scoping guard preserved.

Recommendations

  1. (warning) Consider restoring an explicit if (!token) early return in solveCaptcha for clearer fail-closed behavior and better native-client diagnostics.
  2. (info) Honor the PR's merge gate: ship only after Apple/Android clients send userProfile with every scoped solveCaptcha, or all scoped solves will fail with "no profile available".
  3. (info) Optionally add an integration test for a missing/empty token on solveCaptcha to lock in expected error behavior.
Open in Web View Automation 

Sent by Cursor Automation: Web compat and sec

}

const callback = captchaSolveProvider.getSolveCallback(captchaContainer, captchaToken);
const callback = captchaSolveProvider.getSolveCallback(captchaContainer, token);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Security (warning): The previous if (!captchaToken) return createError('no token available to solve the captcha') guard was removed along with pendingCaptchaContext. A missing token now reaches injectToken / getSolveCallback, which may coerce null to an empty input value rather than failing fast. Consider restoring an explicit token check for clearer, fail-closed behavior.

@github-actions github-actions Bot added semver-minor New feature — triggers minor version bump and removed semver-patch Bug fix / internal — no release needed labels Sep 6, 2026
@madblex
madblex force-pushed the fix/captcha-solve-reads-native-profile branch from baf4707 to daf1ae9 Compare September 7, 2026 10:57
@github-actions github-actions Bot added semver-major Breaking change — triggers major version bump and removed semver-minor New feature — triggers minor version bump labels Sep 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-major Breaking change — triggers major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant