Introducing a new way to review your PRs.

Read the announcement

sheeki03 / tirith

Terminal security for developers and AI agents. Intercepts homograph URLs, pipe-to-shell, ANSI injection, obfuscated payloads, data exfiltration, and malicious AI skills/configs before they execute.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / supply-chain-and-artifact-security

Supply-chain and artifact security

Tirith reduces supply-chain risk before software is installed or run. It connects package-name checks, registry and repository evidence, install-script review, artifact inspection, and download provenance into findings and verdicts that can warn or block the next action.

Security boundary

The supply-chain boundary covers both the source of software and the bytes that reach an environment. Tirith treats a package name, a repository URL, a registry response, an install hook, and a downloaded file as related evidence rather than as separate trust decisions.

Package and repository sources

Package and repository checks ask whether the requested source is a plausible and reviewable origin. The command rules identify package installs from non-standard URLs, Docker images from non-standard registries, Git repository lookalikes, and infrastructure sources such as untrusted Helm or Terraform locations. Registry-backed package checks compare a package's claimed source repository with the package identity in that repository when online evidence is available.

These checks do not treat a familiar host name as proof of a safe publisher. A registry response must identify the requested package, and version-bound evidence must describe the release that the package manager will receive. An unknown, unreachable, or mismatched source remains an uncertainty that the workflow reports instead of silently treating as trusted.

References: crates/…/ecosystem.rs• L8-20 crates/…/ecosystem.rs• L22-107 crates/…/repo_mismatch.rs• L29-149 crates/…/registry_api.rs• L225-301 crates/…/install.rs• L1421-1521

Dependency declarations

ecosystem scan examines the dependency declarations that define a project's supply chain. It finds supported manifests and lockfiles, extracts direct and transitive package identities, and sends each declared dependency through the same package-risk model used by package risk. The scan produces normal Tirith findings, so its result can be explained, recorded, allowlisted, or used as a CI gate.

The scan keeps an incomplete result visible. Unsupported direct sources, malformed manifests, unreadable files, and bounded walks become coverage findings because an omitted dependency cannot support a clean conclusion. Online registry enrichment is optional; the default scan uses local data and does not make registry calls.

References: crates/…/ecosystem_scan.rs• L1-16 crates/…/ecosystem_scan.rs• L124-170 crates/…/ecosystem_scan.rs• L191-260 crates/…/ecosystem.rs• L39-55

Package risk signals

Tirith uses two complementary views of a package. package risk is an advisory score that explains why a package looks risky. The ecosystem scan and install paths turn selected signals into policy-aware findings and verdicts.

Name and reputation signals

The local signed threat database supplies package reputation without a network call on the normal check path. Tirith compares a name with known popular packages and known malicious typosquats. A close spelling match is a strong warning shape, while an unknown name is only a small baseline and is not itself proof of malware.

When the operator passes --online, Tirith may add registry provenance from npm, PyPI, or crates.io. It can use package age, release timing, ownership changes, download volume, repository presence and consistency, yanked or deprecated status, dependency-confusion evidence, and exact-version OSV advisories. The score is a fixed, explainable sum. A registry failure is reported as unavailable and does not become a false clean result. Registry identity and exact-version checks prevent evidence for another package or release from being used for the requested one.

For npm, the result can also show published integrity, signature, attestation, and registry-bound tarball facts. These are provenance facts from the registry record. Tirith does not download or verify the tarball on this path, so these facts do not prove the local bytes.

References: crates/…/package_risk.rs• L1-25 crates/…/package_risk.rs• L60-103 crates/…/package_risk.rs• L359-457 crates/…/registry_api.rs• L43-118 crates/…/registry_api.rs• L225-301 crates/…/registry_api.rs• L849-959 crates/…/osv_correlation.rs• L21-33

Package content signals

When package content already exists on disk, Tirith reviews the parts that can run code during installation. It looks for package lifecycle hooks, Python setup behavior, and bundled native or compiled content. It reads script text as evidence and never runs the script as part of the review.

The content check is deliberately separate from the name score. A package can have a normal name and still carry a risky install hook or opaque native code. If content is not present locally, Tirith says that it was not inspected rather than downloading the package just to score it.

References: crates/…/package_risk.rs• L147-178 crates/…/package_risk.rs• L297-317 crates/…/package.rs• L650-830 crates/…/install_script_analysis.rs• L1-16

Dependency confusion

Dependency confusion means a public package can take the place of a package that an organization intended to resolve privately. Tirith checks operator-declared internal package patterns and conservative npm scope patterns before a public-registry resolution is trusted.

The check follows the naming rules of the candidate ecosystem. This matters because alternate spellings can refer to the same project in one registry but not in another. A positive match adds a package finding and gives the operator a reason tied to the internal name or scope.

References: crates/…/dep_confusion.rs• L1-15 crates/…/dep_confusion.rs• L21-71 crates/…/dep_confusion.rs• L74-113

Install and artifact controls

Tirith has a review path for ordinary install commands and a stricter firewall for controlled Python package installs. Both aim to stop unreviewed or changed bytes from reaching an execution environment.

Install command checks

Command analysis watches for actions that weaken package authenticity or apply remote content without review. Examples include adding an APT source from a download, disabling repository signature checks, applying a remote Kubernetes manifest, pulling a chart from an untrusted repository, or using a remote Terraform module.

The package-install planner applies the same boundary to package-manager transactions. It preserves the exact install inputs, checks whether each executable input is understood, and binds online evidence only when the source and version can be matched. Manifest installs, local paths, direct or VCS sources, non-official registries, unknown options, missing values, and unavailable provenance become explicit coverage gaps. An incomplete plan cannot silently look fully reviewed; strict fail_mode: closed blocks it.

These checks act before the command runs. They focus on the trust change created by the command: a source is being added, a signature check is being disabled, or remote content is being turned directly into an install or deployment input.

References: crates/…/install_txn.rs• L196-346 crates/…/install_txn.rs• L368-546 crates/…/install_txn.rs• L864-933 crates/…/install_txn.rs• L1984-2159 crates/…/install.rs• L687-804 crates/…/install.rs• L889-1087 crates/…/install.rs• L1288-1396 crates/…/install.rs• L1421-1521

Artifact inspection

An artifact is a distributable file such as a Python wheel, or a file already installed into an environment. Artifact inspection asks what the file contains, what can execute, whether its recorded contents match its bytes, and whether the inspection covered the full subject.

The artifact model keeps observations separate from policy decisions. It can record startup hooks, native execution paths, integrity mismatches, execution relationships between a loader and a payload, and known-malicious hashes. The same observations can then be evaluated under different policies. The command surface supports one artifact, a wheel set for cross-package relationships, or an installed environment.

For the current wheel inspection path, a structurally hostile archive is rejected. A large or unsupported member is instead a coverage gap. Both cases remain visible to verdict consumers, and install enforcement does not allow an incomplete artifact review to look clean. The policy evaluator can warn for incomplete coverage under a permissive policy or block it when the policy requires complete analysis.

See Artifact analysis lifecycle for the artifact flow from archive reading through inspection, quarantine, install, and post-install checks.

References: crates/…/mod.rs• L1-5 crates/…/mod.rs• L14-41 crates/…/mod.rs• L149-259 crates/…/mod.rs• L504-643 crates/…/package.rs• L93-303 crates/…/archive.rs• L1-33 crates/…/inspect.rs• L1-35

Hash and install firewall

The package firewall separates resolution, inspection, and installation. It resolves a Python requirement set to hash-pinned wheels, places those bytes in a quarantine, inspects the complete set, and allows installation only from the inspected bytes.

The firewall checks each artifact again at the install edge. If a quarantined blob is missing or no longer matches its approved digest, Tirith treats that as an integrity failure. A known-malicious hash is a different finding: it means the bytes are confirmed bad, while an integrity mismatch means the approved bytes can no longer be proven to be the bytes being installed.

After a clean pre-install verdict, the install plan uses only local, hash-pinned wheel references. The contained install has no network access and runs only when the host can provide the required capsule controls; unsupported platforms fail closed before pip starts. It writes the approved requirements inside the transaction boundary, installs into a private target, and publishes that target only after verification. A post-install check compares the installed files with their package records so a successful process does not hide changed output. The result and its coverage are recorded for later review.

References: crates/…/resolver.rs• L1-19 crates/…/quarantine.rs• L1-8 crates/…/firewall.rs• L1-49 crates/…/install.rs• L1-73 crates/…/pkg_install.rs• L1-40 crates/…/pkg_install.rs• L1471-1721 crates/…/pkg_install.rs• L1824-1877

Download provenance

Downloads that are kept for later use carry provenance into later command checks. A file saved from a risky download is marked as tainted, which means Tirith can warn when a later command executes or sources that file instead of treating the later command as unrelated.

This link is path based and persists until the operator clears it. It gives Tirith a memory of the source-to-execution chain without claiming that every downloaded file is malware.

References: crates/…/taint.rs• L1-22 crates/…/taint.rs• L31-49 crates/…/taint.rs• L244-330 crates/…/verdict.rs• L625-640

Decision flow

The supply-chain decision combines local source checks, optional online evidence, artifact content, install coverage, and the final action boundary. This diagram shows the broad path from a package or repository request to an allow, warn, or block result.

flowchart TD
    A[Package, repository, install command, or downloaded file] --> B{Source and name checks}
    B --> C[Local threat data and package signals]
    B --> D[Optional registry and repository evidence]
    A --> E{Content or artifact available locally?}
    E -->|No| F[Report content not inspected]
    E -->|Yes| G[Review hooks, records, native code, archive shape, and hashes]
    A --> H{Install inputs fully understood?}
    H -->|No| I[Record coverage gap]
    H -->|Yes| J[Bind package and version evidence]
    C --> K[Correlate supply-chain evidence]
    D --> K
    F --> K
    G --> K
    I --> K
    J --> K
    K --> L[Apply policy and coverage rules]
    L --> M[Allow]
    L --> N[Warn]
    L --> O[Block before install or execution]

The important boundary is the last one. A risk score helps explain evidence, but a verdict controls whether the guarded operation proceeds. Confirmed malicious hashes, hostile archive structure, suspicious startup execution, changed approved bytes, and strict coverage failures are block-grade controls; heuristic release changes and weaker provenance signals can remain warnings unless policy upgrades them.

References: crates/…/correlate.rs• L40-75 crates/…/mod.rs• L613-735 crates/…/install_txn.rs• L648-710 crates/…/verdict.rs• L828-885

The supply-chain page provides the system view. Use the child pages for the two deeper paths:

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to package identity or version parsing must stay aligned across manifest scans, registry identity checks, exact-version advisories, allowlists, and approved install references.
  • Changes to artifact hash or coverage handling must preserve the distinction between a known-malicious hash, an approved-byte mismatch, a hostile archive, and an incomplete inspection.
  • Changes to registry repository fields, redirect rules, or npm distribution facts must keep registry evidence tied to the validated origin, package identity, selected version, and the stated bytes-not-bound caveat.
  • Changes to install-source rules or manager support must preserve the boundary between a local reviewed input, a validated official registry, and a remote or signature-disabled input. New manager adapters must also update the coverage state rather than silently becoming unverified.
  • Changes to contained-install target binding, capsule coverage, or post-install record checks must preserve the sequence from private install to verified publication and receipt.
  • Changes to taint creation or path normalization must preserve the later execute/source checks, including their fail-safe behavior when taint state is incomplete.

Important failure modes

TriggerConsequenceGuard
A package name is a close match to a popular name or is a known malicious typosquatThe package receives a strong reputation finding before installLocal threat data compares package identity and keeps confirmed typosquats distinct from weak similarity
A registry response names a different package, a requested exact version is absent, or a registry redirect changes originRegistry evidence is not reused for the requested package or releaseRegistry metadata binds package identity and selected version, and registry requests stay on the validated origin
A wheel has traversal, duplicate, encrypted, symlink, CRC, or identity violationsThe artifact is rejected and the install path blocksThe archive boundary separates structural rejection from ordinary coverage limits
A quarantined blob changes or disappears after approvalThe install is blocked as an integrity mismatchThe firewall re-hashes the content-addressed blob immediately before inspection and install
An artifact member, manifest, or install operand is not fully inspectedA clean result is not allowed to hide the missing coverageCoverage gaps become findings and enforcing install paths require complete coverage
The contained-install host cannot provide the required capsule or target bindingPip does not start and the operation fails closedThe enforcing launcher has no uncontained fallback and rejects unsupported coverage before execution
A downloaded file is later executed or sourcedThe later command receives a tainted-file findingDownload provenance persists until an explicit clear action

Key files

FileWhy to read it
crates/…/ecosystem_scan.rsDefines the project-level dependency scan and its coverage model.
crates/…/package.rsShows the user-facing package risk, dependency scan, and artifact inspection workflows.
crates/…/package_risk.rsDefines the explainable package-risk signals and score boundary.
crates/…/registry_api.rsShows how optional registry evidence is normalized and bound to package and release identity.
crates/…/install_txn.rsDefines install planning, source checks, package extraction, and explicit coverage gaps.
crates/…/inspect.rsConnects artifact files to archive, startup, record, and native analysis.
crates/…/mod.rsDefines the artifact observation model, policy evaluation, and coverage floor.
crates/…/firewall.rsDefines the pre-install integrity and inspection gate.
crates/…/install.rsDefines the install-from-digest and post-install integrity boundary.
crates/…/pkg_install.rsRuns the approved Python install through the contained execution path and records its outcome.
crates/…/install.rsContains command checks for unsafe package and infrastructure sources.
crates/…/taint.rsDefines download-to-later-execution provenance tracking.
crates/…/verdict.rsLists the supply-chain findings and their action strength.