ποΈ Strictly validate symbol (\flag) arguments#657
Merged
Conversation
Flags should not allow `atom-specials`. Previously, no validation was done on symbol data. Sending atom or flag args which contain atom specials could lead to various errors. Although this could theoretically include injection attacks, this is not considered to be a critical vulnerability in `net-imap`, for the following reason: Valid "system flag" inputs are restricted to an enumerated set of RFC-defined flag types. User-defined "keyword" flags are sent as atoms, not flags, which use string inputs (strings which can't be sent as an atom will be quoted or sent as a literal). `\Seen` as a flag (symbol argument) is semantically different from `Seen` as a keyword (string argument). So there is no scenario where it is appropriate to call `#to_sym` on unvetted user input. Any code which calls `#to_sym` indiscriminately on user-input is already buggy. Nevertheless, users should reasonably be able to rely on `net-imap` to do very basic input validation on its basic input types.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important
This fixes a CRLF/command/argument injection vulnerability for Symbol arguments.
Flags should not allow
atom-specials.Previously, no validation was done on Symbol arguments. Sending atom or flag args which contain atom specials could lead to various errors.
Although this does create a CRLF/command injection attack vector, this is not considered to be a "critical" vulnerability in
net-imapfor the following reason: Valid "system flag" inputs are restricted to an enumerated set of RFC-defined flag types. User-defined "keyword" flags are sent as atoms, not flags, which use string inputs (strings which can't be sent as an atom will be quoted or sent as a literal).\Seenas a system flag (symbol argument) is semantically different fromSeenas a keyword (string argument). So there is no scenario where it is appropriate to call#to_symon unvetted user input. Any code which calls#to_symindiscriminately on user-input is already buggy.Nevertheless, users should reasonably be able to rely on
net-imapto do very basic input validation on its most basic input types! So, despite the rationale above, this is still a serious security vulnerability!