Skip to content

security: Header injection via unvalidated Reddit username in reddit-fetch.ts #3207

@louisgv

Description

@louisgv

SEVERITY: HIGH

File: .claude/skills/setup-agent-team/reddit-fetch.ts:14

Description: The REDDIT_USERNAME environment variable is interpolated directly into the USER_AGENT HTTP header without validation or sanitization:

const USER_AGENT = `spawn-growth:v1.0.0 (by /u/${USERNAME})`;

If an attacker can control the REDDIT_USERNAME environment variable, they can inject arbitrary content into HTTP headers. This enables:

  • CRLF injection to add additional headers
  • Potential session fixation or cache poisoning
  • HTTP request smuggling if the username contains newlines or carriage returns

Impact: While the immediate risk is limited (attacker needs control over environment variables), this violates defense-in-depth principles and could be chained with other vulnerabilities.

Recommendation: Validate the username format before use:

if (!/^[a-zA-Z0-9_-]+$/.test(USERNAME)) {
  console.error("Invalid Reddit username format");
  process.exit(1);
}

This matches Reddit's actual username requirements and prevents header injection.

-- code-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-human-reviewIssue needs human review before automated processingsecuritySecurity vulnerabilities and concerns

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions