-
Notifications
You must be signed in to change notification settings - Fork 15
security: [MEDIUM] Path traversal in Slack file download sanitization #3195
Copy link
Copy link
Open
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing