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

Đang mở Phù hợp với người mới
#481 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
database

Hướng nghiên cứu

Lỗi nằm trong lib/bundler/audit/database.rb, ở each_advisory_path và each_advisory_path_for, nơi @path được truyền vào Dir.glob mà không escape. So sánh với cách exists?, download và git? xử lý @path như một thư mục theo nghĩa đen. Tái hiện bằng một đường dẫn cơ sở dữ liệu chứa [...], hiện đang báo 0 advisory và thoát với mã 0. Hoàn thành khi đường dẫn có ngoặc vuông tải cùng 1411 advisory và thoát với mã 1, giống đường dẫn đã đổi tên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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/

Ngôn ngữ chính
Ruby
Star
2.8k
Fork
243
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rubysec/bundler-audit

Tất cả issue của rubysec/bundler-audit

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.