Can uv Detect Advisories? The Practical Answer

Can uv Detect Advisories? The Practical Answer

A clean uv.lock tells you exactly what your project resolved. It does not tell you whether those versions are known to be vulnerable. So, can uv detect advisories? Not on its own. uv is built to resolve, lock, install, and run Python environments quickly and reproducibly. Advisory detection is a separate security job that needs vulnerability data and a scanner that can interpret it.

That distinction matters because a dependency workflow can be perfectly reproducible and still reproduce a vulnerable environment on every machine and in every CI run.

Can uv detect advisories during dependency resolution?

uv does not treat an advisory database as a dependency constraint. When it resolves a project, it selects versions that satisfy your declared requirements, Python version, platform markers, and available package metadata. Its lockfile records the result. It does not normally reject a version because a CVE or GitHub Security Advisory applies to it.

This is the right boundary for a package manager. Advisory data changes independently of package releases, and vulnerability records are often incomplete, corrected later, or disputed. Folding that data directly into resolution would make installs less predictable and could force policy decisions that belong to the project owner.

The result is straightforward: use uv for deterministic dependency state, then use an advisory scanner to assess that state. The scanner should compare the resolved package name and version against a current vulnerability source, then report the affected range, the advisory identifier, and a fixed version when one exists.

Do not confuse uv lock success with a security result. A successful lock says the dependency graph can be resolved. A successful uv sync says that graph was installed. Neither statement says the graph has no published advisories.

Why uv.lock is the file that matters

Scanning pyproject.toml alone is better than nothing, but it answers a weaker question. A project may declare httpx >=0.25, while the lockfile selects one specific release. The advisory risk applies to the version actually installed, including indirect packages that never appear in the top-level dependency list.

uv.lock is the closest representation of the environment your application, test suite, or CI job will use. A useful scanner needs to read it accurately, including package versions, dependency edges, extras, markers, and source information where relevant. Otherwise, it can report packages that are not active for the current environment or miss ones that are.

There is a trade-off in scope. A full lockfile scan gives the broadest coverage, especially for transitive dependencies. It can also generate more findings, including packages introduced far below your direct requirements. A top-level-only view is quieter and makes ownership clearer, but it can hide the real source of exposure in a nested dependency.

The practical approach is to keep both views available. Start with the complete resolved graph for security coverage. Then group findings by the direct dependency that brought them in, so a developer can decide whether to upgrade, replace, constrain, or temporarily accept the risk.

What an advisory scanner must handle correctly

Dependency advisories are not a simple lookup table. A scanner has to match package ecosystems and normalize names, interpret affected version ranges, and handle advisories with no fixed release. It also needs current data. A scan based on a stale local cache can quietly miss a newly published advisory.

Good output is specific enough to act on. Each finding should identify the installed version, the affected range, the advisory or CVE identifier, severity if the source provides one, and the first known fixed version. It should also say whether the vulnerable package is direct or transitive.

Severity deserves context. A high-severity advisory in an optional feature that your application does not enable may have less immediate impact than a moderate issue in a public request path. Conversely, a low-confidence or unscored advisory is not automatically safe to ignore. The advisory record is a triage input, not a substitute for understanding reachability and deployment context.

False confidence is the larger failure mode. A scanner that claims a project is clean while reading the wrong file, ignoring markers, or checking only declared constraints is worse than one that clearly states its limits.

A practical uv advisory workflow

Keep the workflow close to the lockfile rather than making developers maintain a second hand-written requirements file. The basic sequence is small:

  1. Update or verify uv.lock as part of normal dependency work.
  2. Scan the resolved lockfile with a tool that explicitly supports uv lockfiles, or export a pinned requirements representation if that is the scanner's supported input.
  3. Fail CI only on policies your team has agreed to, such as known exploitable findings or advisories above a defined severity threshold.
  4. Re-scan after changing dependencies, and keep an exception record with an owner and expiration date when a fix cannot ship immediately.

The details depend on the project. A library may scan several Python versions and extras because its consumers resolve different graphs. An application generally has a narrower production environment, so scanning the exact production lock and platform is more meaningful. If you export requirements as a compatibility step, make sure the export preserves the dependency set and markers you intend to assess.

Run the scan in CI, but do not reserve it for CI. Developers need feedback while selecting or upgrading packages, when fixing the issue is still a small change. Practical UV takes this approach inside VS Code by focusing on uv-based dependency security and lockfile-accurate findings rather than treating the manifest as the installed environment.

A scheduled scan is also useful even when no dependency files changed. New advisories can be published for versions that have been in your lockfile for months. That is the core reason advisory checking cannot be a one-time resolution feature.

Fixing a finding without breaking reproducibility

When a scanner reports an affected package, first identify how it entered the graph. For a direct dependency, update the declared version range or request a newer version with uv, then review the lockfile change. For a transitive dependency, upgrade the direct parent package if possible. Adding a narrow constraint can work as a temporary measure, but it can create resolver pressure and should not become a permanent substitute for upgrading the parent.

After the update, inspect what else moved. Security remediation sometimes pulls in behavior changes, dropped Python-version support, or a different optional dependency path. Run the test suite and rebuild the environment from the updated lockfile. A fixed advisory is useful only if the resulting application still behaves as expected.

Sometimes there is no patched version. In that case, document whether the vulnerable code path is reachable, apply configuration-level mitigation if one exists, and set a date to revisit the exception. Suppressing an advisory forever turns a deliberate risk decision into invisible debt.

Treat the lockfile as evidence

uv gives Python projects a precise answer to a hard operational question: which packages did we choose? Advisory scanning answers the next question: what is known about the risk of those exact packages right now?

Keep those responsibilities separate, but run them together. A lockfile without an advisory check is reproducible exposure. An advisory check that ignores the lockfile is incomplete evidence. The useful workflow is the one that makes both facts visible before the vulnerable version reaches production.

Practical UV

uv inside VS Code. Outdated packages and known vulnerabilities are flagged in the file you already have open, and a pip project converts to uv in one click.