mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-08-31 01:54:53 +00:00
security: fix path traversal in CLI installer file downloads (#1383)
Fixes path traversal vulnerability where unvalidated filenames from
GitHub API could write files outside intended directory.
Attack vector: MITM attack or DNS hijacking could inject filenames
like "../../../../../../tmp/evil.ts" to write arbitrary files.
Fix: Validate filenames before download - block "..", "/", and "\\"
to ensure files are written only within ${dest}/cli/src/
Severity: HIGH/CRITICAL
Affects: All users running installer via curl|bash
Agent: security-auditor
Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
30138f6a8a
commit
d2b6fc1ae4
2 changed files with 11 additions and 1 deletions
|
|
@ -165,6 +165,16 @@ clone_cli() {
|
|||
curl -fsSL "${SPAWN_RAW_BASE}/cli/bun.lock" -o "${dest}/cli/bun.lock"
|
||||
curl -fsSL "${SPAWN_RAW_BASE}/cli/tsconfig.json" -o "${dest}/cli/tsconfig.json"
|
||||
for f in $files; do
|
||||
# SECURITY: Validate filename to prevent path traversal attacks
|
||||
# Block parent directory references (..) and directory separators (/)
|
||||
if [[ "$f" =~ \.\. ]] || [[ "$f" =~ / ]] || [[ "$f" =~ \\ ]]; then
|
||||
log_error "Security: Invalid filename from API (path traversal attempt): $f"
|
||||
log_error "This may indicate a compromised network connection or API response."
|
||||
log_error "Installation aborted for safety."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Filename is safe - proceed with download
|
||||
curl -fsSL "${SPAWN_RAW_BASE}/cli/src/${f}" -o "${dest}/cli/src/${f}"
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openrouter/spawn",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"spawn": "cli.js"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue