-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
This commit fixes a potential denial of service vulnerability in logrus.Writer() that could be triggered by logging text longer than 64kb without newlines. #1376
Conversation
…us.Writer() that could be triggered by logging text longer than 64kb without newlines. Previously, the bufio.Scanner used by Writer() would hang indefinitely when reading such text without newlines, causing the application to become unresponsive.
@sirupsen Its not clear to me what is failing in the tests as I don't have any experience with appveyor. Can you take a look and see what the issue is? |
This commit fixes a potential denial of service vulnerability in logrus.Writer() that could be triggered by logging text longer than 64KB without newlines. Previously, the bufio.Scanner used by Writer() would hang indefinitely when reading such text without newlines, causing the application to become unresponsive.
@ozfive I believe the following patch is required for this to pass CI:
Also, I think what @dolmen is trying to say is that your commit message could be a little more concise on the first line and then move the more detailed content to the 'body' section. I've created ozfive#1 to demonstrate the fix as well as a suggested commit message. WDYT? Also, I created #1382 as a Draft, just so CI can run. |
Scan text in 64KB chunks
You are a god among men. I am still learning git so will make it my job to look up patching and try to understand what you did here. |
@sirupsen I believe this is ready for review, when you have time please 🙂 The git commits might need a squash though. |
@sirupsen is it possible to trigger the CI on this? Would love to see it merged. |
@sirupsen Hi, would it be possible to get this change merged? |
Thanks so much for merging @sirupsen 🙇♂️ May we please have a new release to include this fix? 🙏 |
ah yes tagged v1.8.3 |
Thanks for creating a new tag @sirupsen 🙇♂️ The latest tag/release prior to the new v1.8.3 tag was v1.9.0 (which is what we use in our golang projects here at GitLab). Will there also be a v1.9.1 tag and release? |
🤦🏻 v1.9.1 released, I didn't pull down the most recent tags before deciding the new one |
This is no longer splitting at newlines at all so it is chaining the output for users. With this change there is no reason to use the Scanner at all, you could just Read from the reader and write that with printFunc(). Anyway the reason I am here is because the change is broken and causes panics: #1383 |
Updated version of the logrus module to 1.9.2, see also sirupsen/logrus#1376
#623) Updated version of the logrus module to 1.9.2, see also sirupsen/logrus#1376
Fix denial of service vulnerability in logrus.Writer()
The related issue #1370 explains the problem.
This pull request fixes a potential denial of service vulnerability in logrus.Writer() that could be triggered by logging text longer than 64kb without newlines. Previously, the bufio.Scanner used by Writer() would hang indefinitely when reading such text without newlines, causing the application to become unresponsive.
To fix the issue, I've modified the writerScanner() function to split input into chunks of up to 64kb using a custom split function. I've also set the scanner buffer size to the maximum token size using bufio.MaxScanTokeSize.
With these changes, logrus.Writer() now properly handles long, newline-free log messages without causing a denial of service.
Note that the code has also been updated with more comments and that this fix is backwards-compatible. It does not affect existing applications using logrus.Writer()