This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
Backport fix for excessive logging from media type spoof detector #2126
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before the error message was sometimes millions of characters long. > [paperclip] Content Type Spoof: Filename a.csv > (application/octet-stream from Headers, > [#<MIME::Type::Columnar:0x007f9f90f89fa8 > @container=#<MIME::Types:0x007f9f90b09d98 ... snip millions of > characters of output here ...>], @content_type="text/csv", > @raw_media_type="text", @raw_sub_type="csv", @simplified="text/csv", > @i18n_key="text.csv", @media_type="text", @sub_type="csv", > @extensions=["csv"]>] from Extension), content type discovered from > file command: application/zip. See documentation to allow this > combination. Now becomes: > [paperclip] Content Type Spoof: Filename a.csv > (application/octet-stream from Headers, > ["text/comma-separated-values", "text/csv"] from Extension), content > type discovered from file command: application/zip. See documentation > to allow this combination. [fixes #2017]
@@ -12,7 +12,7 @@ def initialize(file, name, content_type) | |||
|
|||
def spoofed? | |||
if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch? | |||
Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.") | |||
Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name.map(&:to_s)} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [289/80]
Thank you! Would you like to squash the commits together? Also, I think the context in the PR description is very relevant, can you add it to the commit messages please? Then I'll merge. Thank you! |
…our to prevent regressions. Excessive logging can fill up disk space and become a denial of service attack, see https://cwe.mitre.org/data/definitions/779.html
Squashed and added info. How does it look @tute ? |
tute
added a commit
that referenced
this pull request
Mar 11, 2016
Backport fix for excessive logging from media type spoof detector
Thank you! |
Great! Is a new version on the way? :) I can do a separate PR to bring the test to the master branch if you'd like. |
Yep, soon!
Please do. Thank you! |
berkes
added a commit
to berkes/spree
that referenced
this pull request
Apr 18, 2016
"It's possible to cause a DoS by uploading files with a spoofed media type, because it causes megabytes of logging to be written." See thoughtbot/paperclip#2017 and thoughtbot/paperclip#2126
berkes
added a commit
to berkes/spree
that referenced
this pull request
Apr 18, 2016
"It's possible to cause a DoS by uploading files with a spoofed media type, because it causes megabytes of logging to be written." See thoughtbot/paperclip#2017 and thoughtbot/paperclip#2126
berkes
added a commit
to berkes/spree
that referenced
this pull request
Apr 18, 2016
"It's possible to cause a DoS by uploading files with a spoofed media type, because it causes megabytes of logging to be written." See thoughtbot/paperclip#2017 and thoughtbot/paperclip#2126
damianlegawiec
pushed a commit
to spree/spree
that referenced
this pull request
Apr 18, 2016
"It's possible to cause a DoS by uploading files with a spoofed media type, because it causes megabytes of logging to be written." See thoughtbot/paperclip#2017 and thoughtbot/paperclip#2126
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 8339e0f (#2017) to 4.3 to prevent excessive logging, which might be abused. Fixes #2125.
Please release 4.3.6 as soon as possible to prevent abuse.