A Dependency Audit Example That Finds Real Risk

A Dependency Audit Example That Finds Real Risk

A production service can have 40 packages in its manifest and more than 1,000 packages in its resolved dependency tree. A dependency audit example is useful when it shows what to do with that difference. The goal is not to produce a long list of CVEs. It is to decide which dependency risks can affect your software, who owns the fix, and what can wait.

This example uses a Node.js API, but the same method works for Python, Java, Ruby, Go, and frontend applications. The package commands differ. The questions do not.

What a dependency audit should answer

A useful audit answers four things in plain language. What third-party code is present? Which versions are actually deployed? Which known issues apply to those versions? What action is proportionate to the exposure?

That last question is where many audits fail. A vulnerability scanner can match a package version to an advisory. It usually cannot tell whether your application reaches the affected code path, whether the package is only used during tests, or whether an upgrade breaks a critical integration. Those are engineering decisions.

Treat the audit as a snapshot with a repair plan, not as a compliance document you file and forget. Dependencies change when you merge a lockfile update, release a container, or restore an old branch to production.

Dependency audit example: a Node API

Assume you maintain an API called orders-api. Its package.json declares Express, a JWT library, a PostgreSQL client, a logger, and a test framework. The repository commits package-lock.json, and production runs a container built from that lockfile.

Start by recording the scope. In this case, the audit covers the application repository, the production lockfile, and the container image built from the current main branch. It does not cover the infrastructure repository, browser extension, or internal shared packages. Writing this down prevents a common mistake: reporting a clean application dependency tree while an adjacent deployment repository carries the vulnerable component.

Next, generate the resolved package tree from a clean install. Keep the lockfile revision and the date with the result. The manifest tells you what you asked for. The lockfile tells you what you got. For a deployed service, the latter matters more.

The first inventory might look like this:

| Package | Resolved version | Direct or transitive | Used in production? | Owner | | --- | --- | --- | --- | --- | | express | 4.18.3 | Direct | Yes | API team | | jsonwebtoken | 9.0.2 | Direct | Yes | Identity team | | pg | 8.12.0 | Direct | Yes | API team | | axios | 1.7.4 | Transitive | Yes | Platform team | | glob | 7.2.3 | Transitive | No, test tooling only | Developer experience |

The owner column is not paperwork. If nobody owns a direct dependency, upgrades wait because every team assumes another team will test them. For a transitive dependency, the owner is normally the team that owns the nearest direct parent, unless your platform team maintains a shared base image or package catalog.

Now run your advisory source against the exact lockfile. Do not scan only package.json. A version range such as ^1.2.0 may allow a safe release today while the committed lockfile still resolves an older vulnerable version. Also scan the image or software bill of materials when native packages, operating system packages, or copied build artifacts are in scope.

Suppose the scan reports three findings:

  1. glob 7.2.3 has a denial-of-service advisory in a pattern-matching path.
  2. axios 1.7.4 has an advisory involving requests to attacker-controlled URLs under specific configurations.
  3. An older cookie package is present through Express middleware and has a low-severity parsing issue.

The scan is the beginning of the audit. The next step is validation.

Validate each finding against your code

For glob, inspect how it arrives in the tree and where it runs. In this example, it belongs to test tooling and is absent from the production image because production dependencies are installed separately. The finding still deserves an update. It is not a production incident.

For axios, search the repository for its call sites and configuration. The API uses it in a payment-provider client. The base URL is a fixed environment variable, paths are chosen from a small internal map, and user input is passed as JSON request data rather than a URL. The vulnerable behavior is not reachable through the current application flow.

That does not mean “ignore it.” A future feature might add webhooks, imports, or tenant-defined endpoints. Record the reason it is not reachable, upgrade in the next routine dependency change, and add a test or code constraint if the safe URL assumption is central to the decision.

For cookie, confirm which middleware loads it and whether the affected parser handles attacker-controlled headers. The API is internet-facing and processes request cookies. Even if the advisory has low severity, the code path is reachable. The fix should be scheduled promptly, or expedited if a compatible patch is available with a narrow change set.

Reachability is not always cheap to establish. For a large codebase, you may need runtime traces, integration tests, or an owner who knows a service boundary. State that uncertainty directly. “Not assessed” is more honest and more useful than “not exploitable” without evidence.

Prioritize by exposure, not severity alone

Severity helps compare advisories, but it is not a queue by itself. A high-severity issue in a development-only package may be less urgent than a lower-severity issue reachable from an unauthenticated endpoint.

For each finding, assess the affected environment, whether untrusted input reaches it, what an attacker gains, whether a practical fix exists, and the cost of applying that fix. The cost matters because a major-version upgrade can introduce more operational risk than a small patch. It should not become an excuse to defer every hard update.

The repair plan for this example is straightforward. Update cookie through the compatible Express middleware release, test authentication and session handling, and ship it in the next patch release. Update glob with the next developer tooling refresh. Upgrade axios within its current major version, even though the vulnerable behavior is not currently reachable, then retain the URL constraint in the payment client.

Each action needs a due date and a verification step. “Upgrade dependency” is incomplete. A better task says: update the lockfile, rebuild the container, rerun the advisory scan, run payment integration tests, and verify the deployed image digest came from the rebuilt artifact.

Check the supply chain, not only advisories

Known-vulnerability matching answers one narrow question: whether a published advisory covers a version you use. A dependency audit should also ask whether you installed the package you intended to install.

Verify that your lockfile is committed and reviewed. Use a registry policy that prevents unexpected sources where appropriate. Review new install scripts, native binaries, and packages with unusually broad access during builds. If your build downloads tools outside the package manager, include those downloads in the inventory too.

This is where the audit becomes specific to your environment. A frontend project may need to review packages that run during a browser build. A backend service may focus on production image contents and credentials available to build jobs. A desktop application may need to consider bundled libraries that remain on user machines for years.

Do not claim reproducibility if the build can silently resolve fresh versions without a lockfile or if the deployment pulls a mutable image tag. You may still have a workable process, but the audit cannot reliably connect a finding to a released artifact.

Make the audit repeatable

A quarterly full review is useful, especially for older services. It is not enough on its own. Run an automated lockfile scan in pull requests or continuous integration, and rerun it when you rebuild an image. Then reserve human review for new direct dependencies, findings with plausible exposure, exceptions, and upgrades that change behavior.

Keep exceptions short and expiring. An exception should name the package and resolved version, the reason it remains, the compensating control if one exists, an owner, and a review date. “No time this sprint” is not a compensating control.

For teams on GitHub or GitLab, dependency health also belongs beside normal engineering work. You need to see whether updates are landing, whether maintainers are concentrated in one person, and whether the codebase is becoming harder to change. Wizhut .Code reads an organization with read-only access and explains those trends in plain words. It keeps no copy of your code.

The useful output of a dependency audit is a smaller, defensible list: fix this reachable issue now, update this low-risk package in routine maintenance, and reassess this uncertain finding when the missing evidence is available. That gives your team a way to reduce risk without turning every advisory into an emergency.