portswigger-all-labs

Complete PortSwigger Web Security Academy Lab Writeups Detailed, categorized solutions for every lab — from APPRENTICE to EXPERT — covering all 30 vulnerability types.

View on GitHub

Web Application Architecture:

image


1. Path Traversal Vulnerabilities

Path traversal vulnerabilities allow attackers to access arbitrary files on a server by manipulating file paths in user inputs, such as URL parameters.

Exploitation Techniques

Example

https://insecure-website.com/loadImage?filename=../../../etc/passwd

This could allow an attacker to read sensitive files like /etc/passwd.


2. Remote File Inclusion (RFI)

RFI occurs when an application dynamically includes external files based on user input, allowing attackers to include malicious scripts from remote servers.

Exploitation

Key Difference from Path Traversal


3. Parser Logic Flaws and Path Normalization Issues

Orange Tsai’s presentation highlights how inconsistencies in path normalization across web application components (e.g., reverse proxies, Java backends) create vulnerabilities. These issues often lead to path traversal or RCE, especially in multi-layered architectures.

Key Vulnerabilities

  1. Inconsistent Path Parsing:
    • Different components (e.g., Nginx, Apache, Tomcat) interpret paths differently:
      • Windows vs. Linux: file:///etc/passwd?/../../Windows/win.ini may be treated as a URL on Linux but a UNC path on Windows.
      • Proxies may decode %2e%2e%2f before forwarding, while backends fail to re-sanitize.
    • Example: /..;/ is treated as a directory by some proxies (e.g., Nginx, Apache), bypassing ACLs or context mappings.
  2. Nginx Off-by-Slash:
    • Misconfigured alias directive:
      location /static {
          alias /home/app/static/;
      }
      
      • Request: http://127.0.0.1/static../settings.py
      • Result: Nginx appends ../settings.py to /home/app/static/, resolving to /home/app/settings.py.
  3. Java Frameworks:
    • Spring (CVE-2018-1271):
      • Flawed cleanPath function allows traversal with double slashes (/foo//..//foo/).
      • Exploit: http://0:8080/spring-rabbit-stock/static/%255c%255c%255c%255c%255c%255c..%255c..%255c..%255c..%255c..%255c..%255c/Windows/win.ini.
    • Rails (CVE-2018-3760):
      • Sprockets supports file:// scheme, bypassing absolute path checks.
      • Double encoding (%252e%252e) and query string injection (%3F) allow RCE via ERB templates:
        http://127.0.0.1:3000/assets/file:%2f%2f/app/assets/images/%252e%252e/%252e%252e/%252e%252e/etc/passwd
        
        http://127.0.0.1:3000/assets/file:%2f%2f/app/assets/images/%252e%252e/%252e%252e/%252e%252e/tmp/evil.erb%3ftype=text/plain
        
  4. Reverse Proxy Issues:
    • Apache mod_jk, mod_proxy, Nginx ProxyPass:
      • These components often fail to normalize paths consistently with the backend, allowing traversal sequences like /..;/ to bypass restrictions.
      • Example: http://example.com/portal/..;/manager/html accesses the Tomcat management console by exploiting proxy-backend mismatches.
  5. Case Studies:
    • Uber: Bypassed SSO whitelist with /status/..;/secure/Dashboard.jspa.
    • Bynder: RCE via /..;/railo-context/admin/web.cfm and log injection.
    • Amazon: RCE on Nuxeo by chaining path normalization bugs, Seam Framework EL injection, and blacklist bypass.

Why These Architectures Are Vulnerable