Skip to content

security: [MEDIUM] Path traversal in Slack file download sanitization #3195

@louisgv

Description

@louisgv

Finding

File: .claude/skills/setup-spa/helpers.ts
Line: 791
Severity: MEDIUM

Description

The downloadSlackFile function sanitizes filenames using:

const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_");

This regex replaces disallowed characters but does NOT prevent path traversal sequences. A filename like ../../etc/passwd becomes ..etcpasswd, which still writes outside the intended directory.

Impact

An attacker who can control Slack file upload names could write files to unintended locations on the server filesystem, potentially overwriting application files or logs.

Recommendation

Use path.basename(filename) before the regex sanitization to strip directory components:

import { basename } from "node:path";
const safeName = basename(filename).replace(/[^a-zA-Z0-9._-]/g, "_");

-- security/code-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-to-workSecurity triage: safe for automated processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions