Skip to content

Commit 0ae2aa0

Browse files
[PR aio-libs#12125/f049588a backport][3.13] Block absolute paths in static files (aio-libs#12128)
**This is a backport of PR aio-libs#12125 as merged into master (f049588).** Co-authored-by: Sam Bull <git@sambull.org>
1 parent 7438e8d commit 0ae2aa0

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

aiohttp/web_urldispatcher.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ def __iter__(self) -> Iterator[AbstractRoute]:
676676

677677
async def _handle(self, request: Request) -> StreamResponse:
678678
filename = request.match_info["filename"]
679+
if Path(filename).is_absolute():
680+
# filename is an absolute path e.g. //network/share or D:\path
681+
# which could be a UNC path leading to NTLM credential theft
682+
raise HTTPNotFound()
679683
unresolved_path = self._directory.joinpath(filename)
680684
loop = asyncio.get_running_loop()
681685
return await loop.run_in_executor(

0 commit comments

Comments
 (0)