A .docx describes itself twice, and the two descriptions do not have to agree.
The central directory at the end of the ZIP lists every part: name, method, sizes, offset, CRC. Each local header, sitting right before the compressed bytes, repeats most of that. Nothing in the format forces them to match. A reader that trusts one and extracts from the other is reading a file that two different tools will see two different ways.
We hit this while building screenfence, our open-source docx checker. What we landed on: the central directory is the one description of the archive. Wherever the file disagrees with itself we refuse, and the refusal carries a code and the part name instead of a stack trace.
What that means in practice.
Finding the end-of-directory record is a check in itself. We scan back for the signature whose declared comment length matches its own position, so a stray signature inside the content cannot pose as the real one. Before that record, a zip64 locator, a split-archive marker or a zip64 sentinel is a refusal, not a feature we support.
Walking the directory, we refuse an empty part name, an encryption flag, zip64 markers, and any method that is not store or deflate. OPC part names are case-insensitive, so two names that are equal once case-folded are a duplicate part, and the lookup folds case the same way, which means the duplicate check and the lookup cannot disagree about what one part is.
Then each local header gets opened and compared: same name bytes, same method, and the same compressed and uncompressed sizes (unless the data-descriptor flag says the sizes live after the data). Entry data that runs past the start of the central directory is a bad local header.
The one that is easy to miss is overlap. Sort the located entries by header start, and if one entry's data end passes the next entry's header start, refuse. Otherwise a byte can belong to two parts at once, and the document means one thing to a reader that walks the directory and another to a reader that follows offsets.
After extraction, the byte count has to equal the declared uncompressed size and the CRC has to match the recorded one. Two more refusals, not warnings.
None of this is about malformed files from bad encoders. It is about a file that is valid to one reader and different to another, which is the gap anything downstream of the parse will sit in.
If you do format validation, the split we find interesting is whether you treat self-consistency as a precondition for parsing, or as something you check once you already have the data.