Skip to content

security: Manual typeguards used instead of valibot validation in SPA code #3200

@louisgv

Description

@louisgv

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:

  1. Claude Code stream event parsing (main.ts:640+) - Manually parsing JSON events with toRecord() and property checks
  2. Slack event payloads (main.ts:927-958) - Manual parsing of message structures without schema validation
  3. Reddit API responses (reddit-fetch.ts) - Parsing API responses with manual type coercion
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in-progressIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processingsecurity-review-requiredSecurity review found critical/high issues - changes required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions