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 / threat-intelligence-and-registry-correlation

Threat intelligence and registry correlation

Threat intelligence and registry correlation turns package names, versions, URLs, network indicators, and hashes into security evidence. It combines the signed local ThreatDB with registry history and advisory data so Tirith can find known threats, assess package risk, detect dependency confusion, and scan project dependencies without treating missing data as proof of safety.

System role

This subsystem supplies evidence to package checks, package-risk analysis, and project-wide ecosystem scans. Local data supports fast offline checks. Online data adds registry history and advisory context only when the operation allows network access.

The main flow joins feed maintenance, local lookup, online correlation, and policy-aware findings.

flowchart LR
    F[Threat feeds] --> B[Signed ThreatDB]
    P[Package and project identities] --> C[Correlation]
    B --> C
    R[Registry APIs and history] --> C
    O[OSV and KEV] --> C
    C --> A[Package risk]
    C --> S[Ecosystem scan]
    A --> V[Explained findings]
    S --> V

This page complements Supply-chain and artifact security and Artifact analysis lifecycle. Those pages cover the wider security model and archive inspection. This page covers identity, intelligence, registry provenance, and ecosystem-level dependency evidence.

ThreatDB data

ThreatDB is the local intelligence store for package records and network indicators. Its data also supports artifact hashes, file hashes, malicious URLs, campaigns, and behavior tags. The primary database is signed and distributed by CI. An optional local overlay adds operator-selected network feeds.

Source tiers

The source pipeline treats feed collection as one transaction. It fetches reviewed upstream revisions and mutable feeds into private staging. It validates the complete set and records source provenance before it gives the set to the compiler.

TierPurposeCurrent examples
PrimarySigned baseline shipped to clientsOpenSSF malicious packages, Datadog malicious packages, ecosyste.ms typosquats, Feodo Tracker, CISA KEV, and curated exfiltration endpoints
SupplementalOptional user-local network enrichmentURLhaus, ThreatFox, Phishing Army, PhishTank, FireHOL IP lists, and Tor exit nodes
HeldDefined source not used in the signed buildDigitalSide Threat-Intel remains held while freshness and redistribution terms are unresolved

The source-pin watcher proposes immutable revisions for the three repository-backed package feeds. It uses a completed Assign IDs boundary for OpenSSF and the default branch head for the other two feeds. The proposal is validated with a real fetch and compile before review publication. This keeps source updates reviewable without giving the discovery job signing or release authority.

References: .github/…/fetch-threatdb-sources.sh• L1-12 .github/…/fetch-threatdb-sources.sh• L27-49 .github/…/fetch-threatdb-sources.sh• L277-339 .github/…/threatdb_source_pins.py• L19-34 .github/…/threatdb_source_pins.py• L224-244 .github/…/threatdb-source-pins.yml• L18-109 .github/threatdb-source-pins.json• L1-29

Feed publication

The build records source revisions, commit times, selection times, content hashes, registry snapshot hash, feed hashes, licenses, and compiler metadata in source provenance. It then compiles and signs the database. A source failure, timeout, missing input, size violation, or registry snapshot failure stops publication before a partial source set can reach the compiler.

The rolling release publishes immutable database assets behind signed discovery data. The legacy manifest remains the v1 discovery path. The current v1 manifest points to asset tirith-threatdb-45111381476-1.dat with a recorded size of 11977934 bytes and SHA-256 digest e99ec4f305014ccd5f47d6fd34767c30deb650c4860ac3ac42d1076228c552a4. A v2 index can publish a compatible pair of v1 and v2 assets when its exact activation gate is enabled. The publisher protects assets referenced by either current discovery surface and keeps source provenance with the database generation during cleanup.

References: .github/…/fetch-threatdb-sources.sh• L322-372 .github/…/fetch-threatdb-sources.sh• L405-456 .github/…/fetch-threatdb-sources.sh• L489-560 .github/…/threatdb.yml• L448-560 .github/…/threatdb.yml• L593-657 .github/…/threatdb.yml• L740-885 .github/…/threatdb.yml• L966-1179 threatdb-manifest.json• L1

Local lookups

ThreatDB applies one identity policy to feed ingestion and lookup. Package names are canonicalized by ecosystem. Hostnames are normalized before exact or parent-domain matching. Package assessment keeps the difference between an exact version, a constraint, a resolved version, and an unspecified version.

The lookup surface covers these broad inputs:

InputEvidenceMeaning
Package and versionMalicious-package records with source, confidence, and affected-version scopeExact hit, affected constraint, proven exclusion, or unresolved warning
Package namePopular-package distance and typosquat recordsNear-name or confirmed typosquat signal
Hostname or IPv4 addressNetwork feed indicatorsSource-specific threat match
Normalized URLExact malicious-URL recordURL-level match stronger than a host-only match
Artifact or file hashv2 hash recordsKnown artifact or file match with campaign and behavior context

The primary database is authoritative for records that it contains. A supplemental match can add evidence but cannot make an unresolved primary package assessment clean. If the local database is unavailable, callers keep weaker coverage and report that the intelligence source was unavailable. A malformed v2 data trailer is rejected rather than treated as an empty v2 database.

References: crates/…/threatdb.rs• L251-397 crates/…/threatdb.rs• L475-562 crates/…/threatdb.rs• L869-936 crates/…/threatdb.rs• L1330-1451 crates/…/threatdb.rs• L1560-1585 crates/…/threatdb.rs• L2216-2592

ThreatDB update lifecycle

ThreatDB updates move from signed discovery data to verified local state. The client first tries the signed v2 index when the build supports it. If that index is absent, incompatible, invalid, or its asset cannot be verified, the client falls back to the independently signed v1 manifest.

sequenceDiagram
    participant C as Tirith client
    participant D as Discovery documents
    participant L as Release asset
    participant F as Local files
    C->>D: Fetch and verify v2 index
    alt Compatible v2 asset
        C->>L: Download selected asset
        C->>C: Check hash, signature, format, and sequence
        C->>F: Atomically install v2 file
    else Missing or unusable v2 index
        C->>D: Fetch and verify v1 manifest
        C->>L: Download v1 asset
        C->>C: Check hash, signature, format, and sequence
        C->>F: Atomically install v1 file
    end
    C->>F: Reconcile optional supplemental feeds

The v2 file uses a distinct local path so an older client cannot read a format it does not understand. The loader prefers v2 only when it is structurally valid and signed. Sequence checks prevent rollback. The installed primary database and the optional overlay are separate concerns. A current primary database still triggers overlay reconciliation when policy enables, retries, or disables supplemental feeds.

References: crates/…/threatdb_cmd.rs• L375-405 crates/…/threatdb_cmd.rs• L423-500 crates/…/threatdb_cmd.rs• L523-644 crates/…/threatdb.rs• L1453-1553

Supplemental feed refresh

Supplemental feeds are opt-in network indicators. The client validates the remote target, bounds response size and time, parses each feed into its intended indicator type, and writes a local overlay only when every enabled feed produces usable data.

A partial outage does not rebuild the overlay from only the feeds that succeeded. The last known good overlay stays in place. A disabled group removes its overlay. An empty successful response is treated as a failure for publication so an upstream wipe cannot erase coverage.

References: crates/…/threatdb_cmd.rs• L681-842 crates/…/threatdb_cmd.rs• L845-1006

Registry provenance

Registry provenance adds facts that threat feeds cannot provide. The online registry path normalizes package metadata and binds the response to the requested package. It supports npm, PyPI, and crates.io in the current package-risk path.

Registry metadata

Registry data can describe package age, selected-version age, version history, maintainers, download activity, source repository, yanked or deprecated state, npm lifecycle scripts, and npm distribution claims. These facts enrich risk analysis. They do not prove that a downloaded archive or attestation was verified. Network access occurs only in an explicit online operation. Failed transport, parsing, size, unsupported-ecosystem, and missing-version checks remain unavailable rather than clean.

A confirmed 404 is different from a failed request. The former supports a package-not-found claim. The latter means the system does not know the registry result.

References: crates/…/registry_api.rs• L43-118 crates/…/registry_api.rs• L162-240 crates/…/registry_api.rs• L304-373 crates/…/registry_api.rs• L849-918

Registry history

Registry history turns repeated provenance observations into a time-based signal. A general provenance fetch records a local maintainer snapshot. The system compares the two newest snapshots to distinguish normal maintainer churn from a full ownership transfer.

An ownership transfer requires maintainers in both snapshots with no identity carried from the older set. A narrow existence check or an exact install-bound lookup does not write history because those operations do not need a history side effect.

References: crates/…/registry_history.rs• L1-12 crates/…/registry_history.rs• L23-38 crates/…/registry_history.rs• L132-173 crates/…/registry_history.rs• L195-235 crates/…/registry_api.rs• L201-301

Advisory correlation

Advisory correlation checks a concrete package release against OSV data and adds exploitation context from the CISA Known Exploited Vulnerabilities catalog. It keeps a verified empty advisory result separate from an unavailable query.

OSV queries

OSV queries use an ecosystem, package name, and exact version. A range or tag is not sent as a literal version. When a request has a range, Tirith can use a safe concrete version from deps.dev only when that version satisfies the range. Otherwise it reports that the advisory check could not resolve the requested release.

The result can include advisory IDs, aliases, summaries, references, and a parseable CVSS v3 score. An OSV alias found in KEV adds an actively exploited signal.

StateMeaning
Not checkedOffline operation, no concrete version, or unsupported mapping
VerifiedOSV answered, including an empty advisory list
UnavailableThe request failed or the version selector was unsuitable

Response size and advisory-field limits keep an enrichment request bounded. A failed query never becomes a verified clean result.

References: crates/…/threatdb_api.rs• L23-40 crates/…/threatdb_api.rs• L277-451 crates/…/threatdb_api.rs• L741-795 crates/…/threatdb_api.rs• L1011-1062

Dependency-confusion checks

Dependency confusion is the risk that a public package can shadow a package intended for private use. Tirith reports this as a heuristic signal because a name match alone does not prove malicious intent.

Internal package patterns

Policy can declare internal package names for one ecosystem or for all ecosystems. A pattern can include one trailing wildcard for a package family. Matching uses the target ecosystem's identity rules, such as PEP 503 folding for PyPI and case handling for npm.

An online resolution that matches an internal pattern explains how a public registry could shadow the internal package. A confirmed package-not-found response is also checked so a missing public name is not confused with a successful public resolution.

References: crates/…/dep_confusion.rs• L1-24 crates/…/dep_confusion.rs• L34-113 crates/…/package.rs• L576-645

Reserved npm scopes

Without an operator pattern, the heuristic checks a small reserved set of npm scopes that often represent private namespaces. It applies only to npm and does not flag ordinary scopes outside that set.

References: crates/…/dep_confusion.rs• L53-71 crates/…/dep_confusion.rs• L116-153

Package-risk analysis

Package-risk analysis is a deterministic, advisory assessment of package identity, content, registry, and advisory signals. It produces a score from 0 to 100 with named factors. The score explains review risk. It does not itself set a verdict, action, or exit code.

Offline package signals

Offline analysis does not download package content. It compares the name with local popular-package and typosquat data. When local content is already available, it can identify install hooks and bundled compiled artifacts. It reads install-script text to find network calls or shell spawning. It never runs the script.

These signals describe review cost and possible identity risk. An unknown name is not treated as malicious merely because local data has no record for it.

References: crates/…/package_risk.rs• L1-25 crates/…/package_risk.rs• L128-178 crates/…/package_risk.rs• L625-815 crates/…/install_script_analysis.rs• L1-16 crates/…/package.rs• L650-704

Online package signals

Online analysis adds age, release change, maintainer, download, repository, and yanked or deprecated signals when the registry provides them. It can add OSV, KEV, dependency-confusion, registry repository, and exact npm install-script evidence. npm distribution claims remain provenance context rather than byte verification.

The result states whether online data was not requested, was available, or was unavailable. Explanations preserve the source and reason for degraded coverage so an external lookup failure cannot look like a clean package.

References: crates/…/package_risk.rs• L359-509 crates/…/package_risk.rs• L818-1064 crates/…/registry_api.rs• L304-373 crates/…/package.rs• L489-645

Ecosystem scanning

Ecosystem scanning applies the package assessment path to a project. It discovers declared or installed dependencies, keeps their source and version intent, correlates them with ThreatDB and online evidence, and sends the combined results through the normal policy-aware finding and verdict flow.

flowchart TD
    I[Project root or supplied lockfile] --> D[Discover dependencies]
    D --> N[Normalize ecosystem identity and version intent]
    N --> T[ThreatDB and typosquat checks]
    N --> R[Optional registry and OSV checks]
    D --> G[Coverage and integrity checks]
    T --> A[Dependency assessments]
    R --> A
    G --> A
    A --> P[Policy-aware findings and verdict]

The scan supports three input modes:

ModeMain inputMain use
ManifestsDependency files below a project rootReview declared dependencies and lockfile-resolved transitive intent
InstalledPackage trees and installed metadataReview what exists on disk when installed state may differ from declarations
Specific lockfileOne supplied lockfileReview one resolved dependency set without walking the project

Manifest scanning

Manifest scanning reads supported npm, Python, Rust, Go, and Ruby dependency descriptions without executing them or using the network. Lockfiles add resolved versions and transitive dependencies where the format supports them. Bounded Python include and constraint handling follows project scope. Direct URL and VCS dependencies stay visible as coverage gaps because they are not ordinary registry identities.

Each dependency keeps its ecosystem, security target, version intent, source manifest, risk factors, and ThreatDB result. Exact versions can produce definite results. Ranges and missing versions can remain unresolved when a threat record exists but the scan cannot prove the selected release. npm aliases are assessed under their resolved target package.

References: crates/…/ecosystem_scan.rs• L191-259 crates/…/ecosystem_scan.rs• L371-475 crates/…/ecosystem_scan.rs• L597-639 crates/…/ecosystem_scan.rs• L1058-1149 crates/…/ecosystem_scan.rs• L2469-2518

Installed-tree scanning

Installed scanning checks package trees and metadata on disk. It can inspect node_modules, Python site-package roots, Go vendor trees, and Rust lock state. It then reuses the same identity, risk, and optional online provenance path. This exposes drift between declared dependencies, lockfiles, generated environments, and installed packages.

The scan reports unreadable inputs, size caps, and other coverage limits as incomplete analysis. Online registry calls are reused per package. Large scans can require operator confirmation before making many network requests.

References: crates/…/ecosystem_scan.rs• L2591-2631 crates/…/ecosystem_scan.rs• L2825-2939 crates/…/ecosystem.rs• L39-44 crates/…/ecosystem.rs• L105-175

Installed integrity

Installed mode also checks whether Python distributions still match their recorded installed state. It correlates file-hash mismatches, overlapping ownership, and unowned startup hooks. Stronger evidence such as an unowned startup hook stays separate from ordinary environment drift.

This integrity view complements package identity and registry provenance. Missing records are coverage gaps, not proof of tampering. The scan includes the integrity result and folds it into the same policy-aware verdict path.

References: crates/…/ecosystem_scan.rs• L2652-2669 crates/…/ecosystem_scan.rs• L3361-3424 crates/…/ecosystem_scan.rs• L3433-3515 crates/…/ecosystem_scan.rs• L3531-3589

Scan findings

The scan combines malicious-package matches, typosquats, near-name signals, slopsquats, unresolved versions, registry and OSV results, dependency-confusion checks, and policy thresholds. A slopsquat is a plausible fake name near a popular package. It remains a heuristic and is separate from a confirmed typosquat.

Global allowlists suppress a dependency as a whole. Rule-scoped allowlists suppress only the matching rule, so one exception does not hide other evidence for that dependency. The final report includes the scan mode, discovered inputs, dependency assessments, online state, notes, coverage gaps, installed integrity when relevant, and the resolved verdict.

References: crates/…/ecosystem_scan.rs• L1570-1753 crates/…/ecosystem_scan.rs• L1842-2173 crates/…/ecosystem_scan.rs• L2624-2715 crates/…/ecosystem.rs• L231-263

Change checklist

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

  • Keep source names, tiers, confidence values, behavior tags, provenance fields, and finding labels aligned across feed parsing, compilation, lookup, JSON output, and release metadata.
  • Keep package and hostname canonicalization aligned across extraction, ThreatDB lookup, policy patterns, registry identity binding, and OSV ecosystem mapping.
  • Preserve the difference between exact, resolved, constrained, and unspecified versions. Never turn an unresolved request into a clean result by checking a substituted release.
  • When a registry field becomes a score factor, define its unavailable state first. Keep npm distribution claims separate from verified archive or attestation checks.
  • If snapshot or ownership rules change, update both snapshot writing and two-snapshot comparison. Check which lookup paths may write history.
  • If a feed changes tier or source pin, review the watcher, fetch transaction, attribution, freshness checks, parser limits, source provenance, and release publication together.
  • Keep database format support, signed discovery data, cache-path separation, sequence floors, and v1 fallback aligned when the ThreatDB asset or format changes.
  • If a parser accepts new fields, preserve its indicator-type boundary and fail-closed input, record, response-size, and unique-entry limits.
  • If scan modes, alias identity, installed integrity, or scan limits change, keep shared assessments and coverage gaps aligned so truncated or conflicting input cannot look clean.

Important failure modes

TriggerConsequenceGuard
A required source fetch, sparse checkout, or registry snapshot failsA partial source set could be compiled or publishedPrivate staging, bounded child processes, explicit waits, validation, and one final rename fail the transaction closed
A source-pin candidate is a transient OpenSSF ingestion commitThe signed database could include an incomplete source boundaryThe watcher selects the completed Assign IDs boundary and checks the candidate is strictly ahead
A package range is sent to OSV as a literal versionThe wrong release may be checked and appear cleanOnly exact selectors or constraint-satisfying resolved versions are queried
A registry response names a different package or releaseProvenance could attach to the wrong dependencyResponses are bound to the canonical requested identity and exact version when needed
A registry or OSV request failsUnknown data could look like a verified clean resultResults expose unavailable or not-checked states separately from verified
Only one maintainer snapshot existsA transfer claim could be based on current state aloneTransfer evidence needs two snapshots with non-empty sets and no surviving identity
A supplemental feed is partial or emptyThe local overlay could silently lose indicatorsThe last known good overlay is retained until every enabled feed returns usable data
A v2 database trailer or signature is invalidNew sections could be read from corrupt or untrusted dataThe v2 file is rejected; the loader uses a valid signed path or reports failure
A v2 asset is installed over the v1 pathAn older client could read an unsupported formatv1 and v2 assets use distinct local paths and the stamped format must match discovery data
A project walk or input read hits a capUnseen dependencies could make an incomplete scan look cleanCoverage gaps and incomplete analysis are included in findings and notes
A lockfile alias or installed identity conflicts with its resolved pathEvidence could attach to an alias or wrong packageContradictory lock data is not indexed and path identity must agree with declarations
A public package matches an internal pattern or reserved npm scopeA public package may shadow a private dependencyDependency-confusion checks surface a separate explained heuristic

Key files

FileWhy to read it
crates/…/threatdb.rsDefines ThreatDB source tiers, package assessment states, signed loading, identity rules, and package, network, URL, and hash lookups.
crates/…/threatdb_cmd.rsShows signed update selection, v1 fallback, v2 path separation, background updates, and supplemental feed reconciliation.
.github/…/fetch-threatdb-sources.shShows the fail-closed source transaction, registry snapshot input, bounded fetches, and source provenance.
.github/…/threatdb_source_pins.pyDefines reviewed upstream pin discovery and the completed-source boundary policy.
.github/…/threatdb-source-pins.ymlShows how source proposals are fetched, compiled, staged, and sent for review without signing authority.
.github/…/threatdb.ymlShows signed database publication, discovery surfaces, v2 activation, provenance, and retention.
threatdb-manifest.jsonIdentifies the current signed v1 database asset and its checksum, size, version, and signature.
crates/…/registry_api.rsDefines normalized registry metadata, supported registries, identity binding, cache behavior, and unavailable states.
crates/…/registry_history.rsDefines maintainer snapshots and time-based ownership signals.
crates/…/threatdb_api.rsDefines OSV, KEV, and related online enrichment states and limits.
crates/…/dep_confusion.rsDefines internal package patterns and reserved npm-scope checks.
crates/…/package_risk.rsDefines package-risk factors, score behavior, and explanations.
crates/…/ecosystem_scan.rsDefines dependency discovery, manifest and installed scans, integrity checks, coverage, and report assembly.
crates/…/ecosystem.rsConnects ecosystem scanning to online mode, policy, output, and exit behavior.