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

未关闭 适合新手
#481 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ruby
领域
database

调研方向

错误位于 lib/bundler/audit/database.rb 中的 each_advisory_path 和 each_advisory_path_for,其中 @path 未经转义就传入 Dir.glob。请与 exists?、download 和 git? 将 @path 视为字面目录的方式进行比较。使用包含 [...] 的数据库路径复现,目前会报告 0 个 advisory 并以退出码 0 退出。完成标准是:带方括号的路径能加载与重命名路径相同的 1411 个 advisory,并以退出码 1 退出。

由索引模型根据 Issue 内容生成。

描述

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/

主要语言
Ruby
星标
2.8k
派生
243
平均合并
1 天 13 小时
30 天内合并 PR
9

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rubysec/bundler-audit 的其他 Issue

查看 rubysec/bundler-audit 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。