[ Reports & investigation ]

Safe ingestion of compressed DMARC XML files

Separate attachment intake, bounded decompression, safe parsing and transactional import so one hostile report cannot corrupt analytics or exhaust the collector.

By the EmailAuth research team

[ Key points ]

  • Treat report attachments as untrusted at every ingestion layer.
  • Bound expanded bytes during decompression, not after full allocation.
  • Commit only validated, duplicate-handled data and preserve controlled diagnostics.
On this page

A reporting mailbox is an input boundary, not a trusted data source. An attachment can be malformed, oversized or intentionally expensive to process. Build the ingestion path so that transport acceptance does not automatically mean parser acceptance, and parser acceptance does not automatically mean the report's claims are trustworthy.

RFC 9990 describes aggregate XML delivery and warns about resource exhaustion and false information. The pipeline below is an implementation recommendation, not a claim that a particular product already provides these controls.

Isolate intake from analysis

References: RFC 9990 §8.1, RFC 9990 §8.2.

Assign an arrival identifier and preserve a bounded, access-controlled reference to the original attachment. Record its size, fingerprint, arrival time and transport metadata. Apply queue and per-origin resource controls so one stream cannot monopolize workers. Treat a sender address or familiar filename as insufficient evidence of authenticity.

Keep the worker minimally privileged and separate from the database credentials used to publish final metrics. Prevent attachment content from determining executable commands or destination paths. Failed inputs belong in a controlled diagnostic path, not in public error pages or unrestricted logs.

Bound decompression while it runs

References: RFC 9990 §3.5.2, RFC 9990 §8.1.

RFC 9990 specifies XML and recommends GZIP compression. Detect the supported format and reject unsupported containers according to a documented compatibility policy. If older archive formats are deliberately supported, review their additional extraction and path risks instead of treating them as equivalent to a single XML stream.

Set limits for compressed bytes, expanded bytes, elapsed processing time, memory, record count and concurrency. Enforce expanded-size limits while reading, not after allocating the entire output. Size declarations inside a container are not a substitute for measuring actual output. Stop processing when a configured limit is reached.

Parse without unnecessary capabilities

References: RFC 9990 §3.1.1, RFC 9990 §8.1.

Reference: OWASP XML external-entity prevention, General Guidance.

Use a maintained parser with its actual runtime configuration reviewed. Disable unneeded document types, external entity resolution, XInclude and external resource retrieval. Treat unsupported hardening settings as configuration failures, not warnings to ignore. Use trusted local schemas where validation is required rather than following schema locations supplied by an attachment. Apply limits to nesting and text size as well as total bytes.

Validate the expected report structure and field semantics separately from XML well-formedness. A document can be well-formed but unusable as a DMARC report. Preserve the reason for rejection without translating a parser failure into a mail-authentication verdict.

Use a small bounded fixture

Illustrative staging configuration: allow 64 KiB compressed input and 256 KiB expanded output for a deliberately small test worker. A harmless GZIP fixture expands to 300 KiB of repetitive test text. The expected result is an expanded-size stop before complete materialization, no report rows committed and a diagnostic containing the limit and input reference.

These numbers are demonstration limits, not production sizing advice. Test a valid small report immediately afterward to verify that the worker remains usable. Record actual measurements before claiming the control works. This article describes required staging behavior, not an executed tenant test. The review package also records a new bounded Python GZIP demonstration: it detects expansion beyond the 256 KiB cap with at most one extra detection byte, then successfully handles a tiny valid XML-text stream. That demonstrates only this local decompression guard, not parser hardening, memory isolation or database behavior.

Commit only validated data

References: RFC 9990 §3.5.4, RFC 9990 §9.2.

Stage normalized records and complete the import atomically after validation and duplicate handling. An interrupted file should not leave a partial count in production analytics. Make replay idempotent and retain the decision linking repeated arrivals to the counted report.

Monitor rejected bytes, processing time, queue age and recovery outcomes. Legitimate reports can exceed local limits, so provide a controlled review path rather than automatically raising every limit. Close the operational design with named owners for intake, parser maintenance, storage retention and incident response.

[ Takeaway ]

Commit only validated, duplicate-handled data and preserve controlled diagnostics.

[ By role ]

What this means for you

Choose your role for practical next steps.

IT / Mail Admin

Enforce streaming expansion limits.

Validate before committing metrics. Test replay and post-failure recovery.

Next steps

  1. Enforce streaming expansion limits.
  2. Validate before committing metrics.
  3. Test replay and post-failure recovery.

CISO / SecOps

Review worker privileges and egress.

Require measured resource tests. Keep hostile inputs out of unrestricted logs.

Next steps

  1. Review worker privileges and egress.
  2. Require measured resource tests.
  3. Keep hostile inputs out of unrestricted logs.

Founder / Non-technical

Assign ownership for collector reliability.

Keep ingestion outages distinct from mail failures. Fund a controlled oversized-report review path.

Next steps

  1. Assign ownership for collector reliability.
  2. Keep ingestion outages distinct from mail failures.
  3. Fund a controlled oversized-report review path.

[ FAQs ]

Frequently asked questions

Is an attachment trusted because it arrived at rua?

No. Intake must treat report content as untrusted.

RFC 9990 §8.2

What compression does the current aggregate RFC recommend?

GZIP for the XML report; additional legacy containers need an explicit compatibility policy.

RFC 9990 §3.5.2

When should expanded-size checks run?

During decompression, before the full output is allocated or written.

Are compressed-size limits sufficient?

No. Expanded bytes, time, memory and concurrency also need controls.

RFC 9990 §8.1

Should parser schema locations trigger network fetches?

Use trusted local validation resources and prevent attachment-directed retrieval.

Is malformed XML evidence of spoofed mail?

No. It is a processing outcome, not a message-authentication result.

What if a valid report exceeds a local limit?

Quarantine it for controlled review without silently weakening the entire pipeline.

How should a failed import recover?

Commit no partial metrics, retain a safe diagnostic and verify the next valid report processes normally.

[ Sources ]

Sources

  1. RFC 9990

    Sections §3.1 · §3.1.1 · §3.5.2 · §3.5.4 · §8.1 · §8.2 · §9.2

  2. OWASP XML External Entity Prevention

    Sections General Guidance

[ Glossary ]

Glossary

Expanded size
The output bytes produced by decompression, independent of compressed input length.
Atomic commit
A local storage design that exposes all validated import changes together or none of them.
Aggregate report
Grouped receiver observations about DMARC evaluation during a reporting interval.

RFC 9990 §3.1

Enterprise provenance

Why top financial institutions and governments retired their email security dashboards.

Traditional email authentication platforms sell you a dashboard and ask your engineers to do the labour. In high-stakes environments, manual oversight means delayed enforcement, configuration drift and unmonitored shadow domains.

EmailAuth is the agentic email provenance platform. Our agents enforce p=reject, keep third-party senders aligned and move your domains to full RFC 9989 compliance, the new DMARC standard,, with human-in-the-loop auditability.

Governments Large enterprises Tier-1 financial institutions

SaaS · Dedicated tenancy · Air-gapped on-prem · BYOK encryption

Knowledge Base