caddy/modules
Will Norris f8a2c60297
caddyhttp: properly sanitize requests for root path (#6360)
SanitizePathJoin protects against directory traversal attacks by
checking for requests whose URL path look like they are trying to
request something other than a local file, and returns the root
directory in those cases.

The method is also careful to ensure that requests which contain a
trailing slash include a trailing slash in the returned value.  However,
for requests that contain only a slash (requests for the root path), the
IsLocal check returns early before the matching trailing slash is
re-added.

This change updates SanitizePathJoin to only perform the
filepath.IsLocal check if the cleaned request URL path is non-empty.

---

This change also updates the existing SanitizePathJoin tests to use
filepath.FromSlash rather than filepath.Join. This makes the expected
value a little easier to read, but also has the advantage of not being
processed by filepath.Clean like filepath.Join is. This means that the
exact expect value will be compared, not the result of first cleaning
it.

Fixes #6352
2024-06-02 03:40:59 +00:00
..
caddyevents events: Add debug log 2024-04-26 18:59:08 -06:00
caddyfs fix a typo (#6333) 2024-05-21 18:41:41 -04:00
caddyhttp caddyhttp: properly sanitize requests for root path (#6360) 2024-06-02 03:40:59 +00:00
caddypki acmeserver: Add sign_with_root for Caddyfile (#6345) 2024-05-27 20:06:54 -04:00
caddytls I'm so tired of typos 2024-06-01 20:43:35 -06:00
filestorage caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
logging logging: support ms duration format and add docs (#6187) 2024-03-21 22:17:09 -04:00
metrics caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
standard filesystem: Globally declared filesystems, fs directive (#5833) 2024-01-13 20:12:43 +00:00