Skip to content

Reject absolute paths in StaticFiles.lookup_path#3287

Merged
Kludex merged 1 commit into
mainfrom
reject-absolute-paths-staticfiles
May 23, 2026
Merged

Reject absolute paths in StaticFiles.lookup_path#3287
Kludex merged 1 commit into
mainfrom
reject-absolute-paths-staticfiles

Conversation

@Kludex
Copy link
Copy Markdown
Owner

@Kludex Kludex commented May 23, 2026

Summary

StaticFiles.lookup_path() joins the requested path onto the served directory before resolving it. Because an absolute path makes os.path.join discard the directory it is joined onto, an absolute request path bypasses the directory it is supposed to be confined to.

This rejects absolute paths up front (anything starting with / or \), returning a not-found result before any filesystem resolution. Relative paths are unaffected.

Test

Added tests covering POSIX absolute paths and backslash-prefixed paths.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

@Kludex Kludex changed the title Reject absolute paths in StaticFiles.lookup_path Reject absolute paths in StaticFiles.lookup_path May 23, 2026
@Kludex Kludex merged commit fd53168 into main May 23, 2026
11 checks passed
@Kludex Kludex deleted the reject-absolute-paths-staticfiles branch May 23, 2026 16:50
@Kludex Kludex mentioned this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant