ValueError when null byte in URL #2574
Replies: 3 comments
-
For some more context, this happens when filename contains a null byte (such filenames are invalid). I suppose a fix would be to sanitize filenames or to improve exception handling. I prefer the latter since it will not impact the performance of normal requests. It will also be much simpler in code. |
Beta Was this translation helpful? Give feedback.
-
This seems to be a cpython issue. I created a PR to fix this issue python/cpython#117573 |
Beta Was this translation helpful? Give feedback.
-
That "someone" is trying to exploit a vulnerability in your service. Allowing null bytes in paths can have bad implications, Luckily, that ugly error came to your rescue. I personally think this should be anticipated at the ASGI app (or middleware), e.g. rejecting filenames with null. |
Beta Was this translation helpful? Give feedback.
-
Hello,
today someone tried a bunch of URLs on my online service (using starlette).
On one URL (
/%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD/%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD/%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD/etc/passwd%00
) starlette (specific the StaticFiles Middleware) raised anValueError: embedded null byte
.This is the full StackTrace
I would expect starlette to handle this in someway instead of raising an exception.
Important
Beta Was this translation helpful? Give feedback.
All reactions