Skip to content

Conversation

@Maeeen
Copy link
Contributor

@Maeeen Maeeen commented Dec 27, 2024

I discovered that there is a path traversal vulnerability with static files. Here is a repository that showcases the issue.

In StaticUtil (StaticEndpoints.scala), the ctx.remainingPathSegments is not properly sanitized and is priorly decoded in Main.scala. Therefore, if a static endpoint has a remaining path segment having / (e.g. if a client sends a static/..%2F/hi.txt), filter will fail to filter the .. and the path static/../hi.txt will be returned to get returned to the client, which should be prohibited.

Before this commit, it is possible to do path traversals with static files. In `StaticUtil` (`StaticEndpoints.scala`), the `ctx.remainingPathSegments` is not properly sanitized and is priorly decoded in `Main.scala`. Therefore, if a static endpoint has a remaining path segment having `/` (e.g. if a client sends a `static/..%2F/hi.txt`), `filter` will fail to filter and the path `static/../hi.txt` will be returned, which should be prohibited.
@lihaoyi
Copy link
Member

lihaoyi commented Dec 27, 2024

The issue looks valid but the fix looks subtle and non-obvious. Could you add a unit test in cask/test/src/test/cask to minimize the problem and validate the fix is working?

@lihaoyi lihaoyi merged commit c776ef9 into com-lihaoyi:master Dec 27, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants