Guides / Languages and packages

Check Ruby gems with bundler-audit

beginnerUpdated 26 Nov 2026715 words

bundler-audit reads the Gemfile.lock of a Ruby or Rails project and compares each gem version with the Ruby Advisory Database, a public collection of advisories for gems. It also warns about gem sources over plain http:// or git://. The check itself runs offline; only the download of the database needs the network.

Install it

gem install bundler-audit

As of November 2026 the current version is 0.9.3. bundler-audit keeps the advisory database as a git checkout in ~/.local/share/ruby-advisory-db and downloads it on the first run, so git must be installed. In a project you can also add it to the development group of the Gemfile:

group :development, :test do
  gem "bundler-audit", require: false
end

Run it

From the directory with Gemfile.lock:

bundle-audit check --update

--update fetches the latest advisories first. Without it, bundler-audit uses the copy it downloaded last time, which can be months old on a machine where it rarely runs.

For a Gemfile.lock with rack 2.2.3 (bundler-audit 0.9.3, trimmed):

ruby-advisory-db:
  advisories:	1411 advisories
  last updated:	2026-11-22 09:40:03 -0500
Name: rack
Version: 2.2.3
CVE: CVE-2022-30123
GHSA: GHSA-wq4h-7r42-5hrr
Criticality: Critical
URL: https://groups.google.com/g/ruby-security-ann/c/LWB10kWzag8
Title: Possible shell escape sequence injection vulnerability in Rack
Solution: update to '~> 2.0.9, >= 2.0.9.1', '~> 2.1.4, >= 2.1.4.1', '>= 2.2.3.1'

...

Vulnerabilities found!

That run listed 35 advisories for this one gem.

Each finding names the gem, the installed version, the advisory id (CVE or GHSA), its criticality, a link and the versions that fix it. With findings, the command ends with Vulnerabilities found! and exit code 1, so it can gate CI as it is. Without findings it prints No vulnerabilities found and exits with 0.

A lockfile with a different name is checked with --gemfile-lock:

bundle-audit check --gemfile-lock Gemfile.next.lock

Update the gems it names

Update only the gem in question:

bundle update rack --conservative
Fetching rack 2.2.26 (was 2.2.3)
Installing rack 2.2.26 (was 2.2.3)
Bundle updated!

--conservative updates the gem you name and none of its indirect dependencies. If the fixed version is outside the constraint in your Gemfile (for example gem "rack", "2.2.3"), change the constraint first (here to "~> 2.2"), then run the update. Run your tests and bundle-audit check again; in the example it then printed No vulnerabilities found.

bundle outdated lists all gems with newer releases. It does not know about advisories; use it to plan upgrades.

Ignore an advisory

When an advisory does not affect your app, add its id to .bundler-audit.yml in the project directory:

---
ignore:
  - CVE-2024-26146

In the example this took the count from 35 to 34. bundle-audit check --ignore CVE-2024-26146 does the same for one run.

Write the reason in the commit message or a comment next to it and look at the list again when you upgrade Rails or the gem.

Run it in CI

GitHub Actions with a daily schedule, so that new advisories are found on days without commits:

name: bundler-audit
on:
  push:
  pull_request:
  schedule:
    - cron: "11 6 * * *"
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
      - run: gem install bundler-audit
      - run: bundle-audit check --update

The job does not run bundle install, since bundler-audit only reads Gemfile.lock.

In GitLab CI:

bundler-audit:
  image: ruby:3.4.13-slim-trixie
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends git
    - gem install bundler-audit
  script:
    - bundle-audit check --update

For Rake users, bundler-audit ships a task (require "bundler/audit/task" and Bundler::Audit::Task.new in the Rakefile) that adds rake bundle:audit.

What it does not cover

bundler-audit checks gems. Ruby itself (installed with the distribution, rbenv, or in the base image), native libraries such as libxml2 or OpenSSL, and the operating system packages need their own updates. Gems that bundle a C library get fixes for it as new gem releases; the database has entries for nokogiri that concern its packaged libxml2, for example.

The Patchbrief agent can read the Gemfile.lock of the app paths you configure and checks it against new advisories every day.

Sources

Check your servers every day

The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.

Start free