Strange request skipped all before_dispatch hooks #2257
Replies: 4 comments
-
Hi there. I have not seen that particular issue of a client being able to bypass internal hooks, and do not believe that to be very probable in this case. I would rather think this is an issue of ordering, ie. which hooks are executed and at what time, and what kind of processing goes on there. My advice would be to dive into your code and make sure that you first of all have graceful handling of cases like you mention here where a protected endpoint is called without the user being authenticated / having a valid session. Meaning; get rid of cases such as the one you mentioned where you get a 500 due to a user not being authenticated. Then I would look into mapping which hooks are executed when and check, if there are multiple of them in the same request stage, if any particular ordering is required for them to function correctly. If however you do find that there is a vector where a malicious actor can form a request that does bypass hooks then please do let us know so we can look into it. A working example would be greatly appreciated and help expedite patching. |
Beta Was this translation helpful? Give feedback.
-
Understanding the exact details of the request would be interesting and useful for creating a repeatable test case. Unfortunately, it's too late to turn this on after the bad request occurred, and you generally wouldn't want this running all of the time. Maybe run it in a separate honeypot app for future investigations? Try a
|
Beta Was this translation helpful? Give feedback.
-
There are some requests that don't make it to the code - bad request line, large request body/over sized attachments and read time-outs all stop dispatch, it could be one of those cases... You might get a more detailed picture by:
Then you can can import your nginx logs along side your app-generated logs and find out which requests managed to escape the logging hook and what nginx resolved to do with them. In interesting cases you can go find the full request in the temp dir |
Beta Was this translation helpful? Give feedback.
-
Thanks everyone for the input! As @christopherraa suggested, I had to "dive into my code" — and that helped a lot. It turned out the request shown in the access log was actually a WebSocket request, and I completely missed that at first. What I also didn’t realize is that regular routes are still accessible via WebSocket connections, not just those explicitly defined with The good news is that I tracked it down to some legacy code that wasn’t properly secured — so this helped me catch a real security gap. Appreciate the help — and big respect for Mojolicious, solid and reliable as always. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm seeing something strange in my Mojolicious 8.50 app.
I have two before_dispatch hooks: one for authentication (cookie-based) and one for request logging to MySQL. These are normally triggered for every request. However, I noticed a request from a suspicious client in my NGINX logs:
49.113.95.xxx - - [02/Jun/2025:19:10:22 +0200] "GET / HTTP/1.1" 500 7285 "-" "Go-http-client/1.1"
This request somehow:
So it seems like before_dispatch was never called for this request.
I'm wondering:
Would really appreciate any insights or tips on how to catch or defend against this kind of request.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions