Skip to content

Commit 231ffeb

Browse files
murderteethclaude
andauthored
Fix reflected XSS in /api/vault/meta endpoint (#1129)
Add strict allowlist validation for chainId and address query parameters before they are interpolated into HTML. chainId must be numeric and address must match the 0x-prefixed 40-char hex pattern, otherwise the request is rejected with a 400. This prevents attackers from breaking out of meta tag attribute contexts to inject arbitrary HTML/scripts. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 75ffa73 commit 231ffeb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/vault/meta.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
1313
return res.status(400).json({ error: 'Missing or invalid chainId or address' })
1414
}
1515

16+
// Strict allowlist validation to prevent XSS via parameter injection
17+
if (!/^\d+$/.test(chainId)) {
18+
return res.status(400).json({ error: 'Invalid chainId' })
19+
}
20+
if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {
21+
return res.status(400).json({ error: 'Invalid address' })
22+
}
23+
1624
try {
1725
let html = baseHtml
1826

0 commit comments

Comments
 (0)