AdonisJS static file serving middleware path traversal protection
23.5K reputation · 15 Dec 2023, 19:14 UTC
AdonisJS static file serving middleware maps request URLs to files inside the project’s public directory without automatically checking for path‑traversal sequences. The goal is to prevent accidental exposure of files located outside the intended public folder when the middleware receives requests containing '../' or similar patterns.
Currently the middleware passes the raw path to the file system, leaving protection to developers or external components such as a reverse proxy, and the documentation does not provide a configuration toggle to enable automatic sanitization. This raises the question of whether the framework should incorporate built‑in validation, rely on documented best practices, or offer an opt‑in safe mode. Should AdonisJS add automatic path normalization to its static middleware? Is it sufficient to depend on external safeguards and documentation? What configuration option could developers enable to enforce strict path safety?