Skip to content

Provider: reject requests where the header and body site keys differ - #3391

Merged
HughParry merged 4 commits into
mainfrom
sec/provider-sitekey-header-mismatch
Oct 26, 2026
Merged

HughParry merged 4 commits into
mainfrom
sec/provider-sitekey-header-mismatch

Conversation

@goastler

@goastler goastler commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What changed

  • The domain middleware rejects a request (400 SITE_KEY_INVALID) if the body's dapp isn't the same as the prosopo-site-key header.

Why

  • The origin check used the header, but the handlers used the body. From any website you could put your own key (or a test key, which skips the check) in the header and a victim's key in the body.

Effect

  • Challenges can only be requested for the site key whose domain check passed.
  • Every widget package sends the same key in both places, so normal traffic is unaffected.

Tests

  • 5 new cases added to the existing domainMiddleware tests (matching key, another site's key, a non-string key, a victim key behind a test-key header, no body key). The 3 attack cases fail on main; 21/21 pass now.
  • Full provider unit suite passes (the 2 failures are macOS-only: /proc and the Linux native addon).
  • Manual (before the merge with main): attacker origin + victim key in body got a challenge (200) on main, 400 with this change. Normal requests still get 200.

domainMiddleware checks the origin allowlist of the prosopo-site-key
header, but the handlers use the dapp in the body. Reject requests where
the two differ, so a site's allowlist cannot be sidestepped by sending
another key in the header (including a reserved test key).
Keep main's domainMiddleware test harness and add the body/header site-key
cases to it; invalidSiteKeyError now takes only the site key.
@HughParry
HughParry marked this pull request as ready for review October 26, 2026 12:06
@HughParry
HughParry enabled auto-merge (squash) October 26, 2026 12:07
@HughParry
HughParry disabled auto-merge October 26, 2026 13:11
@HughParry
HughParry merged commit 736e988 into main Oct 26, 2026
10 of 19 checks passed
@HughParry
HughParry deleted the sec/provider-sitekey-header-mismatch branch October 26, 2026 13: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.

3 participants