Skip to content

Prevent IMAP command injection in UID values and message flags - #208

Merged
stevebauman merged 2 commits into
masterfrom
fix/imap-command-injection
Nov 16, 2026
Merged

stevebauman merged 2 commits into
masterfrom
fix/imap-command-injection

Conversation

@stevebauman

@stevebauman stevebauman commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Caller-supplied UID values and message flags can currently include line breaks that introduce additional IMAP commands. Applications that pass user input into these APIs can allow commands to execute in their authenticated mailbox session.

This validates sequence sets before they are used in queries and validates flags before sending STORE or APPEND commands. Command compilation also rejects control characters in command names, tags, and non-literal tokens before any data is written to the connection. Literal message content continues to support line breaks.

The assertions live in Support\Assert, with hasNoControlCharacters(), isValidFlag(), and isValidSequenceSet() methods. Invalid input throws InvalidArgumentException.

Verified with the full suite against a local GreenMail server. All 1,185 tests pass.

@stevebauman
stevebauman merged commit e052d71 into master Nov 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant