Skip to main content
MediumSupply chainOWASP A05:2021CWE-200

How to fix: Ruby Gemfile or Gemfile.lock Exposed

A Gemfile or Gemfile.lock was found publicly accessible. Ruby gem dependency files reveal the exact gem versions used, enabling CVE-based vulnerability scanning against your dependencies.

Why it matters

Gemfile.lock contains the complete dependency tree with exact versions including all transitive gems. An attacker can use bundler-audit or CVE databases to find vulnerable gems in under a minute.

Gemfile.lock is similar to package-lock.json: it pins every gem to an exact version. This is necessary for reproducibility but should never be publicly accessible in production.

How to fix it

  1. 1Block access to Gemfile and Gemfile.lock in your web server configuration.
  2. 2In Rails: use config.public_file_server.enabled = false or configure Nginx to block these paths.
  3. 3Audit what files are in your Rails public/ directory.

Code examples

Rails public file server config

Ruby
# config/environments/production.rb
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Nginx deny rule
# location ~* /(Gemfile(\.(lock))?) { deny all; }

References

Detected automatically by VulnRadar. The check id is supply-chain-gemfile-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Ruby Gemfile or Gemfile.lock Exposed?
VulnRadar rates this medium severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-gemfile-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Ruby Gemfile or Gemfile.lock Exposed map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for ruby gemfile or gemfile.lock exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Ruby Gemfile or Gemfile.lock Exposed | VulnRadar