`Database` passes unescaped `@path` to `Dir.glob`, reporting 0 advisories when the database path contains `[...]`

Open Beginner friendly
#481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
database

Research direction

The bug is in lib/bundler/audit/database.rb, in each_advisory_path and each_advisory_path_for, where @path goes into Dir.glob unescaped. Compare that with how exists?, download and git? treat @path as a literal directory. Reproduce with a database path containing [...], which should currently report 0 advisories and exit 0. Done means the bracketed path loads the same 1411 advisories and exits 1, like the renamed path.

Written by the indexing model from the issue text.

Description

Description

Bundler::Audit::Database#each_advisory_path and #each_advisory_path_for in lib/bundler/audit/database.rb pass @path directly to Dir.glob(File.join(@path, ...)) without escaping glob metacharacters. Other Database methods (exists?, download, git?, update!) treat @path as a literal directory, so when the advisory database path (for example via --database, BUNDLER_AUDIT_DB="$PWD/..." in a matrix workspace like job[ruby-3.3], or HOME) contains [...], bundle-audit clones or opens the database cleanly while Dir.glob treats the bracketed segment as a character class, matches zero .yml files, and reports No vulnerabilities found with exit status 0.

Steps To Reproduce

Steps to reproduce the bug:

  1. Create a Gemfile.lock locking rack 2.2.0 and download ruby-advisory-db into a directory whose path contains brackets:
mkdir repro && cd repro
printf 'source "https://rubygems.org"\ngem "rack", "2.2.0"\n' > Gemfile
bundle lock
bundle-audit download "job[ruby-3.3]/ruby-advisory-db"
bundle-audit check --database "job[ruby-3.3]/ruby-advisory-db"
echo "exit=$?"
  1. Rename the directory to remove the brackets and run the same check:
mv "job[ruby-3.3]" job_ruby_3_3
bundle-audit stats "job_ruby_3_3/ruby-advisory-db"
bundle-audit check --database "job_ruby_3_3/ruby-advisory-db"
echo "exit=$?"

Expected Behavior

Both paths should load all advisories in ruby-advisory-db, report the known rack 2.2.0 advisories (such as CVE-2020-8184), print Vulnerabilities found!, and exit with status 1, matching the output for job_ruby_3_3/ruby-advisory-db:

ruby-advisory-db:
  advisories:	1411 advisories
  last updated:	2026-11-22 09:40:03 -0500
  commit:	c87703e7f2c64f8745ce032711308a17d10cda55

Name: rack
Version: 2.2.0
CVE: CVE-2020-8184
GHSA: GHSA-j6w9-fv6q-3q52
Criticality: High
URL: https://groups.google.com/g/rubyonrails-security/c/OWtmozPH9Ak
Title: Percent-encoded cookies can be used to overwrite existing prefixed cookie names
Solution: update to '~> 2.1.4', '>= 2.2.3'
...
Vulnerabilities found!
exit=1

Actual Behavior

Download ruby-advisory-db ...
Cloning into 'job[ruby-3.3]/ruby-advisory-db'...
ruby-advisory-db:
  advisories:	0 advisories
  last updated:	2026-11-22 09:40:03 -0500
  commit:	c87703e7f2c64f8745ce032711308a17d10cda55
No vulnerabilities found
exit=0

Environment

$ bundler-audit --version
bundler-audit 0.9.3
$ bundle --version
Bundler version 2.6.9
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
$ git --version
git version 2.39.5

Also reproduced against master (3cd866bedf609aa2c98a464909602f595265ae49).

We found this while fuzzing.

Credit: https://ucsbplse.github.io/

Dominant language
Ruby
Stars
2.8k
Forks
243
Avg merge
1d 13h
Merged PRs (30d)
9

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rubysec/bundler-audit

All issues in rubysec/bundler-audit

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.