{"id":"CVE-2026-129295","kind":"vulnerability","aliases":["CVE-2026-129295","GHSA-r7w7-vpq8-c5vv"],"related":[],"title":"mail-parser is vulnerable to polynomial ReDoS in email header parsing","description":"### Summary\n\nTwo regular expressions used while parsing email headers backtrack\npolynomially on attacker-controlled input. Parsing a single small, well-formed\nemail can consume minutes to hours of CPU, denying service to any process that\nparses untrusted mail.\n\nBoth are reachable from an ordinary `parse_from_string()`, `parse_from_bytes()`\nor `parse_from_file()` call — no special API, option, or malformed structure is\nrequired by the victim.\n\n### Details\n\n**1. Address-header fallback regex (`src/mailparser/utils.py`)**\n\n`get_addresses()` falls back to `_ADDR_FALLBACK_RE` whenever\n`email.utils.getaddresses(strict=True)` yields no usable address. The\nalternative `([^<,]*?)\\s*<([^>]+)>` overlaps a lazy quantifier with an adjacent\n`\\s*` — a space matches both. Driven by `finditer`, which retries at every\noffset and rescans the remainder, matching degrades to **quadratic** on `<`\npadding and **cubic** on whitespace padding.\n\nThe fallback engages on the feature's own happy path, e.g.\n`From: alice@example.com <bob@example.com>`.\n\nMeasured (4.6.0, CPython 3.14, macOS arm64; reproduced identically on Linux and\non CPython 3.9, 3.11, 3.12, 3.13):\n\n| Padding                | Parse time         |\n| ---------------------- | ------------------ |\n| valid address + 750 sp | 0.38 s             |\n| + 1500 sp              | 2.97 s             |\n| + 3000 sp              | 23.4 s (×7.9/2×)   |\n| + 6 KB sp              | 185 s              |\n| ~100 KB sp             | hours              |\n\nFully RFC 5322-compliant folded headers (all lines ≤ 71 octets) trigger the same\nblowup, so the input passes normal MTA and library checks. ~100 KB of headers is\nwithin Postfix's default `header_size_limit = 102400`.\n\nAll six address headers parsed by the library (`From`, `To`, `Cc`, `Bcc`,\n`Reply-To`, `Delivered-To`) are affected and their cost adds up linearly.\n\n**2. Received-header clause splitter (`src/mailparser/const.py`)**\n\n`parse_received()` splits on `_CLAUSE_SPLITTER`,\n`(?:^|\\s+)(from|by|via|with|id|for|envelope-from)\\s+`. Under `re.split` this\nbacktracks **quadratically** over any whitespace run that is not followed by a\nclause keyword. The pre-existing normalization collapsed only `[\\t\\n]`, so\nliteral spaces — including folded-header padding — reached the splitter intact.\n\nMeasured: 24 000 spaces in one `Received:` header → 22 s; ~100 KB → minutes.\n\n### Impact\n\nAvailability. A handful of small emails keeps every parsing worker of a mail\ngateway, ticketing system, quarantine UI, or archiving pipeline permanently\nbusy. No confidentiality or integrity impact.\n\nAnyone who parses email they did not author is affected — which is the library's\npurpose.\n\n### Patches\n\nFixed in **4.6.1**.\n\n- The address fallback is now a linear scan: the header is split into\n  comma-separated items (quote-aware, in Python), then each item is matched\n  against a bounded angle-address `<([^<>\\s]+)>` with the display name derived\n  in Python, falling back to a bare-email match. Each pattern has a single\n  non-nested quantifier over a negated character class → O(n).\n  2000 padding spaces: `3.5 s → <0.01 s`. 256 KB padding: `hours → 0.087 s`.\n  Output is preserved on every previously supported shape.\n- `parse_received()` collapses whitespace runs to a single space before\n  splitting, so the splitter's `\\s+` only ever matches one character → O(n).\n  The date is extracted from the raw header beforehand, so date formatting is\n  unaffected. 24 000 spaces: `22 s → 0.003 s`; 200 000 spaces: `0.004 s`.\n\nRegression tests assert linear-time behaviour for both paths.\n\n### Workarounds\n\nNone within the library. Upgrade to `4.6.1`.\n\nUsers who cannot upgrade immediately should cap total header size before\nparsing and enforce a wall-clock timeout around each parse.","summary":"mail-parser is a Python library for parsing emails, and from 4.2.0 through 4.6.1 crafted address and Received headers make its regular expressions backtrack heavily. An attacker who sends a small, well-formed message can keep parsing workers busy for a long time, which denies service.","severity":"high","cvss":7.5,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"mail-parser","fixed":["4.6.1"],"affected":">= 4.2.0, < 4.6.1","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["cwe-1333","mail-gateway","mail-parser","package","python"],"not_affected_if":["no-untrusted-email-parsing","version-4.6.1-or-later"],"how_to_check":"- Run `pip show mail-parser` and compare the version with `4.6.1`.\n- Search requirements files and lockfiles for `mail-parser` pinned between `4.2.0` and `4.6.1`.","fix":"- mail-parser: move to `4.6.1`","status":"open","published_at":"2026-11-16T18:17:30+00:00","first_seen_at":"2026-11-16T18:38:03+00:00","triaged_at":"2026-11-16T18:39:12+00:00","updated_at":"2026-11-16T22:12:15+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-11-16T18:39:12Z","model":"claude-haiku-5-5","output":{"fix":"- mail-parser: move to `4.6.1`","reach":"internet","title":"mail-parser: crafted email headers cause slow regex backtracking, stalling parsing","impact":"medium","summary":"mail-parser is a Python library for parsing emails, and from 4.2.0 through 4.6.1 crafted address and Received headers make its regular expressions backtrack heavily. An attacker who sends a small, well-formed message can keep parsing workers busy for a long time, which denies service.","audience":"developers","category":"package","nicknames":[],"who_cares":["python","mail-parser","mail-gateway"],"confidence":0.85,"fix_status":"available","needs_auth":"no","worst_case":"parsing workers stall, tying up mail processing for extended periods","analyst_note":"","how_to_check":"- Run `pip show mail-parser` and compare the version with `4.6.1`.\n- Search requirements files and lockfiles for `mail-parser` pinned between `4.2.0` and `4.6.1`.","plain_action":"","product_name":"mail-parser","needs_analyst":false,"not_affected_if":["version-4.6.1-or-later","no-untrusted-email-parsing"],"who_is_affected":"Applications that call mail-parser on untrusted email, such as mail gateways, ticketing, quarantine or archival pipelines, are exposed. Projects that do not parse attacker-supplied mail, or that already run 4.6.1 or later, can skip it.","user_interaction":"no","product_ecosystem":"pypi","needs_special_setup":"no","severity_if_unknown":"unknown"},"cost_usd":0.001168,"input_tokens":4851,"output_tokens":1366,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-129295':15A,23A '-1333':28B '-2026':14A,22A '/2':265C '0.003':589C '0.004':594C '0.01':531C '0.087':537C '0.38':254C '000':401C,585C,592C '1':155C '100':271C,298C,409C '102400':310C '1500':256C '185':269C '2':337C '2.97':258C '200':591C '2000':526C '22':407C,587C '23.4':262C '24':400C,584C '256':533C '3.11':244C '3.12':245C '3.13':246C '3.14':233C '3.5':529C '3.9':243C '3000':260C '4.2.0':49B '4.6.0':231C '4.6.1':51B,460C,613C '5322':277C '6':266C '7.9':264C '71':283C '750':252C 'add':334C 'addr':167C 'address':53B,157C,163C,177C,251C,313C,462C,493C 'address-head':156C 'adjac':187C 'affect':330C,450C 'alice@example.com':228C 'altern':179C 'angl':492C 'angle-address':491C 'anyon':441C 'api':144C 'archiv':432C 'arm64':235C 'around':633C 'assert':598C 'attack':64B,98C 'attacker-control':97C 'author':448C 'avail':413C 'awar':480C 'back':165C,503C 'backtrack':61B,94C,364C 'bare':507C 'bare-email':506C 'bcc':322C 'beforehand':578C 'behaviour':602C 'blowup':288C 'bob@example.com':229C 'bound':490C 'busi':77B,435C 'byte':136C 'c5vv':20A 'call':141C 'cannot':616C 'cap':620C 'cc':321C 'charact':522C,567C 'check':297C 'class':523C 'claus':341C,348C,376C 'clock':631C 'collaps':383C,549C 'comma':475C 'comma-separ':474C 'compliant':278C 'confidenti':437C 'consum':110C 'control':99C 'cost':333C 'cpu':115C 'cpython':232C,242C 'craft':52B 'cubic':212C 'cve':13A,21A 'cwe':27B 'date':571C,580C 'default':306C 'degrad':206C 'deliv':327C 'delivered-to':326C 'deni':83B,116C 'deriv':499C 'detail':154C 'display':497C 'driven':193C 'e.g':226C 'email':10A,46B,92C,108C,418C,444C,508C 'email.utils.getaddresses':171C 'enforc':627C 'engag':218C 'envelop':358C 'envelope-from':357C 'ever':564C 'everi':199C,420C,543C 'exist':381C 'express':60B,88C 'extract':573C 'fall':164C,502C 'fallback':159C,168C,217C,463C 'featur':221C 'file':140C 'findit':195C 'fix':458C 'fold':279C,392C 'folded-head':391C 'follow':373C 'form':71B,107C 'format':581C 'fulli':275C 'gateway':31B,426C 'get':162C 'ghsa':17A 'ghsa-r7w7-vpq8-c5vv':16A 'hand':415C 'happi':224C 'header':11A,56B,93C,158C,280C,301C,307C,314C,340C,393C,406C,470C,577C,622C 'heavili':62B 'hour':113C,274C,536C 'id':355C 'ident':237C 'immedi':618C 'impact':412C,440C 'includ':390C 'input':100C,291C 'intact':398C 'integr':439C 'item':477C,485C 'kb':267C,272C,299C,410C,534C 'keep':74B,419C 'keyword':377C 'lazi':183C 'librari':43B,296C,318C,454C,610C 'limit':309C 'line':282C 'linear':336C,467C,600C 'linear-tim':599C 'linux':239C 'liter':388C 'long':80B 'maco':234C 'mail':2A,25A,30B,33B,38B,124C,425C 'mail-gateway':29B 'mail-pars':1A,32B,37B 'mail-parser':24A 'make':57B 'malform':147C 'match':191C,205C,487C,509C,565C 'measur':230C,399C 'messag':72B 'minut':111C,411C 'mta':294C 'n':386C,525C,569C 'name':498C 'negat':521C 'nest':517C 'non':516C 'non-nest':515C 'none':607C 'normal':293C,382C 'o':524C,568C 'octet':284C 'offset':200C 'one':404C,566C 'option':145C 'ordinari':130C 'output':539C 'overlap':181C 'packag':35B 'pad':210C,215C,247C,394C,527C,535C 'pars':12A,45B,75B,91C,101C,122C,131C,134C,138C,248C,315C,344C,421C,443C,547C,625C,635C 'parser':3A,26A,34B,39B 'pass':292C 'patch':457C 'path':225C,605C 'pattern':511C 'perman':434C 'pipelin':433C 'polynomi':7A,95C 'postfix':304C 'pre':380C 'pre-exist':379C 'preserv':541C 'previous':544C 'process':120C 'purpos':456C 'python':36B,42B,482C,501C 'quadrat':208C,365C 'quantifi':184C,518C 'quarantin':429C 'quot':479C 'quote-awar':478C 'r7w7':18A 'raw':576C 're':169C 're.split':362C 'reach':395C 'reachabl':127C 'receiv':55B,339C,345C,405C,548C 'received-head':338C 'redo':8A 'regex':160C 'regress':596C 'regular':59B,87C 'remaind':204C 'repli':324C 'reply-to':323C 'reproduc':236C 'requir':150C 'rescan':202C 'retri':197C 'rfc':276C 'run':369C,551C 'scan':468C 'send':66B 'separ':476C 'servic':84B,117C 'shape':546C 'singl':103C,514C,554C 'six':312C 'size':308C,623C 'small':68B,104C,417C 'sp':253C,257C,261C,268C,273C 'space':190C,389C,402C,528C,555C,586C,593C 'special':143C 'split':346C,472C,557C 'splitter':342C,349C,397C,560C 'src/mailparser/const.py':343C 'src/mailparser/utils.py':161C 'strict':172C 'string':133C 'structur':148C 'summari':85C 'support':545C 'system':428C 'test':597C 'ticket':427C 'time':81B,249C,601C 'timeout':632C 'total':621C 'trigger':285C 'true':173C 'two':86C 'ui':430C 'unaffect':583C 'untrust':123C 'upgrad':611C,617C 'usabl':176C 'use':89C 'user':614C 'valid':250C 'via':353C 'victim':153C 'vpq8':19A 'vulner':5A 'wall':630C 'wall-clock':629C 'well':70B,106C 'well-form':69B,105C 'whenev':170C 'whitespac':214C,368C,550C 'within':303C,608C 'workaround':606C 'worker':76B,422C 'yield':174C","nicknames":[],"mitigations":[],"who_affected":"Applications that call mail-parser on untrusted email, such as mail gateways, ticketing, quarantine or archival pipelines, are exposed. Projects that do not parse attacker-supplied mail, or that already run 4.6.1 or later, can skip it.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["mailparser"],"ptokens":["mail","parser"],"labels":["cwe1333","high","mailgateway","mailparser","package","pypi","python"],"campaign_type":null,"search_a":"'-129295':15A,23A '-2026':14A,22A 'c5vv':20A 'cve':13A,21A 'email':10A 'ghsa':17A 'ghsa-r7w7-vpq8-c5vv':16A 'header':11A 'mail':2A,25A 'mail-pars':1A 'mail-parser':24A 'pars':12A 'parser':3A,26A 'polynomi':7A 'r7w7':18A 'redo':8A 'vpq8':19A 'vulner':5A","search_b":"'-1333':28B '4.2.0':49B '4.6.1':51B 'address':53B 'attack':64B 'backtrack':61B 'busi':77B 'craft':52B 'cwe':27B 'deni':83B 'email':46B 'express':60B 'form':71B 'gateway':31B 'header':56B 'heavili':62B 'keep':74B 'librari':43B 'long':80B 'mail':30B,33B,38B 'mail-gateway':29B 'mail-pars':32B,37B 'make':57B 'messag':72B 'packag':35B 'pars':45B,75B 'parser':34B,39B 'python':36B,42B 'receiv':55B 'regular':59B 'send':66B 'servic':84B 'small':68B 'time':81B 'well':70B 'well-form':69B 'worker':76B","search_c":"'/2':265C '0.003':589C '0.004':594C '0.01':531C '0.087':537C '0.38':254C '000':401C,585C,592C '1':155C '100':271C,298C,409C '102400':310C '1500':256C '185':269C '2':337C '2.97':258C '200':591C '2000':526C '22':407C,587C '23.4':262C '24':400C,584C '256':533C '3.11':244C '3.12':245C '3.13':246C '3.14':233C '3.5':529C '3.9':243C '3000':260C '4.6.0':231C '4.6.1':460C,613C '5322':277C '6':266C '7.9':264C '71':283C '750':252C 'add':334C 'addr':167C 'address':157C,163C,177C,251C,313C,462C,493C 'address-head':156C 'adjac':187C 'affect':330C,450C 'alice@example.com':228C 'altern':179C 'angl':492C 'angle-address':491C 'anyon':441C 'api':144C 'archiv':432C 'arm64':235C 'around':633C 'assert':598C 'attack':98C 'attacker-control':97C 'author':448C 'avail':413C 'awar':480C 'back':165C,503C 'backtrack':94C,364C 'bare':507C 'bare-email':506C 'bcc':322C 'beforehand':578C 'behaviour':602C 'blowup':288C 'bob@example.com':229C 'bound':490C 'busi':435C 'byte':136C 'call':141C 'cannot':616C 'cap':620C 'cc':321C 'charact':522C,567C 'check':297C 'class':523C 'claus':341C,348C,376C 'clock':631C 'collaps':383C,549C 'comma':475C 'comma-separ':474C 'compliant':278C 'confidenti':437C 'consum':110C 'control':99C 'cost':333C 'cpu':115C 'cpython':232C,242C 'cubic':212C 'date':571C,580C 'default':306C 'degrad':206C 'deliv':327C 'delivered-to':326C 'deni':116C 'deriv':499C 'detail':154C 'display':497C 'driven':193C 'e.g':226C 'email':92C,108C,418C,444C,508C 'email.utils.getaddresses':171C 'enforc':627C 'engag':218C 'envelop':358C 'envelope-from':357C 'ever':564C 'everi':199C,420C,543C 'exist':381C 'express':88C 'extract':573C 'fall':164C,502C 'fallback':159C,168C,217C,463C 'featur':221C 'file':140C 'findit':195C 'fix':458C 'fold':279C,392C 'folded-head':391C 'follow':373C 'form':107C 'format':581C 'fulli':275C 'gateway':426C 'get':162C 'hand':415C 'happi':224C 'header':93C,158C,280C,301C,307C,314C,340C,393C,406C,470C,577C,622C 'hour':113C,274C,536C 'id':355C 'ident':237C 'immedi':618C 'impact':412C,440C 'includ':390C 'input':100C,291C 'intact':398C 'integr':439C 'item':477C,485C 'kb':267C,272C,299C,410C,534C 'keep':419C 'keyword':377C 'lazi':183C 'librari':296C,318C,454C,610C 'limit':309C 'line':282C 'linear':336C,467C,600C 'linear-tim':599C 'linux':239C 'liter':388C 'maco':234C 'mail':124C,425C 'malform':147C 'match':191C,205C,487C,509C,565C 'measur':230C,399C 'minut':111C,411C 'mta':294C 'n':386C,525C,569C 'name':498C 'negat':521C 'nest':517C 'non':516C 'non-nest':515C 'none':607C 'normal':293C,382C 'o':524C,568C 'octet':284C 'offset':200C 'one':404C,566C 'option':145C 'ordinari':130C 'output':539C 'overlap':181C 'pad':210C,215C,247C,394C,527C,535C 'pars':91C,101C,122C,131C,134C,138C,248C,315C,344C,421C,443C,547C,625C,635C 'pass':292C 'patch':457C 'path':225C,605C 'pattern':511C 'perman':434C 'pipelin':433C 'polynomi':95C 'postfix':304C 'pre':380C 'pre-exist':379C 'preserv':541C 'previous':544C 'process':120C 'purpos':456C 'python':482C,501C 'quadrat':208C,365C 'quantifi':184C,518C 'quarantin':429C 'quot':479C 'quote-awar':478C 'raw':576C 're':169C 're.split':362C 'reach':395C 'reachabl':127C 'receiv':339C,345C,405C,548C 'received-head':338C 'regex':160C 'regress':596C 'regular':87C 'remaind':204C 'repli':324C 'reply-to':323C 'reproduc':236C 'requir':150C 'rescan':202C 'retri':197C 'rfc':276C 'run':369C,551C 'scan':468C 'separ':476C 'servic':117C 'shape':546C 'singl':103C,514C,554C 'six':312C 'size':308C,623C 'small':104C,417C 'sp':253C,257C,261C,268C,273C 'space':190C,389C,402C,528C,555C,586C,593C 'special':143C 'split':346C,472C,557C 'splitter':342C,349C,397C,560C 'src/mailparser/const.py':343C 'src/mailparser/utils.py':161C 'strict':172C 'string':133C 'structur':148C 'summari':85C 'support':545C 'system':428C 'test':597C 'ticket':427C 'time':249C,601C 'timeout':632C 'total':621C 'trigger':285C 'true':173C 'two':86C 'ui':430C 'unaffect':583C 'untrust':123C 'upgrad':611C,617C 'usabl':176C 'use':89C 'user':614C 'valid':250C 'via':353C 'victim':153C 'wall':630C 'wall-clock':629C 'well':106C 'well-form':105C 'whenev':170C 'whitespac':214C,368C,550C 'within':303C,608C 'workaround':606C 'worker':422C 'yield':174C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-08-12T07:35:31+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"nvd","external_id":"CVE-2026-129295","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129295","severity":null,"published_at":"2026-11-16T18:17:30+00:00","modified_at":"2026-11-16T18:17:30+00:00","first_seen_at":"2026-11-16T18:38:03+00:00","fetched_at":"2026-11-16T18:38:03+00:00","note":null},{"source":"ghsa","external_id":"GHSA-r7w7-vpq8-c5vv","url":"https://github.com/advisories/GHSA-r7w7-vpq8-c5vv","severity":"high","published_at":"2026-11-16T22:11:08+00:00","modified_at":"2026-11-16T22:11:09+00:00","first_seen_at":"2026-11-16T22:12:15+00:00","fetched_at":"2026-11-16T22:12:15+00:00","note":null}],"documents":[{"id":171746,"url":"https://github.com/SpamScope/mail-parser/commit/037293158cb291caa96635a54449243d32cd4d96","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":171747,"url":"https://github.com/SpamScope/mail-parser/commit/5aab122f0d763991604d2c2bcc807c6bf2489464","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":171748,"url":"https://github.com/SpamScope/mail-parser/commit/85e53f820d78ae7c955dafbbcd0e20989a735c2c","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":171749,"url":"https://github.com/SpamScope/mail-parser/releases/tag/4.6.1","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"},{"id":171750,"url":"https://github.com/SpamScope/mail-parser/security/advisories/GHSA-r7w7-vpq8-c5vv","title":"Vendor advisory: github.com","kind":"vendor","source":"nvd","publisher":"vendor","text":null,"published_at":"2026-08-12T07:35:31+00:00","relation":"advisory","confidence":null,"note":"Vendor advisory: github.com"},{"id":172681,"url":"https://api.github.com/repos/SpamScope/mail-parser/security-advisories/GHSA-r7w7-vpq8-c5vv","title":"Maintainer's advisory: api.github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Maintainer's advisory: api.github.com"},{"id":172683,"url":"https://github.com/SpamScope/mail-parser/pull/166","title":"Patch: github.com","kind":"other","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}