Skip to content

fix: block path traversal in /cgi-bin/temp/get (#1304)#1318

Open
echopi wants to merge 3 commits intoavwo:masterfrom
echopi:fix/path-traversal-1304-v2
Open

fix: block path traversal in /cgi-bin/temp/get (#1304)#1318
echopi wants to merge 3 commits intoavwo:masterfrom
echopi:fix/path-traversal-1304-v2

Conversation

@echopi
Copy link
Copy Markdown
Contributor

@echopi echopi commented Apr 6, 2026

Summary

  • Fixes Security Vulnerability:Path traversal #1304 — 未认证时,/cgi-bin/temp/get 可通过 filename=/etc/passwd 等路径读取任意文件
  • 当未配置 username/password 时,仅允许访问合法 temp 文件(64位 hex),其余返回 { forbidden: true }
  • 新增 test/units/temp-get.test.js 测试用例,覆盖路径穿越、空文件名、合法 temp 文件场景

Changes

  • lib/service/service.js: 在 isTempFile 检查后增加 else if 分支,无认证时拒绝非 temp 文件
  • test/units/temp-get.test.js: 4 个测试用例

Test plan

  • 绝对路径 /etc/passwd → 返回 { forbidden: true }
  • 相对路径 ../../etc/passwd → 返回 { forbidden: true }
  • 空文件名 → 返回 { forbidden: true }
  • 合法 64 位 hex 文件名 → 不返回 forbidden

🤖 Generated with Claude Code

echopi and others added 3 commits April 6, 2026 08:47
Node.js v17+ (OpenSSL 3.0) rejects EE certificates with keys smaller
than 2048-bit. The test certs were 1024-bit, causing ERR_SSL_EE_KEY_TOO_SMALL.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port 8081 is commonly used by other services (e.g. AliLang), causing
EADDRINUSE when running tests. Use a high port to reduce conflicts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reject non-temp filenames when no auth is configured, preventing
arbitrary file reads (e.g. /etc/passwd). Add test cases covering
path traversal, empty filename, and valid temp file scenarios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@echopi echopi force-pushed the fix/path-traversal-1304-v2 branch from b402cd7 to 7d085d4 Compare April 6, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security Vulnerability:Path traversal

1 participant