Anonymous Intelligence Signal

StaticFilesMiddleware Path Traversal Vulnerability: Insufficient Sanitization Exposes Server Files

human The Lab unverified 2026-04-03 13:27:03 Source: GitHub Issues

A critical path traversal vulnerability exists within the `StaticFilesMiddleware` component, exposing server files to unauthorized access. The flaw stems from an insufficient sanitization routine that uses a simple `str_replace('..', '/', ...)` to block directory traversal attempts. This protection is easily bypassed using multiple encoding and pattern techniques, allowing an attacker to potentially read arbitrary files from the server's filesystem.

The vulnerability is located in the `getPublicPathFile()` method within `src/Middleware/StaticFilesMiddleware.php`. The current logic naively replaces double-dot sequences (`..`) with a forward slash (`/`), but fails to account for standard bypass methods. Attackers can exploit this using double URL encoding (`%252e%252e%252f`), patterns like `....//` which become `./` after replacement, or directly using URL-encoded dots (`%2e%2e%2f`). Each method effectively neutralizes the intended security control.

This vulnerability represents a direct threat to application and server security, as it could lead to the exposure of sensitive configuration files, source code, or system data. The issue highlights a common pitfall in custom security implementations where sanitization logic is outpaced by basic encoding tricks. The presence of such a flaw in a core middleware component responsible for serving static files significantly raises the risk profile for any application relying on this code.