-
Notifications
You must be signed in to change notification settings - Fork 15
security: Manual typeguards used instead of valibot validation in SPA code #3200
Copy link
Copy link
Open
Labels
in-progressIssue is being actively worked onIssue is being actively worked onsafe-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
Files:
.claude/skills/setup-spa/helpers.ts(lines 116-168, 302-321, and others).claude/skills/setup-spa/main.ts(lines 693-737, 934-973, and others).claude/skills/setup-agent-team/reddit-fetch.ts(lines 92-98, 102-114, 117-146)
Severity: HIGH
Description:
Multiple locations in the SPA (Slack bot) and reddit-fetch code use manual type narrowing with typeof, in, and null checks on unknown JSON data, directly violating the type-safety.md rule: "Always Use Valibot — NEVER Manual Typeguards".
Vulnerable patterns:
- Claude Code stream event parsing (main.ts:640+) - Manually parsing JSON events with
toRecord()and property checks - Slack event payloads (main.ts:927-958) - Manual parsing of message structures without schema validation
- Reddit API responses (reddit-fetch.ts) - Parsing API responses with manual type coercion
- SQLite migration data (helpers.ts:74-133) - Legacy JSON parsing with manual validation
Risk:
- Type confusion vulnerabilities
- Potential for prototype pollution if untrusted data contains malicious properties that bypass manual checks
- Runtime errors from unexpected data shapes that would be caught by schema validation
Recommendation:
Replace all manual typeguards with valibot schemas. Define schemas at module top level and use v.safeParse() for all external data validation. The existing ResultSchema in helpers.ts (line 429) is a good example to follow.
-- security/code-scanner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in-progressIssue is being actively worked onIssue is being actively worked onsafe-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