Dependency Review Action

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 10 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Dependency Review and the Dependency Review Action

Introduction: Why Supply Chain Security Matters

In the modern software development landscape, the vast majority of application code is not written by the primary developers. Instead, it is imported. We rely heavily on open-source libraries, frameworks, and packages to provide functionality that would otherwise take months to build from scratch. While this approach dramatically increases velocity, it also introduces a significant attack surface: the software supply chain. When you pull in a dependency, you are implicitly trusting the authors of that package, their security practices, and the integrity of their distribution platform.

Dependency Review is a mechanism designed to mitigate the risks associated with this reliance on external code. It provides a way to inspect the changes in your project's dependencies before they are merged into your main codebase. By automating this inspection, you can catch malicious code, outdated packages with known vulnerabilities, or dependencies that are licensed in a way that conflicts with your organizational policies. In essence, Dependency Review acts as a gatekeeper, ensuring that your software remains secure and compliant even as you iterate rapidly.

In this lesson, we will focus on the Dependency Review Action, an automated tool that integrates directly into your CI/CD pipeline. We will explore how it works, how to configure it effectively, and how to interpret its findings. By the end of this guide, you will understand how to shift security to the left, catching potential supply chain issues during the pull request process rather than after they reach production.


Not read yet

Understanding the Anatomy of Dependency Risk

Before we dive into the tooling, it is important to understand what we are actually looking for. Dependency risk generally falls into three distinct categories: security vulnerabilities, licensing compliance, and malicious behavior.

1. Known Security Vulnerabilities

This is the most common form of risk. Many open-source packages have publicly disclosed vulnerabilities, tracked in databases like the GitHub Advisory Database or the National Vulnerability Database (NVD). If your project uses an outdated version of a library that has a known exploit, your application is inherently vulnerable. Dependency Review tools cross-reference your manifest files (like package-lock.json, requirements.txt, or go.sum) against these databases to alert you when a vulnerable version is introduced.

2. Licensing Compliance

Every piece of open-source software comes with a license, and these licenses dictate how you can use, modify, and distribute the code. Some licenses are permissive, while others, known as "copyleft" licenses, may require you to release your own source code if you include the library in your product. Using a library with an incompatible license can lead to significant legal headaches. Dependency Review can scan your dependencies and highlight packages that violate your organization's legal policies.

3. Malicious Code Injection

This is the most insidious threat. Attackers sometimes compromise a popular package by injecting malicious code—a technique known as "dependency confusion" or "typosquatting." Because these packages often look legitimate, they can bypass traditional security scans. Dependency Review focuses on analyzing changes in your manifest files. By spotting a sudden jump in version numbers (an indicator of a hijacked package) or the addition of an unknown dependency, you gain an opportunity to manually investigate before the change is accepted.

Callout: Dependency Review vs. SCA Tools Software Composition Analysis (SCA) tools are typically designed to generate a comprehensive inventory of your dependencies and provide a report on historical vulnerabilities. Dependency Review, particularly the Action we are discussing, is more surgical. It is designed to be a "delta-based" tool. It doesn't just look at the current state; it looks at the difference between the base branch and the proposed changes in a pull request. This makes it an ideal tool for developers to use during the code review process.


Not read yet

Configuring the Dependency Review Action

The Dependency Review Action is designed to be low-friction. It integrates into your existing workflow by running as a check on your pull requests. When a user submits a PR that modifies dependency manifest files, the Action triggers, evaluates the changes, and posts a comment on the PR detailing the potential risks.

Step-by-Step Implementation

To add the Dependency Review Action to your repository, you need to create a workflow file in your .github/workflows directory. A standard configuration looks like this:

name: Dependency Review
on: [pull_request]

permissions:
  contents: read
  pull-requests: write

jobs:
  dependency-review:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
      
      - name: Dependency Review
        uses: actions/dependency-review-action@v4
        with:
          fail-on-severity: critical

Breaking Down the Configuration

  • on: [pull_request]: This ensures the job only runs when a pull request is opened or updated, which is exactly when you need to review dependency changes.
  • permissions: The action needs to read the contents of your repository to parse your lock files and write comments on the pull request to report its findings.
  • fail-on-severity: This is a powerful configuration option. You can set it to low, moderate, high, or critical. If the Action detects a vulnerability at or above this level, the check will fail, effectively blocking the PR from being merged until the dependency is updated or the risk is mitigated.

Note: The fail-on-severity setting is a policy-driven decision. Start with critical or high if you are just beginning to implement these checks to avoid overwhelming your team with noise. As your team matures in their security practices, you can tighten this policy to moderate or even low.


Not read yet

Advanced Configuration Options

While the basic setup is often sufficient for many teams, the Dependency Review Action provides several advanced parameters that allow you to tailor the behavior to your specific organizational needs.

Ignoring Specific Dependencies

Sometimes, you may have a dependency that is flagged as vulnerable, but you have already patched it internally or have implemented a workaround that makes the vulnerability non-exploitable in your specific context. You can use the allow-list or deny-list features (or local configuration files) to manage these exceptions.

Customizing Output Formats

By default, the action posts a comment on the PR. However, for larger organizations that aggregate security metrics, you might want to export the results. The action supports various output formats, allowing you to integrate the findings into your broader security dashboard.

Handling Private Packages

If your project relies on private registries or internal packages, standard public scanners may struggle to resolve them. Ensure that your CI environment has the necessary authentication tokens (stored as GitHub Secrets) configured so that the runner can access your private package sources during the dependency resolution phase.


Not read yet

Best Practices for Dependency Management

Implementing the Dependency Review Action is only one part of a healthy security strategy. To truly secure your supply chain, you must cultivate a culture of proactive dependency management.

1. Keep Dependencies Up to Date

The most effective way to avoid vulnerabilities is to stay on current, supported versions of your dependencies. Use automated tools like Dependabot to automatically generate PRs for dependency updates. When paired with the Dependency Review Action, you create a "safe update" loop: Dependabot proposes the change, and Dependency Review validates that the change is secure.

2. Audit Your Lock Files

Never commit a manifest file (like package.json or requirements.txt) without its corresponding lock file (package-lock.json or poetry.lock). Lock files ensure that every environment—development, staging, and production—uses the exact same version of every dependency, including transitive dependencies. Transitive dependencies are the packages that your dependencies depend on, and they often represent the largest portion of your total dependency tree.

3. Minimize Your Dependency Footprint

Every dependency you add increases your surface area for potential supply chain attacks. Before adding a new library, ask:

  • Does this library solve a problem I cannot solve with native code or existing libraries?
  • Is the library well-maintained, with active contributors and recent commits?
  • How many transitive dependencies does this library bring in?
  • What is the license of this library and its dependencies?

4. Use Scoped Registries

If your organization uses internal packages, always use scoped registries. This prevents "dependency confusion" attacks, where an attacker publishes a malicious package with the same name as an internal package to a public registry, hoping your package manager will pull the public version instead of your private one.


Not read yet

Common Pitfalls and How to Avoid Them

Even with the best tools, mistakes happen. Here are some of the most common pitfalls teams encounter when setting up Dependency Review and how to avoid them.

Pitfall 1: The "Noise" Problem

If you turn on Dependency Review with strict settings on a large, legacy project, you will likely be flooded with hundreds of alerts. This leads to "alert fatigue," where developers start ignoring the security warnings entirely.

  • The Fix: Start with a "log-only" mode. Configure the action to report findings but not fail the build. Spend a few weeks triaging the backlog, updating the most critical packages, and ignoring or documenting the false positives. Once the baseline is clean, switch the action to "fail on critical."

Pitfall 2: Ignoring Transitive Dependencies

Many developers only look at their top-level dependencies. However, a vulnerability in a transitive dependency is just as dangerous as one in a top-level dependency.

  • The Fix: Ensure your CI process always runs a full dependency resolution. If you are using Python, for example, ensure you are using a tool that generates a full lock file (like pip-compile or Poetry), rather than just relying on a loose requirements.txt file.

Pitfall 3: Not Reviewing the "Why"

Dependency Review tells you that a dependency changed, but it doesn't tell you why the change was made in your code.

  • The Fix: Treat dependency updates like any other code change. When a PR updates a library, look at the release notes of that library. If the update is a major version jump, check for breaking changes. If the update seems suspicious (e.g., a massive version jump in a short time), take the time to investigate the package's repository on GitHub or the registry site.

Not read yet

Quick Reference: Dependency Review Severity Levels

Severity Description Recommendation
Critical Known exploit exists; high impact on data/system integrity. Block merge immediately; patch required.
High Significant vulnerability; potential for remote code execution. Block merge; patch prioritized.
Moderate Vulnerability exists but may require specific conditions. Review and update within a specific timeframe.
Low Minimal risk; often theoretical or difficult to exploit. Monitor and update during regular maintenance.

Warning: Never ignore a "Critical" or "High" severity warning simply because the package is widely used. Popular packages are prime targets for attackers because a successful compromise provides access to thousands of downstream projects. Always verify the source of the update.


Integrating SBOMs (Software Bill of Materials)

While Dependency Review focuses on the change, the Software Bill of Materials (SBOM) focuses on the inventory. An SBOM is a formal record of every component, library, and module that makes up your software. In the context of supply chain security, an SBOM is the "ingredients list" for your application.

Why SBOMs Matter

When a new "zero-day" vulnerability (like the Log4j incident) is announced, the first question your security team will ask is: "Are we using this?" Without an SBOM, you have to manually scan every repository, which can take days or weeks. With an SBOM, you can query your inventory and identify affected systems in seconds.

Generating SBOMs in CI

You can integrate SBOM generation into your GitHub Actions workflow. Tools like syft or cdxgen can be used to scan your project and generate a file in a standard format, such as SPDX or CycloneDX.

- name: Generate SBOM
  run: |
    # Example using syft to generate a CycloneDX SBOM
    curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
    syft . -o cyclonedx-json > bom.json

By storing these SBOMs as artifacts in your CI process, you create a historical audit trail. If you ever need to perform a forensic analysis of a previous build, the SBOM will tell you exactly what was inside it at that moment in time.


Not read yet

Putting It All Together: A Comprehensive Security Workflow

To build a truly resilient supply chain, you should combine these elements into a cohesive strategy. Here is what an ideal workflow looks like:

  1. Continuous Scanning: Use Dependabot to keep dependencies updated and identify known vulnerabilities.
  2. Pull Request Validation: Use the Dependency Review Action to gate PRs, ensuring no new vulnerable or non-compliant dependencies are introduced.
  3. Inventory Management: Generate an SBOM for every release, providing visibility into your application's composition.
  4. Policy Enforcement: Define clear organizational policies regarding licenses and vulnerability thresholds.
  5. Regular Audits: Periodically perform manual reviews of your dependency tree to identify "zombie" dependencies—packages that are no longer maintained but are still being pulled in by your project.

Example: Handling a Vulnerable PR

Imagine a developer opens a PR that adds a new library, fast-data-parser, to the project. The Dependency Review Action runs and comments on the PR:

"Dependency Review found 1 critical vulnerability in fast-data-parser@1.2.0. This package is known to be vulnerable to buffer overflow attacks. Please upgrade to version 1.2.1 or higher."

The developer now has the information they need to fix the issue before the code is ever merged. They update the package.json, push the change, and the Action runs again, this time passing the check. This is the essence of "shifting security left"—finding and fixing problems when they are cheapest and easiest to resolve.


Not read yet

Common Questions and FAQ

Q: Does Dependency Review catch zero-day vulnerabilities?

A: Generally, no. Dependency Review relies on databases of known vulnerabilities. If a vulnerability is brand new and has not yet been assigned a CVE or added to an advisory database, the tool will not flag it. This is why you should always combine automated tools with good coding practices, such as minimizing dependencies and vetting new libraries before adding them.

Q: Can I use Dependency Review for languages other than JavaScript/Python?

A: Yes. The Dependency Review Action supports many package managers, including Maven (Java), NuGet (.NET), Go, and more. Check the official documentation for the list of supported manifest file formats.

Q: What if I have a false positive?

A: If a tool flags a dependency that you believe is safe, check the vulnerability details. Sometimes a vulnerability might be in a part of the code that you aren't actually using. If you determine it is a false positive, you can often configure the tool to ignore that specific alert, though you should document why you are ignoring it for audit purposes.

Q: How often should I update my dependencies?

A: As often as possible. While you don't need to be on the bleeding edge of every release, staying within one or two minor versions of the latest release is a good goal. This makes the eventual jump to a new major version much less painful and keeps you protected against the majority of discovered vulnerabilities.


Not read yet

Key Takeaways

As we conclude this lesson, keep these core principles in mind to maintain a secure supply chain:

  • Trust, but Verify: Every dependency is a potential entry point for an attacker. Treat third-party code with the same scrutiny you apply to your own.
  • Automate the Gate: Use the Dependency Review Action to block vulnerable code from entering your main branch. This prevents technical and security debt from accumulating.
  • Focus on the Delta: Use tools that evaluate changes in pull requests rather than just scanning the entire codebase. This provides immediate, actionable feedback to developers.
  • Maintain an Inventory: Use SBOMs to keep track of what is in your software. You cannot secure what you do not know you have.
  • Policy is Paramount: Define clear rules for your team regarding licensing and vulnerability thresholds. When everyone knows the rules, compliance becomes a natural part of the development process.
  • Manage the Noise: Start with a sensible configuration (e.g., failing only on critical vulnerabilities) and refine your settings as your team's security maturity grows.
  • Culture Matters: Security is a team effort. Encourage developers to take ownership of their dependencies and provide them with the tools and time necessary to keep them updated.

By implementing these practices, you are not just adding another step to your CI/CD process; you are building a robust defense against one of the most significant attack vectors in modern software development. The goal is to move from a reactive security posture—where you scramble to patch after a breach—to a proactive one, where security is an inherent, automated, and invisible part of your team's daily workflow.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.