All vulnerabilities
CRITICALAppSecexploited in the wild

APPSEC-PATH-TRAVERSAL

Web app · Path Traversal / LFI

Summary

Path traversal (and its include-side variant, Local File Inclusion) occurs when an application builds a filesystem path from user input without canonicalizing and validating it, so sequences like ../ or their URL-encoded forms (%2e%2e%2f) walk out of the intended base directory to read or include arbitrary files such as /etc/passwd or application source. The root cause at the code level is concatenating untrusted input into a path and resolving it before checking that the final canonical path stays within an allowed root. CVE-2021-41773, disclosed 5 October 2021 and rated CVSS 9.8, was a path traversal in Apache HTTP Server 2.4.49 caused by a flawed change to URL path normalization that failed to decode and reject encoded dot-segments; requests mapping outside Alias-configured directories disclosed files, and where mod_cgi was enabled it escalated to remote code execution. It was mass-exploited in the wild within days and the incomplete 2.4.50 fix led to CVE-2021-42013. This class maps to OWASP A01:2021 Broken Access Control.

How to avoid it in your code

  • Canonicalize the resolved path (realpath) and verify it is prefixed by the allowed base directory before opening.
  • Reject input containing path separators, dot-segments, and null bytes after full URL decoding.
  • Map user input to an allow-list of identifiers instead of using it directly as a filename.
  • Serve files via a fixed root with chroot or container isolation and least-privilege file permissions.
  • Keep web servers patched; disable mod_cgi and dynamic include features where not needed.

References

Related vulnerabilities

All AppSec →