Skip to content
docxologyPublic

About

Python toolkit building intelligent document containers — ordinary .docx and .odt files that also carry signed, encrypted payloads through five OOXML/ODF channels: custom XML parts, package parts, metadata properties, image LSB steganography, and MCE AlternateContent. Ed25519 manifests, AES-256-GCM, Merkle binding.

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

docxplus — the Intelligent Document Container

ci.yml workflow status on main License: MIT Requires Python 3.11 or newer

docx+ cover: an intelligent document container over OOXML and ODF extension points. The left panel, OOXML surface (ISO/IEC 29500), lists the structural index, visible narrative, document metadata, consumer compatibility and public document surface. The right panel, intelligence contract (modular payloads), lists the authoritative manifest, sealing lineages, threshold quorums, narrative provenance and recipe claims. A central classical-or-hybrid signed provenance seal joins the two.

Historical archive (v1.0.1) · Current citation metadata: CITATION.cff.

An OOXML .docx or ODF .odt carrying a modular, signed, encrypted intelligence layer through documented package extension points. Structural validation is not a universal Office-application interoperability guarantee.

Latest release · MIT · Python >= 3.11 · CHANGELOG · docs index · CLI reference

docxplus is a standards-first reference implementation. Every channel it uses is grounded in a documented feature of ISO/IEC 29500 (OOXML) or its ODF cousin — custom XML parts, additional package parts, custom document properties, embedded media — layered with a key-family-authenticated signed manifest and AES-256-GCM payload encryption. The media channel bridges to docxology/steganographer so the intelligence can ride inside the least-significant bits of an image the document visibly displays.

Why this is not "just a zip trick"

A .docx is an Open Packaging Conventions (OPC) ZIP. The standards report docs/standards-report.md grounds the extension points. The implementation checks selected package graphs, namespaces and intelligence invariants; it does not implement complete ISO schema validation or prove that every Office application accepts every generated file. Deterministic archive serialization is a project policy, not an OPC conformance requirement.

Channels (modules)

Channel Where the payload lives In-spec basis Good for
custom_xml customXml/itemN.xml mapped content-control data is "flat Open XML markup" (§3.1) structured records
package_part intelligence/payloadN.dxp "a package may contain additional files" (§2.2) bulk / encrypted blobs
metadata docProps/custom.xml property custom document properties (§9) short routing tags
stego_media LSBs of word/media/imageN.png embedded image parts (§2.1) + LSB stego payload hidden in a visible figure
mce <mc:Choice> in word/document.xml MCE AlternateContent (§4.1) payload in an ignorable extension namespace

Every module is described by a manifest (intelligence/manifest.json) — the authoritative list of what the package carries, playing the role ODF assigns to META-INF/manifest.xml.

What the container carries

The primitives scale on five orthogonal axes (see docs/design-rationale.md):

  • Typed payloads — bytes, text, json, project (a selected directory tree packed to a deterministic tar), and docxplus (a nested container). Carrying source does not by itself reproduce its results.
  • Cryptographic depth — password (AES-GCM), multi-recipient (X25519 or genuine X25519 + ML-KEM-768), k-of-n threshold (Shamir with signed full-share digest commitments), and decoy (two bounded password frames sharing a KDF and power-of-two padding policy, not universal deniability).
  • Composition — nest a sealed docxplus inside another (matryoshka).
  • Provenance — a signed Merkle root binds the whole module set, and a profile-separated typed/count/length/hash surface_digest binds the package graph; adding, dropping or swapping a module — or editing a footnote — breaks the signature.
  • Covert depth — dual LSB backends, with a chi-squared heuristic for inspecting selected carriers, not a calibrated presence probability or absence guarantee.

docs/cookbook.md gives buildable document kinds (self-verifying dossier, dead-man's envelope, sealed referee packet, provenance ledger, …). The showcase scripts/04_dossier.py builds and verifies the sealing recipes in one file; the channel and round-trip recipes are covered by their own scripts and tests.

Both containers, one intelligence layer

The .odt profile is not a stub. OdtPlusBuilder / OdtPlusReader carry the same signed manifest, the same four sealing lineages, the same Merkle root and surface digest, and the same co-signature policy as the .docx profile — sharing the sealing and unsealing code rather than reimplementing it, so the two cannot drift apart on the details that matter under attack.

uv run docxplus odt-build report.odt --module brief:brief.json --password s3cret \
    --signing-key key.hex
uv run docxplus odt-validate report.odt        # structural + intelligence checks
uv run docxplus odt-extract report.odt brief --password s3cret

Two OOXML channels have no ODF analogue and do not cross over: custom_xml (no custom XML datastore part) and mce (no Markup Compatibility element). ODT payloads ride as ODF package entries, bounded by archive intake limits, or as odt_metadata user-defined fields in meta.xml for short strings.

Review and recover existing documents

The cross-profile workflows detect container bytes rather than filename extensions:

docxplus audit report.docx packet.odt --expected-key author.pub
docxplus compare previous.docx current.docx --expected-key author.pub
docxplus export packet.odt recovered --slot brief --password s3cret

Audit preserves independent batch findings and separates structural/triage checks from pinned identity. Comparison covers logical package and manifest differences, not plaintext or rendered equivalence. Neither decodes payloads. Bulk export writes exact raw payload bytes and an index into a new private, atomically published no-clobber directory; nested/project payloads remain inert. See the CLI contracts for limits and exits.

Two names, one file

Document building writes the package twice under two names, byte for byte identical:

report.docx / report.odt the surface contract; application/version-specific openability requires its own evidence
report.docxplus / report.odtplus the same bytes, asserting the intelligence contract

An extension is a claim about content. .docxplus asserts an intelligence manifest, not authenticity. docxplus validate checks selected structural and integrity obligations under either name; only caller-pinned verification authenticates it. Writing both names also avoids the missing-handler trap of a lone .docxplus; the ordinary .docx surface name remains available beside it.

Carrying a project, and getting it back

The flagship payload type carries a whole directory tree. What that preserves is a contract, not a hope, and ./run.sh roundtrip measures it on every run: a project is carried into both containers, extracted, and diffed against the original file by file, byte by byte, and mode by mode.

Preserved contents, the executable bit, empty directories, structure, spaced and non-ASCII filenames, zero-byte files
Normalised mtimes, uid/gid, every mode bit but execute — determinism is worth more than that metadata
Refused symlinks. is_file() follows them, so packing one embeds its target: a tree with creds -> ~/.ssh/id_rsa would ship the key. Pass follow_symlinks=True to say so deliberately
Excluded .git, .venv, output, __pycache__, and the rest of the build junk
./run.sh roundtrip      # two suites, run back to back

The first carries a synthetic tree selected to contain awkward cases — an executable entrypoint, an empty directory, a zero-byte file, non-ASCII and spaced filenames — through both profiles, including cross-profile nesting and payload parity. The second carries the selected external template_code_project snapshot through the emitted surface/intelligence names; its inventory comes from its report:

Artefact
output/documents/template_code_project.docx surface name, OOXML
output/documents/template_code_project.docxplus same bytes, intelligence name
output/documents/template_code_project.odt surface name, ODF
output/documents/template_code_project.odtplus same bytes, intelligence name

Each is read back from that name and compared against the captured source. Neither a synthetic fixture nor one external project is a general fidelity proof. Committed output/ artifacts are historical evidence unless a source-bound fresh release receipt identifies the exact inputs and successful run that produced them.

Capture uses retained source descriptors and bounded reads, not a global snapshot: quiesce the tree if cross-file consistency matters. Extraction validates first and publishes a fresh private 0700 root into an absent/empty destination. Platforms without descriptor-relative no-follow directory support refuse safe project I/O.

The harness also covers what a single round trip cannot: the same tree packing to byte-identical payloads in both containers, and a signed .docx nested inside a signed .odt, opened by a dispatcher that reads the container's own magic rather than trusting the caller.

Trust: what a reader can check, and what it costs

Every verification path is available without executing a byte. That is the organising rule, not an optimisation.

  • Signed manifest + co-signatures. verify_provenance(expected_public_key=…) and verify_cosigners([keys]) enforce a signing policy — author AND institution. Authenticity always requires the caller to pin the key they trust: the key inside the manifest is self-asserted, so an unpinned check proves self-consistency only.
  • Reproduction attestation. A project module binds carried bytes to a signed claim about a recipe, toolchain and output digest, not proof of execution. verify_reproduction(slot, expected_public_key=…) authenticates that claim without executing it; without pinning, only self_consistent may be true. reproduce(slot, dest, allow_execution=True) explicitly runs the recipe under available confinement and compares digests. Missing confinement refuses execution. Readable host files remain exposed; use a disposable isolated environment for untrusted code. The living example hashes selected source; it does not rerun the full test/figure/manuscript pipeline or prove scientific reproducibility.
  • Transparency log. Attestations chain into an append-only log with Merkle inclusion proofs. A chain alone proves only self-consistency, so authenticity rests on a signed tree head over (log_size, root_hash); docxplus verify-transparency checks the chain, the head under a pinned signer, and per-entry proofs, and says UNAUTHENTICATED out loud when no head is supplied.
  • Hardened intake. intake.safe_open(bytes, policy) opens untrusted .docx under caps and reports threats — external relationships, macros, altChunk imports — without executing anything. CLI: docxplus scan file.docx [--strict].

Adversarial review

docs/redteam-audit.md records confirmed findings, incomplete earlier mitigations, rejected findings and negative results. Counts generated by src/docxplus/manuscript_vars.py describe that record, not a fresh passing suite or a security proof. Current integration evidence and unavailable release/interoperability proof are distinguished there from historical results.

Quick start

The documentation index separates format and trust references, local checks, and the manuscript. Start with the reader trust discussion if you are evaluating an existing document.

Use the setup and verification guide to install the locked dependencies, inspect a sample, and build the paper. The publication workflow documents the distinct isolated release qualification process.

Security posture

Payloads are encrypted at the payload level (AES-256-GCM, keyed by memory-hard Scrypt by default, with Argon2id available and PBKDF2-HMAC-SHA512 kept for compatibility — the MS-OFFCRYPTO agile lineage), not as whole-package OOXML encryption, so the public surface is not credential-gated. Readers bound declared KDF work and memory, but those bounds are not a total-process resource guarantee. Format 3.0 is an authenticated breaking migration: format-2 manifests and simulated hybrid material are refused; rebuild and re-sign trusted inputs rather than editing a version field. Both profiles support Ed25519 or genuine Ed25519 + ML-DSA-65 manifest/co-signing, and DXE2 classical or DXE3 all-hybrid recipient sealing through cryptography >= 50. Portable typed DXHK private keys distinguish signing from recipient suites and check derived public halves. Mixed recipient families and ambiguous keys refuse; pin the entire composite public identity. Component standards do not certify this product. See docs/security-model.md.

Layout

Every directory carries two guides, and they answer different questions: README.md is for a person deciding what is in there, AGENTS.md is the rules that bind anyone — human or agent — editing it.

Directory What lives there Guides
src/ the import root; holds no modules of its own README · AGENTS
src/docxplus/ domain modules plus channels/; all business logic README · AGENTS
src/docxplus/channels/ the five side-channels behind one Channel protocol README · AGENTS
scripts/ thin pipeline and isolated-release orchestrators README · AGENTS
tests/ the real-data, no-mocks suite behind the 90% gate README · AGENTS
docs/ spec, architecture, security model, cookbook, audit README · AGENTS
docs/manuscript/ the token-driven format write-up README · AGENTS
output/ committed evidence: documents, figures, reports README · AGENTS
data/ deliberately empty — inputs are generated, not stored README · AGENTS
.github/ the CI gates, in the order they fail GITHUB · AGENTS
.agents/ the project-scoped agent skill README · AGENTS

Top-level files: src/docxplus/cli.py (the CLI — see docs/cli.md), run.sh (the pipeline driver, ./run.sh help for the stages), pyproject.toml, CHANGELOG.md, and the citation metadata (CITATION.cff, codemeta.json, .zenodo.json).

The CLI's own surface is not restated here — it drifted once by omitting verify, the authenticity verb, which is the worst possible command to leave out of a summary. docs/cli.md is the contract; update it alongside actual CLI behavior.

Package map

Generated on 2026-11-12 from the import statements under src/docxplus/. An arrow from A to B means code in A imports B; arrows already implied by a longer path are left out, so the picture shows layering rather than every edge. It shows 13 of the package's 30 top-level parts: the largest ones that import or are imported by others.

flowchart TB
    accTitle: Internal dependency map of the docxplus package
    accDescr: Generated from import statements in src/docxplus. Each box is a subpackage or module of the package; an arrow from A to B means code in A imports B; arrows already implied by a longer path are omitted. Most-imported: crypto, opc, payloads.
    n_cli["cli.py"]
    n_channels["channels/"]
    n_crypto["crypto.py"]
    n_container["container.py"]
    n_reproduce["reproduce.py"]
    n_payloads["payloads.py"]
    n_validate["validate.py"]
    n_odt_container["odt_container.py"]
    n_opc["opc.py"]
    n_steg_bridge["steg_bridge.py"]
    n_manifest["manifest.py"]
    n_manuscript_vars["manuscript_vars.py"]
    n_transparency["transparency.py"]
    n_odt_container --> n_container
    n_channels --> n_opc
    n_channels --> n_crypto
    n_reproduce --> n_payloads
    n_cli --> n_validate
    n_cli --> n_transparency
    n_container --> n_manifest
    n_container --> n_odt_container
    n_container --> n_reproduce
    n_reproduce --> n_crypto
    n_validate --> n_odt_container
    n_channels --> n_steg_bridge
    n_manifest --> n_channels
    n_manuscript_vars --> n_container
    n_transparency --> n_crypto
Loading

Documentation

The documentation index links to the CLI, format, security, and manuscript guides.

License

MIT. See LICENSE.

About

Python toolkit building intelligent document containers — ordinary .docx and .odt files that also carry signed, encrypted payloads through five OOXML/ODF channels: custom XML parts, package parts, metadata properties, image LSB steganography, and MCE AlternateContent. Ed25519 manifests, AES-256-GCM, Merkle binding.

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages