security: harden CORS origin validation on faucet and index-supply#694
Open
MoneyBund wants to merge 2 commits into
Open
security: harden CORS origin validation on faucet and index-supply#694MoneyBund wants to merge 2 commits into
MoneyBund wants to merge 2 commits into
Conversation
|
@MoneyBund is attempting to deploy a commit to the Tempo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harden CORS origin validation on the faucet and Index Supply endpoints
Severity: Security — origin allowlist bypass
Both public API routes reflect the caller's
Originback intoAccess-Control-Allow-Originafter a check that can be trivially satisfied byan attacker-controlled domain. That defeats the whole point of the allowlist:
any web page can drive authenticated, state-changing
POSTs to theseendpoints from a victim's browser.
Two bypasses
1.
startsWithprefix match (Index Supply).https://tempo.xyz.attacker.comstarts withhttps://tempo.xyz, so it passesand gets reflected.
2.
includes('vercel.app')substring match (both routes).Preview deployments legitimately live on
*.vercel.app, but a substring testalso green-lights
https://vercel.app.attacker.comandhttps://evil-vercel.app.co.The fix
Replaced the loose checks with an exact allowlist plus a real host match for
preview URLs, extracted into a small
isAllowedOrigin(origin)helper in eachfile:
faucet.tsalreadydid for its base list — the substring branch was the hole);
new URL(origin)parse, thenprotocol === 'https:' && hostname.endsWith('.vercel.app')so only genuine Vercel subdomains match, and a malformed
Originheaderfalls through to "denied".
Each endpoint keeps its own base allowlist unchanged
(
mainnet.docs.tempo.xyzfor Index Supply,docs.tempo.xyzfor the faucet)and the localhost dev entry.
Verification
pnpm check:types— clean.https://tempo.xyz,https://<base>,https://foo.vercel.app, andhttp://localhost:5173(dev only) still allowed.