Skip to content

πŸ”’οΈ Strictly validate symbol (\flag) arguments#657

Merged
nevans merged 1 commit intomasterfrom
strict-atom-flag-command-arg-validation
Apr 23, 2026
Merged

πŸ”’οΈ Strictly validate symbol (\flag) arguments#657
nevans merged 1 commit intomasterfrom
strict-atom-flag-command-arg-validation

Conversation

@nevans
Copy link
Copy Markdown
Collaborator

@nevans nevans commented Apr 23, 2026

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-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 system 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 most basic input types! So, despite the rationale above, this is still a serious security vulnerability!

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.
@nevans nevans added bug Something isn't working backport-0.5 This ticket needs to be backported to the v0.5-stable branch. backport-0.4 This ticket needs to be backported to the v0.4-stable branch labels Apr 23, 2026
@nevans nevans changed the title πŸ₯… Strictly validate symbol (\flag) arguments πŸ”’οΈ Strictly validate symbol (\flag) arguments Apr 23, 2026
@nevans nevans merged commit 9db3e9d into master Apr 23, 2026
39 checks passed
@nevans nevans deleted the strict-atom-flag-command-arg-validation branch April 23, 2026 13:57
@nevans nevans added the security vulnerability patch Pull requests that address security vulnerabilities label Apr 23, 2026
nevans added a commit that referenced this pull request Apr 23, 2026
πŸ”’ Fix CRLF injection vulnerabilities (backports #657, #658, #659, #660, #636, #661)
nevans added a commit that referenced this pull request Apr 23, 2026
πŸ”’ Fix CRLF injection vulnerabilities (backports #657, #658, #659, #660, #636, #661)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-0.4 This ticket needs to be backported to the v0.4-stable branch backport-0.5 This ticket needs to be backported to the v0.5-stable branch. bug Something isn't working security vulnerability patch Pull requests that address security vulnerabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant