Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 36 ยท Security Features

Dependabot and Dependency Security

Use the dependency graph, Dependabot alerts, security updates and version updates to keep dependencies safe. Configure dependabot.yml and try a version-range checker.

Modern projects are mostly other people's code. A typical web app has a handful of direct dependencies and hundreds of indirect ones, and any of them can have a security flaw discovered next month. GitHub offers a set of connected features that track what you depend on, warn you when a known vulnerability appears, and even open pull requests to fix it. This lesson explains them in the order they build on each other.

The dependency graph

GitHub reads your manifest and lock files (package.json and package-lock.json, requirements.txt, pom.xml, Cargo.lock, go.mod, composer.lock, Gemfiles and many more) and builds a dependency graph: every package your repository uses, direct and transitive. You can browse it under Insights -> Dependency graph (or the Dependencies tab), and the same data answers the reverse question for public packages: "who depends on me?".

Lock files matter. A manifest says "express": "^4.18.0", which allows many versions; the lock file records the exact one installed. Alerts are more precise when exact versions are known, so always commit your lock file for applications.

For ecosystems GitHub cannot read statically, the dependency submission API lets a workflow upload the resolved dependency list. Repositories also offer automatic dependency submission for some build tools such as Maven and Gradle.

Dependabot alerts

GitHub maintains the GitHub Advisory Database, a curated collection of security advisories, which includes reviewed advisories for packages in the major ecosystems and links to CVE records. When an advisory matches a package and version range in your dependency graph, Dependabot alerts notify you.

An alert tells you:

  • which dependency and which manifest file is affected;
  • the severity (low, moderate, high, critical), usually with a CVSS score;
  • the vulnerable range and the first patched version;
  • whether a fix is available as a pull request.

Enable alerts under Settings -> Advanced Security (or Code security) by turning on "Dependabot alerts". Notifications reach watchers and maintainers by email, web or mobile. You can dismiss an alert with a reason ("fix started", "no bandwidth", "tolerable risk", "vulnerable code is not actually used"), which documents your decision for the team. In organizations, alert rules can auto-dismiss low-impact alerts or auto-triage them by severity.

Dependabot security updates

When an alert has a patched version, Dependabot security updates automatically open a pull request that raises the dependency to the lowest safe version. Tests run on that pull request like any other, so you merge with evidence. If one patch fixes several alerts, they are grouped in one pull request.

Dependabot version updates

Security updates react to flaws. Version updates keep you current before a flaw appears, on a schedule you choose. They are configured with a file named .github/dependabot.yml:

YAML
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
      day: "monday"
    open-pull-requests-limit: 5
    groups:
      dev-dependencies:
        dependency-type: "development"
        update-types: ["minor", "patch"]
    ignore:
      - dependency-name: "left-pad"
        versions: ["2.x"]
    labels: ["dependencies"]

  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "monthly"

  - package-ecosystem: "docker"
    directory: "/"
    schedule:
      interval: "weekly"

Key settings:

  • package-ecosystem is the tool: npm, pip, maven, gradle, composer, cargo, gomod, bundler, nuget, docker, github-actions, terraform and others.
  • directory is where the manifest lives (use several entries for a monorepo).
  • schedule.interval can be daily, weekly or monthly.
  • groups merge related updates (for example all minor and patch bumps of dev tools) into one pull request, which cuts noise a lot.
  • ignore skips a dependency or a version range you cannot adopt yet.
  • open-pull-requests-limit caps how many update pull requests are open at once.

Note the github-actions ecosystem: it updates the uses: actions/checkout@v4 lines in your workflows, which is part of supply-chain hygiene (see workflow security).

You can also talk to Dependabot from pull request comments, for example @dependabot rebase, @dependabot recreate or @dependabot ignore this minor version.

Pair Dependabot with a solid test suite and required status checks. An automatic pull request is only as trustworthy as the tests that run on it. Some teams auto-merge patch updates when the tests pass, using a small workflow with the gh pr merge --auto command.

Understanding version ranges

An alert depends on comparing your version with a vulnerable range such as >= 4.0.0, < 4.17.21. This is semantic versioning (MAJOR.MINOR.PATCH): a major bump may break compatibility, a minor adds features, a patch fixes bugs. The stand-in below parses simple ranges and tells you whether a version is affected. It is a simplified model for learning (no pre-release tags, no || unions), not the logic GitHub uses internally.

JS Stand-in: is this version vulnerable? (simplified)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The advisories above are made up for the exercise; they are not real vulnerabilities.

Working through an alert

A sensible routine when an alert arrives:

  1. Open the alert and read the advisory: is your usage affected? Many flaws need a specific function call.
  2. If a Dependabot security update pull request exists, review the changelog, wait for tests, and merge.
  3. If no fix exists, look for a workaround in the advisory, or replace the dependency, and dismiss the alert with a reason only when you are sure.
  4. For transitive dependencies, check whether the parent package has a newer release that pulls in the fixed version, or use your package manager's override feature (overrides in npm, resolutions in Yarn).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main difference between Dependabot security updates and version updates?

    Security updates are triggered by alerts, while version updates follow your dependabot.yml schedule.
  2. 2. Why should applications commit their lock file?

    Manifest ranges allow many versions; the lock file pins the real one.
  3. 3. Which dependabot.yml setting merges many small bumps into one pull request?

    groups collect matching updates (for example minor and patch of dev dependencies) into a single pull request.
  4. 4. Why add the github-actions ecosystem to dependabot.yml?

    Dependabot can bump uses: lines such as actions/checkout@v4 to newer versions.

Summary

  • The dependency graph lists direct and transitive dependencies from manifest and lock files.
  • Dependabot alerts match them against the GitHub Advisory Database; security updates open fix pull requests.
  • Version updates, configured in .github/dependabot.yml, keep dependencies fresh; use groups and ignore to control noise.
  • Triage alerts with context, and let your tests gate every automated pull request.

Next: Code Scanning and Secret Scanning