Artifact analysis lifecycle
Artifact analysis turns a package file or installed environment into a checked, traceable decision. It covers the bytes, the ways those bytes can start or load code, the link between files and distributions, and the proof that the same approved bytes reached the install target. The lifecycle is centered on Python wheels and is the artifact-focused part of the supply-chain and artifact security model.
Lifecycle model
The lifecycle separates observation from policy. Inspection records files, hashes, coverage, signals, and execution edges; correlation turns those observations into findings; the install path adds quarantine, containment, and post-install checks.
flowchart TD
A[Artifact or requirement request] --> B{Local file or package install?}
B -->|Local file| C[Inspect archive and carried files]
B -->|Package install| D[Resolve exact wheel set]
D --> E[Ingest expected bytes into quarantine]
E --> F[Re-materialize and inspect the wheel set]
C --> G[Correlate signals and execution edges]
F --> G
G --> H{Verdict and coverage complete?}
H -->|No| I[Warn or block; do not trust the incomplete result]
H -->|Yes| J[Contained install from approved bytes]
J --> K[Verify installed RECORD]
K --> L[Record signed, tamper-evident receipt]
The same inspection can be evaluated under more than one policy without reading the artifact again. A coverage gap is not treated as a clean result: ordinary artifact review cannot finalize an incomplete artifact as Allow, and the package firewall requires complete coverage before installation.
Artifact inspection
Archive inspection
Archive inspection establishes whether a package file is safe to reason about before any carried file is treated as trusted input. The reader first applies bounded checks to the ZIP structure, then streams member bytes under resource limits and records the whole-artifact SHA-256 so later stages can refer to exact content.
Wheel files are the supported package archive in this lifecycle. A file is accepted for wheel analysis only when its content has wheel/ZIP magic and its name is a wheel name; source distributions such as .tar.gz and unrelated ZIP files remain explicit Unsupported coverage rather than being reported as clean. Structural faults such as traversal paths, extraction collisions, symlinks, encryption, CRC errors, conflicting metadata roots, malformed archives, or identity disagreement reject the wheel. Resource limits such as an oversized member or a compression-ratio limit instead produce a coverage gap, because the system must distinguish hostile structure from bytes it could not fully inspect.
References: crates/…/inspect.rs• L195-210 crates/…/archive.rs• L405-413 crates/…/archive.rs• L679-709 crates/…/archive.rs• L785-1069
Wheel metadata and RECORD
Wheel metadata gives the inspection its package identity and its expected file map. METADATA, WHEEL, and RECORD connect the filename, distribution name and version, compatibility claims, carried members, and per-member hashes.
The wheel check is strict because a distributed wheel should account for its contents. Every member other than the RECORD and its supported signature files must be listed with a strong, matching hash, and every RECORD path must name a real member. A missing or dishonest entry is evidence that the artifact does not describe its own contents. Installed environments use different rules: their RECORD can be sparse or contain files from other install scheme roots, so missing RECORD data or empty fields are coverage or unverifiable states rather than automatic proof of tampering.
References: crates/…/wheel.rs• L1-25 crates/…/record.rs• L1-37 crates/…/record.rs• L163-236 crates/…/record.rs• L471-601
Startup hooks and PTH handling
Startup-hook analysis identifies code that can run when Python starts, before an application imports its own code. A .pth file has two distinct effects: an unindented import or import\t line executes at interpreter start, while another non-blank line adds a directory to sys.path; .start, sitecustomize.py, and usercustomize.py are analyzed as startup code in their own right.
The analyzer looks for process launches, network activity, dynamic execution, import-path searches, cross-runtime launches, obfuscation, and untrusted path additions. Exact known editable-install and namespace-package templates stay low risk only when the complete line matches a canonical template. The result is a set of signals and execution edges. Correlation requires an executing hook plus a danger capability for the high-severity startup finding, while a hook that launches Bun, Node, or Deno is a critical cross-runtime finding.
References: crates/…/pth.rs• L1-54 crates/…/pth.rs• L62-131 crates/…/pth.rs• L216-249 crates/…/pth.rs• L665-845 crates/…/correlate.rs• L78-183
Native artifact inspection
Native artifact inspection checks whether a compiled module can execute code or hand control to another payload when Python loads it. The supported view covers ELF, Mach-O, universal Mach-O, and PE members, with a bounded read of imports, exports, initialization entries, strings, runtime names, URLs, and sibling payload references.
Native presence alone is not treated as malicious. A critical native execution-chain finding needs all three parts: a load-time execution entry, a dangerous capability such as process spawning or dynamic loading, and corroboration such as a runtime name, sibling payload, sensitive path, or known-malicious indicator. If a native member is too large or malformed for full triage, the inspection records partial coverage instead of claiming that the member is safe.
References: crates/…/archive.rs• L223-255 crates/…/native.rs• L170-250 crates/…/native.rs• L318-451 crates/…/native.rs• L471-584
Artifact-set relationships
Single-file inspection can miss a split in which one distribution provides a loader and another provides the payload. Set inspection closes that gap by inspecting each wheel first, then building a virtual ownership view across the set and resolving the paths named by executing startup lines.
The resulting finding belongs to the loader artifact and names the foreign payload artifact. It requires a startup hook that executes and searches sys.path, a reference that resolves to a payload-shaped member owned by another distribution, and, for the critical cross-runtime case, a foreign runtime launch. The same ownership idea is used after installation so wheel review and installed-environment review describe the same relationship.
References: crates/…/inspect.rs• L27-34 crates/…/inspect.rs• L466-553 crates/…/inspect.rs• L581-627 crates/…/inspect.rs• L651-875 crates/…/record.rs• L30-37
Package firewall
Resolver behavior
The resolver changes a user request into a complete set of exact wheel bytes. It validates requirement and index forms before child tools or network access, creates a fully hash-pinned lock, downloads binary wheels only, and ingests each download under the lock's SHA-256.
The secure default refuses source distributions, VCS references, editable requirements, local paths, direct URLs, and credential-bearing index URLs. The resolver uses approved HTTPS origins through an authenticated loopback broker. The broker permits only exact approved host and port pairs, rejects private or metadata addresses after resolution, checks TLS SNI, and aborts a transfer that exceeds its bound rather than handing a truncated artifact to the next stage. The resolver also isolates package-manager configuration, disables automatic Python downloads, and resolves uv and Python through executable provenance rather than trusting a bare PATH result. The first untrusted PATH hit fails closed instead of falling through to another tool; explicit enrollment can authorize only a sealed static uv image on Linux, while Python and its runtime tree must remain root-managed. The resolver does not inspect content or make a security verdict; those responsibilities belong to the firewall after quarantine.
References: crates/…/resolver.rs• L1-74 crates/…/resolver.rs• L107-173 crates/…/resolver.rs• L289-363 crates/…/resolver.rs• L1141-1224 crates/…/resolver_broker.rs• L94-131 crates/…/resolver_broker.rs• L357-441 crates/…/resolver_broker.rs• L526-543 crates/…/resolver_broker.rs• L747-803
Quarantine storage
Quarantine breaks the direct path from a network download to an install. Each verified artifact is stored as an immutable content-addressed blob, and each install gets a leased transaction containing independent copies under validated wheel names.
The store verifies bytes against the expected digest when it ingests them and publishes them atomically. It keeps the blob and transaction copy separate so a mutation of one path cannot silently change the other. Transaction leases prevent cleanup from removing a live install, while containment checks keep identifiers, filenames, and filesystem operations inside the quarantine root. Garbage collection removes only old transactions or unreferenced blobs.
References: crates/…/quarantine.rs• L1-77 crates/…/quarantine.rs• L142-166 crates/…/quarantine.rs• L209-229 crates/…/quarantine.rs• L404-417 crates/…/quarantine.rs• L647-729
Firewall evaluation
The firewall is the decision point between resolved bytes and installation. It re-materializes every approved blob and re-checks its digest before inspection, then inspects the intact wheels as a set so cross-distribution loader and payload relationships remain visible.
The firewall keeps two hash failures separate. A download-integrity mismatch means the approved bytes can no longer be reproduced, while a known-malicious hash means the verified bytes match threat data. Structural rejection, suspicious startup or native behavior, RECORD problems, known-malicious hashes, and incomplete coverage all remain visible in the final verdict. A rejected wheel or incomplete artifact set cannot become an installable Allow through a policy or presentation downgrade.
References: crates/…/firewall.rs• L1-49 crates/…/firewall.rs• L60-117 crates/…/firewall.rs• L118-165 crates/…/inspect.rs• L493-553 crates/…/mod.rs• L580-670
Contained installation
Installation consumes only the wheel copies that passed the firewall. The plan re-binds the approval to the current threat-database state, re-hashes the quarantine blobs, requires every expected artifact, and creates local hash-pinned requirements for an isolated Python package-manager run.
The enforcing path uses a new dedicated target and a deny-all network capsule. The contained process can read the transaction and the interpreter's required roots, but it can write only the target environment. The target is published only after the private install is verified, and the path identity is checked across that boundary. Unsupported containment platforms fail before package execution; the compatibility --allow-degraded option does not turn this path into an uncontained install.
References: crates/…/install.rs• L312-367 crates/…/install.rs• L343-445 crates/…/install.rs• L448-595 crates/…/pkg_install.rs• L1-41 crates/…/pkg_install.rs• L665-826
Post-install analysis
Post-install analysis checks the environment that the contained package manager produced. It locates exactly one installed distribution for each approved name and version, verifies its installed RECORD entries, and checks duplicate ownership across those distributions.
The check is scoped to the current install rather than the whole pre-existing environment. It treats editable installs and externally managed environments as legitimate sources of sparse or changing RECORD data, while ordinary hash mismatches and duplicate-owned paths remain integrity signals. Missing distributions, stale versions, duplicate matches, missing RECORD files, or zero verified distributions are incomplete proof and block the enforcing install even when the package manager returned success.
References: crates/…/install.rs• L601-650 crates/…/install.rs• L663-692 crates/…/install.rs• L708-845 crates/…/install.rs• L847-891 crates/…/record.rs• L583-760
Provenance and release review
Provenance records
Provenance records preserve why an artifact was considered exact and what environment produced the install decision. An inspection identifies a distributable artifact by ecosystem, name, version, filename, and whole-file SHA-256; an installed distribution keeps its on-disk identity without inventing a source-wheel hash.
The package firewall receipt records the artifact hashes, resolver and package-manager versions, policy projection hash, threat-database sequence, containment backend and coverage, post-install RECORD summary, and final verdict summary. It omits machine paths, registry credentials, secrets, and detailed evidence text. A private verified receipt is created before publication; a second linked signed receipt records that the exact verified target was committed. The pkg graph view composes ownership and execution relationships for review, while the related threat intelligence and registry correlation page covers external reputation and registry signals. The related execution provenance and trust page covers the wider trust record for tools and side effects.
References: crates/…/mod.rs• L149-191 crates/…/mod.rs• L194-232 crates/…/receipt.rs• L247-369 crates/…/receipt.rs• L611-701 crates/…/pkg.rs• L1-20 crates/…/main.rs• L5429-5460
Release diffs
Release differential review compares an old wheel with a new wheel of the same distribution to find changes in execution shape. It is a local review step that uses the normal inspection results and does not contact a registry or download a release.
The diff flags a pure package that gains native code, a package that gains a startup hook, a jump to at least one megabyte of bundled JavaScript, a changed distribution identity, or a newly gained startup or native execution capability. These are heuristics: the default result warns rather than blocks. The new wheel is still inspected on its own, so a conclusive startup or native execution chain keeps its normal block-grade finding. A rejected or incomplete side cannot be used as a trusted baseline, and incomplete comparison coverage blocks the diff verdict.
References: crates/…/release_diff.rs• L1-53 crates/…/release_diff.rs• L68-105 crates/…/release_diff.rs• L134-180 crates/…/release_diff.rs• L282-321 crates/…/release_diff.rs• L313-408 crates/…/main.rs• L5462-5492
Change checklist
When these files or sections are changed, remember to consider these:
- Keep wheel identity checks, PEP 503 name normalization, approved local requirements, and post-install distribution matching aligned. A spelling or version change in one stage can bind approval to a different installed distribution.
- Preserve the distinction between structural rejection, incomplete coverage, and a clean inspection. A caller that drops either rejection state or coverage gaps can allow bytes that were not proven safe.
- Keep resolver hashes, quarantine blob digests, materialized wheel copies, and install requirements bound to the same artifact set. The firewall and the install re-bind must inspect or install only bytes that reproduce the locked digest.
- Keep the resolver's approved origin set aligned with the broker's exact host and port checks. A new index or redirect path must not gain access without the same public-address and TLS-host controls.
- Keep the artifact-set ownership map aligned with installed RECORD ownership. Cross-distribution loader detection depends on resolving the loader's actual reference to the member owned by another distribution.
- Keep receipt fields and publication state tied to the same verified target. A private receipt is not publication proof, and a committed receipt must link to its signed private predecessor.
- Keep release-diff heuristics complementary to direct new-wheel findings. Do not replace block-grade inspection with a warn-only shape comparison.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Wheel member uses traversal, a symlink, an extraction collision, or a conflicting identity | The wheel is structurally rejected even if its outer hash matches the lock | Hardened archive checks and a synthesized structural-rejection finding |
| Archive or native analysis reaches a resource limit | The artifact has incomplete coverage and cannot be treated as clean | Typed coverage gaps; the firewall requires complete coverage before install |
| Quarantine blob is changed, truncated, or removed after resolution | The approved bytes cannot be reproduced and the install is blocked | Digest re-bind during firewall materialization and again before install |
| Resolver traffic targets an unapproved origin, private address, or mismatched TLS host | The broker refuses the connection and the resolve cannot fetch outside the approved boundary | Exact origin authorization, public-address filtering, cached approved addresses, and SNI matching |
| Startup hook launches a process or searches an untrusted path | Python may run code or load a payload at interpreter start | PTH semantics, capability signals, execution edges, and startup correlation |
| Loader references a payload owned by another wheel | A single-wheel review may miss the split | Two-pass artifact-set ownership resolution |
| Installed RECORD is missing, incomplete, mismatched, or paired with the wrong version | The new environment lacks complete integrity proof | Install-scoped post-install RECORD verification and an enforcing completeness floor |
| Resolver input uses a source, VCS, editable, local, direct-URL, or credentialed form | The request may run an uncontrolled build or fetch outside approved origins | Pre-flight requirement and URL validation before resolver children start |
| Receipt signing or publication confirmation fails | The install cannot claim a fully committed, auditable result | Mandatory signed private receipt, linked committed receipt, and retained recovery state |
Key files
| File | Why to read it |
|---|---|
| crates/…/inspect.rs | Main entry point for one wheel and for cross-distribution artifact-set inspection |
| crates/…/archive.rs | Defines the safe boundary between hard archive rejection and incomplete coverage |
| crates/…/pth.rs | Explains Python startup semantics and PTH capability detection |
| crates/…/native.rs | Defines the evidence needed for a native execution chain |
| crates/…/record.rs | Defines strict wheel RECORD checks and lenient installed RECORD checks |
| crates/…/resolver.rs | Defines hash-locked wheel resolution, tool provenance, and resolver input restrictions |
| crates/…/resolver_broker.rs | Defines the narrow network boundary used by resolver child processes |
| crates/…/quarantine.rs | Defines content-addressed storage and per-install transaction boundaries |
| crates/…/firewall.rs | Connects re-materialization, inspection, threat lookup, and the install verdict |
| crates/…/install.rs | Defines re-binding, contained install intent, and post-install verification |
| crates/…/release_diff.rs | Defines local old-versus-new execution-shape review |
| crates/…/receipt.rs | Defines artifact-install receipt content, signing, and publication linkage |
| crates/…/pkg.rs | Shows how approve, install, verify-env, and receipt operations join the lifecycle |
| crates/…/pkg_install.rs | Shows the contained side-effecting install and publication sequence |