# Trust model

What trusted, untrusted, and unknown mean, which evidence Lafke records, and what it does not guarantee.

## What trusted means

`trusted` means the artifact passed the active policy. It is not a guarantee that a package is safe, authentic, or free of malicious behavior. The CLI prints this as `trusted (under active policy)`.

The default policy requires that OSV was queried and returned no known vulnerabilities. Unchecked vulnerabilities (`state: unknown`) are `unknown`, not `trusted`. Digest, provenance, signature, capability, and ownership checks are optional policy rules and are off by default.

## What untrusted means

The artifact failed at least one enabled policy rule. Typical reasons:

- known vulnerabilities
- malicious package reports (`MAL-*`)
- a missing digest, when required
- an invalid or weak digest (sha1 or malformed), when `require_digest` is set
- provenance not verified, when required
- a signature not verified, when required
- a denied capability, such as shell or install scripts
- filesystem access above the configured maximum

Malicious package reports are not vulnerabilities. A package with no CVEs can still be malware. The default policy denies both.

## What unknown means

Lafke could not complete an evidence lookup, or the ecosystem does not yet expose that evidence. Unknown is not the same as verified.

Offline scans leave provenance, signature, capability, ownership, behavior, chain, vulnerability, and malicious-report state as `unknown`. That is not a clean bill of health.

## Evidence states

| State | Meaning |
| --- | --- |
| `unknown` | The lookup was skipped or failed. |
| `missing` | The lookup succeeded and found no evidence. |
| `present` | The registry returned provenance or signatures, which are not cryptographically verified. |
| `verified` | Cryptographic verification succeeded. |

`require_provenance: true` accepts `present` or `verified`.

## Policy

A policy file sets which rules are on. Policy files are fail-closed: unknown fields, versions, and network modes are errors, so a typo such as `require_provenace` does not silently disable a rule.

```yaml
version: 1
rules:
  require_no_vulnerabilities: true
  provenance:
    minimum: verified
  signature:
    minimum: verified
  capabilities:
    deny:
      - shell
      - native_code
      - install_scripts
    filesystem:
      maximum: read
  ownership:
    publisher_change: deny
    maintainer_added: warn
    maintainer_removed: review
```

For ownership rules, `deny` and `review` fail `verify`, and `warn` is reported but does not fail. When any ownership action is set, unset actions default to `deny`.

To use the built-in strict profile instead:

```sh
lafke verify --profile strict
```

`strict` requires digests, and `provenance` and `signature` minimums of `verified`. It is mutually exclusive with `--policy`.

## Evidence Lafke records

How much evidence Lafke can collect depends on the ecosystem.

| Evidence | npm, pnpm, yarn, bun | PyPI (uv, Poetry, PDM) | Other ecosystems |
| --- | --- | --- | --- |
| Digest | From the language lockfile. | From the language lockfile. | From the language lockfile. |
| Vulnerabilities | OSV advisories. | OSV advisories, when the source is proven public. | OSV advisories, when the source is proven public. |
| Malicious packages | OSV `MAL-*` reports. | The same, when OSV is queried. | The same, when OSV is queried. |
| Provenance and signature | Verified through Sigstore and registry signatures, and bound to the lockfile digest. | Verified through the PEP 740 Integrity API and Sigstore. | `unknown`. |
| Capabilities and behavior | From registry metadata and source heuristics. | `unknown`. | `unknown`. |
| Ownership | The npm publisher and maintainers. | `unknown`. | `unknown`. |

Capability detection for npm uses install-script and native-build metadata, then a deterministic scan of published JavaScript and TypeScript sources for network, filesystem, environment, and shell indicators. It is not a behavioral sandbox and may under-report obfuscated code.

Prefer the `strict` profile on npm-heavy trees today: other ecosystems still leave provenance and signature as `unknown`.

## Accepted findings

`lafke accept` records that a team reviewed a finding and accepts it until a date. Accepted findings are stored in `.lafke/exceptions.yaml`, separately from the policy and from `lafke.lock`.

An exception does not make an artifact `trusted`. It does not change `lafke.lock`, the policy digest, or any trust status, and `scan`, `verify`, and `diff` ignore it. It only suppresses a finding in `audit` output, where it stays visible as suppressed with its reason, approver, and expiry.

Every exception needs a reason and an expiry date. When one lapses, the finding comes back and `audit` reports `exception-expired`. `lafke doctor` reports expired exceptions, those expiring within 14 days, and exceptions with no approver.

## What Lafke does not guarantee

- that a trusted package is benign
- that a version bump is a security fix
- that transitive behavior is reachable or exploitable
- that GitHub, npm, or OSV are uncompromised
- that non-npm ecosystems collect provenance or signature evidence
- that capability heuristics catch every malicious behavior
- that a present trust chain proves the artifact was built from that source

The full model is in [`docs/trust-model.md`](https://github.com/lafke/lafke/blob/main/docs/trust-model.md) and [`docs/threat-model.md`](https://github.com/lafke/lafke/blob/main/docs/threat-model.md) in the repository.
