跳到正文
cccskills
免费在 GitHub 公开

path-traversal

Detect path traversal and Zip Slip vulnerabilities where user-controlled path components can escape intended directories.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(4)

  • SKILL.md3.7 KB
  • references/false-positive-indicators.md1.4 KB
  • references/poc-skeleton.md2.8 KB
  • references/sinks.md2.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Path Traversal & Zip Slip Detection

When to Use

Audit archive extraction libraries, file upload handlers, static file servers, file path utilities, and any package that writes files based on user-controlled names.

~85% CVE acceptance rate when confirmed.

Key Insight

path.join() does NOT prevent .. traversal in Node.js:

path.join('/uploads', '../../../etc/passwd')
// Returns: '/etc/passwd' -- NOT '/uploads/etc/passwd'

path.resolve() returns an absolute path but also does NOT validate that it stays within a base directory.

Variants

1. Classic Path Traversal

User controls a filename/path parameter that is concatenated with a base directory:

const filePath = path.join(uploadDir, req.params.filename);
fs.readFileSync(filePath); // ../../../etc/passwd

2. Zip Slip

Malicious archive entries contain ../ in their filenames. During extraction, files are written outside the intended directory:

malicious.zip contains:
  ../../../../tmp/pwned.txt

3. Symlink Following

Archive contains a symlink pointing outside the target directory, then a file targeting that symlink. During extraction, the file follows the symlink and writes to an arbitrary location.

4. Backslash Bypass

On Windows or with naive path checks, ..\ bypasses ../ filtering:

filename = "..\\..\\..\\etc\\passwd"

5. URL Encoding Bypass

%2e%2e%2f = ../
%2e%2e/ = ../
..%2f = ../
Double encoding: %252e%252e%252f

6. Null Byte (Legacy)

../../etc/passwd%00.png

Older systems truncate at null byte. Rare in modern runtimes.

Process

Step 1: Find File Operations

# JavaScript/TypeScript
grep -rn "fs\.writeFile\|fs\.createWriteStream\|fs\.rename\|fs\.copyFile" .
grep -rn "fs\.readFile\|fs\.readFileSync\|fs\.createReadStream" .
grep -rn "path\.join\|path\.resolve" .

# Python
grep -rn "open(.*w\|shutil\.copy\|shutil\.move\|os\.rename" .
grep -rn "extractall\|extract(" .

# Go
grep -rn "os\.Create\|os\.OpenFile\|io\.Copy\|filepath\.Join" .
grep -rn "archive/zip\|archive/tar" .

Step 2: Check Archive Extraction

grep -rn "unzip\|extract\|decompress\|gunzip\|untar" .
grep -rn "adm-zip\|yauzl\|unzipper\|archiver\|tar\|fflate\|JSZip\|node-7z" .
grep -rn "zipfile\|tarfile\|py7zr\|patool" .

Step 3: Check Path Validation

grep -rn "startsWith\|indexOf\|includes\|realpath\|normalize" .
grep -rn "\.\." . --include="*.js" | grep -i "reject\|deny\|block\|filter"

Step 4: Verify Validation Effectiveness

Common INCORRECT validations:

  • path.join(base, input) -- does NOT prevent traversal
  • input.indexOf('..') === -1 -- can be bypassed with ....// or encoding
  • input.replace('../', '') -- bypassed with ....// (after removal, ../ remains)

CORRECT validations:

  • path.resolve(base, input) then result.startsWith(base + path.sep) -- verifies result is within base
  • fs.realpathSync() to resolve symlinks before checking

CVSS Guidance

  • Arbitrary file read (unauthenticated): HIGH 7.5
  • Arbitrary file write via Zip Slip: HIGH 7.5-8.1
  • File write + code execution (overwrite config/executable): CRITICAL 9.8
  • Authenticated file read: MEDIUM 6.5

References

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

You are helping a penetration tester exploit misconfigured Active Directory

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

You are helping a penetration tester enumerate an Active Directory domain and

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

You are helping a penetration tester establish persistent access in Active

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

You are helping a penetration tester exploit ADCS through template/CA access

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

You are helping a penetration tester establish persistence through AD CS

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

You are helping a penetration tester exploit misconfigured AD CS certificate

中文简介正在准备中。当前显示原文说明。

ajtazer/heckit22026年10月7日 更新

查看 ajtazer 的全部技能

报告此技能的问题