-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Airbrake-ruby stuck in an infinite loop #82
Comments
@pouellet It also happened to us with the same payload |
Fixes #82 (Airbrake-ruby stuck in an infinite loop) This is the first step to fix the problem. Firstly, we must identify the bad payload piece, then we will be able to decide what to do next. This PR at least fixes the infinite loop. Apparently we forget to filter something, so we reduce truncator's `max_size` and eventually it becomes `0`. This is a sign things went wrong, so we can return early.
Fixes #82 (Airbrake-ruby stuck in an infinite loop) This is the first step to fix the problem. Firstly, we must identify the bad payload piece, then we will be able to decide what to do next. This PR at least fixes the infinite loop. Apparently we forget to filter something, so we reduce truncator's `max_size` and eventually it becomes `0`. This is a sign things went wrong, so we can return early.
Hey guys! Please accept my apologies. This is a nasty bug. I just submitted a fix to the infinite loop issue: #83. I would be really grateful if you could test it. Please bear in mind that it's based on the recent version of airbrake-ruby (1.3.0), so you would need to upgrade first. This shouldn't cause much troubles, though. Please note that if we can't truncate/convert your payload, then we cannot send it to Airbrake. Thus, next step would be sharing the failing payload with me, so I could take a look at it and fix the library. I am sincerely surprised that this bug has occurred because I've spent a lot of time making sure it works reliably. We also heavily test this (even on different version of Ruby, because they do have differences in this regard). Sorry for the inconvenience again, hope you will be able to help. Thanks! |
Fixes #82 (Airbrake-ruby stuck in an infinite loop) This is the first step to fix the problem. Firstly, we must identify the bad payload piece, then we will be able to decide what to do next. This PR at least fixes the infinite loop. Apparently we forget to filter something, so we reduce truncator's `max_size` and eventually it becomes `0`. This is a sign things went wrong, so we can return early.
Hey Kyrylo, thanks for the quick answer, really appreciated. Unfortunately I can't reproduce the exact payload since it came from an external request and the only data I have to it is what showed up in our log and that I posted in the description. From the log, I think the request was trying to use this Joomla exploit : https://blog.sucuri.net/2015/12/remote-command-execution-vulnerability-in-joomla.html. I will have to wait for a released gem before I can push it to production, but we will update as soon as it's out. I will also put an alert in our log monitoring tool so that I can catch the new log message you introduced and report the exact payload if it happens again. Thanks! |
Fixes #82 (Airbrake-ruby stuck in an infinite loop) This is the first step to fix the problem. Firstly, we must identify the bad payload piece, then we will be able to decide what to do next. This PR at least fixes the infinite loop. Apparently we forget to filter something, so we reduce truncator's `max_size` and eventually it becomes `0`. This is a sign things went wrong, so we can return early.
The new gem with the infinite loop fix was released. Thanks for reporting the bug! |
Airbrake config
Description
I unfortunately could not come up with a reproduction package after a day of trying different inputs, so I hope that your better understanding of the code might solve this one. This happened on our production server and the best I could collect is log.
A malicious agent tried to pass some executable php code in the user_agent header to our Rails app. The request looked like this (as logged by our nginx server, I believe this is truncated):
The Rails server most likely failed to decode the header and raised an exception that airbrake-ruby tried to report. This is where things started going wrong. Here are the airbrake logs that followed:
From there on, airbrake-ruby was stuck in an infinite loop for about an hour, repeating those last three lines, producing 1GB of logs and locking a process. It eventually was killed by linux when the machine ran out of memory.
This piece of code seems to be responsible for the problem:
If the
truncate_payload
somehow stop reducing the size of the payload (which seems to be the case as the log saysAirbrake: dropped 0 frame(s) from Encoding::UndefinedConversionError
), then this method become an infinite loop. Unfortunately, I could not come up with an exact payload that would reproduce the issue.The text was updated successfully, but these errors were encountered: