DEV Community

CVE Reports
CVE Reports

Posted on Originally published at cvereports.com

CVE-2026-129299: CVE-2026-129299: Uncaught Exceptions and Silent Header Loss via Reflective Attribute Dispatch in SpamScope…

CVE-2026-129299: Uncaught Exceptions and Silent Header Loss via Reflective Attribute Dispatch in SpamScope mail-parser

Vulnerability ID: CVE-2026-129299
CVSS Score: 6.5
Published: 2026-11-16

CVE-2026-129299 (GHSA-24mq-4vc6-2prf) is a parsing and serialization flaw in SpamScope mail-parser prior to version 4.6.2. The library uses reflective Python attribute resolution (getattr) over untrusted email header names and applies caller convenience transformations (such as underscore-to-hyphen folding and _json/_raw suffix stripping) directly to wire headers. An unauthenticated remote attacker can send crafted emails that trigger uncaught TypeError exceptions during JSON serialization or cause security-relevant headers and body content to be silently dropped without setting defect indicators.

TL;DR

SpamScope mail-parser versions prior to 4.6.2 resolve attacker-controlled email header names via Python's getattr() and apply suffix-stripping transformations during parsing. This allows remote attackers to crash email processing pipelines via uncaught TypeError exceptions or evade downstream security scanners by silently overwriting headers and bypassing initialization on headerless messages.


⚠️ Exploit Status: POC

Technical Details

  • CVE ID: CVE-2026-129299 (GHSA-24mq-4vc6-2prf)
  • Primary CWE: CWE-248 (Uncaught Exception) / CWE-436 (Interpretation Conflict)
  • CVSS v3.1 Score: 6.5 Medium (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L)
  • Attack Vector: Network (Unauthenticated crafted email headers or headerless messages)
  • Affected Versions: SpamScope mail-parser < 4.6.2
  • Patched Version: SpamScope mail-parser 4.6.2
  • Technical Impact: Uncaught TypeError DoS on JSON serialization and silent header/body omission
  • CISA KEV Status: Not Listed

Affected Systems

  • SpamScope mail-parser (Python / PyPI package)
  • mail-parser: < 4.6.2 (Fixed in: 4.6.2)

Code Analysis

Commit: ce3cf35

Decouple wire header extraction from getattr(), introduce build_header_index(), guard __getattr_ against private attributes and 8-bit Header objects, and fix headerless message initialization in parse().

@@ -127,6 +144,10 @@ def __init__(self, message=None):
         Init a new object from a message object structure.
         """
         self._message = message
+        # Set before parse() so that __getattr__ is never reached for this
+        # attribute — it resolves unknown names as headers instead of
+        # raising AttributeError, which would recurse.
+        self._header_index = {}
         if message is not None:
             log.debug("All headers of emails: {}".format(", ".join(message.keys())))
         self.parse()
@@ -296,6 +317,96 @@ def _reset(self):
         self._defects = []
         self._defects_categories = set()
         self._has_defects = False
+        self._mail = {}
+        self._mail_partial = {}
+        self._header_index = self._build_header_index()
+
+    def _build_header_index(self):
+        index = {}
+        if self.message:
+            for name, value in self.message.items():
+                index.setdefault(name.lower(), []).append(value)
+        return index
+
+    def _header_value(self, name):
+        name_header = name.lower()
+        if name_header in ADDRESSES_HEADERS:
+            values = self._header_index.get(name_header)
+            raw_header = values[0] if values else ""
+            parsed_addresses = get_addresses(raw_header)
+            return [
+                (
+                    (
+                        ""
+                        if (decoded_name := decode_header_part(name)) == email_addr
+                        else decoded_name
+                    ),
+                    email_addr,
+                )
+                for name, email_addr in parsed_addresses
+                if email_addr
+            ]
+        return decode_headers(self._header_index.get(name_header))
+
     def _make_mail(self, complete=True):
         for i in keys:
             log.debug(f"Getting header or part {i!r}")
-            value = getattr(self, i)
+            if i in _RESERVED_MAIL_KEYS:
+                continue
+            value = getattr(self, i) if i in COMPUTED_PARTS else self._header_value(i)
+            if value:
+                mail[i] = value
@@ -362,11 +481,18 @@ def parse(self):
-        if not self.message:
+        self._reset()
+        if self.message is None:
             return self
-        self._reset()
@@ -619,50 +846,39 @@ def __getattr__(self, name):
-        name = name.strip("_").lower()
-        name_header = name.replace("_", "-")
-        if name.endswith("_json"):
-            name = name[:-5]
-            return json.dumps(getattr(self, name), ensure_ascii=False)
-        elif name.endswith("_raw"):
-            name = name[:-4]
-            raw = self.message.get_all(name) if self.message else None
-            return json.dumps(raw, ensure_ascii=False)
+        if name.startswith("_"):
+            raise AttributeError(
+                f"{type(self).__name__!r} object has no attribute {name!r}"
+            )
+        name = name.rstrip("_").lower()
+        if name.endswith("_json"):
+            return json.dumps(getattr(self, name[:-5]), ensure_ascii=False)
+        if name.endswith("_raw"):
+            raw = self._header_index.get(name[:-4].replace("_", "-")) or []
+            return json.dumps([ported_string(i) for i in raw], ensure_ascii=False)
+        return self._header_value(name.replace("_", "-"))
Enter fullscreen mode Exit fullscreen mode

Mitigation Strategies

  • Upgrade SpamScope mail-parser to version 4.6.2 or later to decouple wire header lookups from Python attribute resolution.
  • Wrap mail_json, mail_partial_json, and attribute access calls in explicit TypeError and RecursionError exception handlers to prevent worker crashes.
  • Inspect raw email messages at the ingestion boundary for header names ending in _json or _raw or matching MailParser method names (Parse, Message, Write_Attachments, From_File).
  • Explicitly check whether parser.message has zero headers (len(parser.message) == 0) before trusting empty parser.body outputs on unpatched versions.

Remediation Steps:

  1. Update project dependency specifications (requirements.txt, pyproject.toml, or Pipfile) to require mail-parser>=4.6.2.
  2. Run 'pip install --upgrade mail-parser>=4.6.2' in all affected virtual environments and container images.
  3. Verify the installed version by running 'python -c "import mailparser; print(mailparser.version)"' and confirming it outputs 4.6.2 or higher.
  4. Restart all email ingestion workers, celery queues, and background parsing services to load the patched library.

References


Read the full report for CVE-2026-129299 on our website for more details including interactive diagrams and full exploit analysis.

Top comments (0)