Mail: Email address spoofing via malformed RFC 2047 encoded-words
Published 2 Sept 2026 · Updated 10 Sept 2026
Is your project on an affected mail?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <2.9.1
- Fixed in
- 2.9.1
bundle update --conservative mail # Gemfile: '>= 2.9.1'Details
Summary
Mail::Utilities.q_value_decode and Mail::Utilities.b_value_decode decoded only the first RFC 2047 encoded-word in a string and used an overly greedy pattern to match the charset token. A crafted, malformed encoded-word embedded in an address display name or local part could cause the decoded output to differ from what a human reviewer or downstream parser would expect, allowing an attacker to spoof the apparent sender/recipient address.
Details
Both decoders used a single String#match against a pattern such as /\=\?(.+)?\?[Qq]\?(.*)\?\=/m. Two problems:
1. Single match, dropped remainder. Only the first =?charset?Q?...?= (or ?B?) word was decoded. Any additional encoded-words or surrounding text were not handled consistently, so the decoded result could silently omit or alter parts of the input. 2. Greedy charset capture. (.+)? is greedy and matches across ? delimiters, so a malformed word could span more of the string than a strict RFC 2047 parse would, changing the boundary between "encoded" and "literal" text.
Impact
Applications using mail to parse and display or authorize based on decoded header values (From, To, Reply-To, etc.) may present or act on an address different from the one a validator inspecting the raw header would see. Primary risk is spoofing / phishing and authorization-check bypass. No RCE.
Is GHSA-mvxr-6m87-mv2q in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected mail, and gives you the command that fixes it.
More advisories for mail
- HighCVE-2012-2140Mail Gem Improper Input Validation vulnerability · 24 Oct 2017
- MediumCVE-2012-2139Mail Gem Path Traversal vulnerability · 24 Oct 2017
- MediumCVE-2011-0739Mail Improper Input Validation vulnerability · 24 Oct 2017
- MediumCVE-2015-9097Mail Gem CRLF Injection vulnerability · 24 Oct 2017
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.