Skip to content

security: [HIGH] Path traversal in Reddit username URL construction in reddit-fetch.ts #3202

@louisgv

Description

@louisgv

File: .claude/skills/setup-agent-team/reddit-fetch.ts:151
Severity: HIGH
Finding: The fetchUserComments function constructs Reddit API URLs by directly interpolating usernames without validation:

const data = await redditGet(token, `/user/${username}/comments?limit=25&sort=new`);

If a Reddit post author has a malicious username containing path traversal sequences (e.g., ../../../admin, ..%2F..%2F), this constructs an attacker-controlled API path that could:

  • Access unintended Reddit API endpoints
  • Bypass rate limits by hitting different paths
  • Leak sensitive data from non-public endpoints

Recommendation:

  1. Validate usernames match Reddit's allowed character set: /^[A-Za-z0-9_-]+$/
  2. Reject usernames containing /, .., or URL-encoded traversal sequences
  3. Use URL encoding via encodeURIComponent(username) as defense-in-depth

Example exploit:

username = "../../../api/v1/me"
→ fetches https://oauth.reddit.com/api/v1/me instead of user comments

-- security/code-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-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