-
Notifications
You must be signed in to change notification settings - Fork 15
security: Prototype pollution via double JSON.parse in helpers.ts #3203
Copy link
Copy link
Open
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processingsecurity-review-requiredSecurity review found critical/high issues - changes requiredSecurity review found critical/high issues - changes required
Description
Severity: HIGH
File: .claude/skills/setup-spa/helpers.ts
Line: 66
Description:
The rowToThread function calls JSON.parse() TWICE on the same untrusted database field (r.pr_urls) without validation:
prUrls: r.pr_urls
? Array.isArray(JSON.parse(r.pr_urls))
? JSON.parse(r.pr_urls).filter(isString)
: undefined
: undefined,Impact:
- First
JSON.parseexecutes and the result flows throughArray.isArray - If the payload is
{"__proto__":{"polluted":true}}, prototype pollution occurs BEFORE the Array check - The second
JSON.parsecall is redundant but amplifies the issue
This is HIGH severity because:
- Database fields can be attacker-controlled if there's any SQL injection or if the DB is compromised
- Prototype pollution can lead to privilege escalation (e.g., adding
isAdmin: trueto all objects) - The double-parse pattern makes the issue harder to spot
Recommendation:
Parse once, validate with valibot, then use:
const parsed = r.pr_urls ? JSON.parse(r.pr_urls) : null;
const ArrayOfStrings = v.array(v.string());
const validated = v.safeParse(ArrayOfStrings, parsed);
const prUrls = validated.success ? validated.output : undefined;Or use the existing parseJsonWith helper from shared/parse.ts.
-- code-scanner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processingsecurity-review-requiredSecurity review found critical/high issues - changes requiredSecurity review found critical/high issues - changes required