Scanner#internal_host? treats unresolvable or offline hosts as internal because [].all? is true
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The bug is in Scanner#internal_host? in lib/bundler/audit/scanner.rb, which calls Resolv.getaddresses(host).all?; an empty result makes [].all? return true and marks the source as internal. Start by reading that method and internal_source?, then reproduce with a host that does not resolve (for example gems.example.invalid). Done when an unresolvable http:// or git:// source is reported as an insecure source and the command exits with status 1.
Written by the indexing model from the issue text.
Description
Description
bundle-audit check skips InsecureSource warnings whenever Resolv.getaddresses(host) returns an empty array (for example when running offline without DNS access, despite the README noting that bundler-audit does not require a network connection, or when a source hostname in Gemfile.lock no longer resolves).
In lib/bundler/audit/scanner.rb, Scanner#internal_host? runs Resolv.getaddresses(host).all? { |ip| internal_ip?(ip) }. When Resolv.getaddresses(host) returns [], [].all? evaluates to true, so internal_source? treats the http:// or git:// source as a private internal IP.
Steps To Reproduce
Steps to reproduce the bug:
gem install rake -v 13.2.1
bundler-audit update
mkdir repro && cd repro
printf 'source "http://rubygems.org"\ngem "rake", "13.2.1"\n' > Gemfile
bundle lock --local
# Online: reports Insecure Source URI found: http://rubygems.org/ (exit 1)
bundle-audit check --no-update
# Offline (Linux network namespace with loopback up, like docker run --network none):
unshare -rn sh -c 'ip link set lo up && bundle-audit check --no-update'
The same happens while online on any OS if the http:// or git:// host does not resolve in DNS (source "http://gems.example.invalid").
Expected Behavior
bundle-audit check --no-update reports the http:// source and exits with status 1:
Insecure Source URI found: http://rubygems.org/
Vulnerabilities found!
Actual Behavior
No vulnerabilities found
Exit status is 0. Reproduces on bundler-audit 0.9.3 and current master (3cd866bedf).
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 tested against master at commit 3cd866bedf609aa2c98a464909602f595265ae49 on Debian x86_64.
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rubysec/bundler-audit
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rubysec/bundler-audit#481 ·
-
Combine ignored CVEs from both `--config` with `--ignore` flagPossibly taken A pull request linked to this issue is open or already merged. Openfeature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rubysec/bundler-audit#388 · 1 comment · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
rubysec/bundler-audit#478 · 1 reaction ·
-
Create a new bundler-audit release then figure out how to get the gem publishedPossibly taken @flavorjones claimed this 4 days ago. Openchore
Difficulty 5/5 Over a week Newbie friendliness 25/100
rubysec/bundler-audit#443 · 8 comments · 4 reactions · 1 assignee ·
-
Duplicate vulnerabilities reported for gems that have multiple arch specs on the lockfilePossibly taken @jrodriigues claimed this 147 days ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 56/100
rubysec/bundler-audit#438 · 4 comments ·
All issues in rubysec/bundler-audit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Coolhand-Labs/coolhand-ruby#232 ·
Maintainers usually reply within 1 day
-
community
Difficulty 1/5 Under an hour Newbie friendliness 78/100
newrelic/newrelic-ruby-agent#3734 · 1 comment ·
Maintainers usually reply within 2 days
-
ETQ admin anglophone, le libellé de la date limite de dépôt reste en françaisPossibly taken @mmagn claimed this today. Openautonome
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
demarche-numerique/demarche.numerique.gouv.fr#14711 ·
Maintainers usually reply within 1 day
-
Speed up the MIaaRD collection exportPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xronos-ch/xronos.rails#573 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
rapid7/metasploit-framework#22183 ·
Maintainers usually reply within 2 days