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.