CVE-2025-54572: Ruby saml Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-rrqh-93c8-j966
CWE-400 CWE-770
Published
Advisory Summary

CVE-2025-54572 is a MODERATE denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Ruby saml libraries in the RubyGems ecosystem. The issue involves ruby saml dos vulnerability with large saml response. Remediation is available by upgrading affected packages to version 1.18.1.

CVE-2025-54572 at a Glance

CVE Identifier CVE-2025-54572
GHSA Identifier GHSA-rrqh-93c8-j966
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Ruby saml
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix CVE-2025-54572

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

ruby-saml fixed: 1.18.1
Upgrade ruby-saml to 1.18.1
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 ruby-saml

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-54572, inspect your project dependencies for Ruby saml:

inspect dependencies for ruby-saml

Analyze the terminal output to locate any version of Ruby saml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.18.1), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Ruby saml, 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 A denial-of-service vulnerability exists in ruby-saml even with the message_max_bytesize setting configured. The vulnerability occurs because the SAML response is validated for Base64 format prior to checking the message size, leading to potential resource exhaustion. ### Details `ruby-saml` includes a `message_max_bytesize` setting intended to prevent DOS attacks and decompression bombs. However, this protection is ineffective in some cases due to the order of operations in the code: https://github.com/SAML-Toolkits/ruby-saml/blob/fbbedc978300deb9355a8e505849666974ef2e67/lib/onelogin/ruby-saml/saml_message.rb ```ruby def decode_raw_saml(saml, settings = nil) return saml unless base64_encoded?(saml) # <--- Issue here. Should be moved after next code block. settings = OneLogin::RubySaml::Settings.new if settings.nil? if saml.bytesize > settings.message_max_bytesize raise ValidationError.new("Encoded SAML Message exceeds " + settings.message_max_bytesize.to_s + " bytes, so was rejected") end decoded = decode(saml) ... end ``` The vulnerability is in the execution order. Prior to checking bytesize the `base64_encoded?` function performs regex matching on the entire input string: ```ruby !!string.gsub(/[\r\n]|\\r|\\n|\s/, "").match(BASE64_FORMAT) ``` ### Impact _What kind of vulnerability is it? Who is impacted?_ When successfully exploited, this vulnerability can lead to: - Excessive memory consumption - High CPU utilization - Application slowdown or unresponsiveness - Complete application crash in severe cases - Potential denial of service for legitimate users All applications using `ruby-saml` with SAML configured and enabled are vulnerable. ### Potential Solution Reorder the validation steps to ensure max bytesize is checked first ```ruby def decode_raw_saml(saml, settings = nil) settings = OneLogin::RubySaml::Settings.new if settings.nil? if saml.bytesize > settings.message_max_bytesize raise ValidationError.new("Encoded SAML Message exceeds " + settings.message_max_bytesize.to_s + " bytes, so was rejected") end return saml unless base64_encoded?(saml) decoded = decode(saml) ... end ```

CVE-2025-54572 Affected Ruby saml Versions

1 component(s)
Fixed Versions:
1.18.1
Product / Package Ecosystem Affected Versions Fixed Version
ruby-saml
RubyGems
< 1.18.1
1.18.1

References

Frequently Asked Questions

What is CVE-2025-54572?
CVE-2025-54572 is a security vulnerability in Ruby saml involving Ruby SAML DOS vulnerability with large SAML response under CWE-400: Uncontrolled Resource Consumption.
Which Ruby saml versions are affected?
Affected versions include releases prior to 1.18.1 across affected packages: ruby-saml.
What version fixes CVE-2025-54572?
Upgrading to 1.18.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ruby-saml affected?
Yes, ruby-saml is affected in releases prior to 1.18.1. Upgrade your dependency to 1.18.1 or later.
What CWE is associated with CVE-2025-54572?
CVE-2025-54572 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check RubyGems dependencies for CVE-2025-54572?
Run the dependency tree command: 'inspect dependencies for ruby-saml'. 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-rrqh-93c8-j966",
  "modified" : "2025-11-03T21:34:17Z",
  "published" : "2025-07-30T13:20:05Z",
  "aliases" : [ "CVE-2025-54572" ],
  "summary" : "Ruby SAML DOS vulnerability with large SAML response",
  "details" : "### Summary\nA denial-of-service vulnerability exists in ruby-saml even with the message_max_bytesize setting configured. The vulnerability occurs because the SAML response is validated for Base64 format prior to checking the message size, leading to potential resource exhaustion.\n\n### Details\n`ruby-saml` includes a `message_max_bytesize` setting intended to prevent DOS attacks and decompression bombs. However, this protection is ineffective in some cases due to the order of operations in the code:\n\nhttps://github.com/SAML-Toolkits/ruby-saml/blob/fbbedc978300deb9355a8e505849666974ef2e67/lib/onelogin/ruby-saml/saml_message.rb\n\n```ruby\n      def decode_raw_saml(saml, settings = nil)\n        return saml unless base64_encoded?(saml) # <--- Issue here. Should be moved after next code block.\n\n        settings = OneLogin::RubySaml::Settings.new if settings.nil?\n        if saml.bytesize > settings.message_max_bytesize\n          raise ValidationError.new(\"Encoded SAML Message exceeds \" + settings.message_max_bytesize.to_s + \" bytes, so was rejected\")\n        end\n\n        decoded = decode(saml)\n        ...\n      end\n```\n\nThe vulnerability is in the execution order. Prior to checking bytesize the `base64_encoded?` function performs regex matching on the entire input string:\n\n```ruby\n!!string.gsub(/[\\r\\n]|\\\\r|\\\\n|\\s/, \"\").match(BASE64_FORMAT)\n```\n\n### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nWhen successfully exploited, this vulnerability can lead to:\n\n- Excessive memory consumption\n- High CPU utilization\n- Application slowdown or unresponsiveness\n- Complete application crash in severe cases\n- Potential denial of service for legitimate users\n\nAll applications using `ruby-saml` with SAML configured and enabled are vulnerable.\n\n### Potential Solution\n\nReorder the validation steps to ensure max bytesize is checked first\n\n```ruby\ndef decode_raw_saml(saml, settings = nil)\n  settings = OneLogin::RubySaml::Settings.new if settings.nil?\n\n  if saml.bytesize > settings.message_max_bytesize\n    raise ValidationError.new(\"Encoded SAML Message exceeds \" + settings.message_max_bytesize.to_s + \" bytes, so was rejected\")\n  end\n  \n  return saml unless base64_encoded?(saml)\n  decoded = decode(saml)\n  ...\nend\n```",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "ruby-saml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.18.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/SAML-Toolkits/ruby-saml/security/advisories/GHSA-rrqh-93c8-j966"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-54572"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SAML-Toolkits/ruby-saml/pull/770"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SAML-Toolkits/ruby-saml/commit/38ef5dd1ce17514e202431f569c4f5633e6c2709"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/SAML-Toolkits/ruby-saml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SAML-Toolkits/ruby-saml/releases/tag/v1.18.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/ruby-saml/CVE-2025-54572.yml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2025/09/msg00001.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-770" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-07-30T13:20:05Z",
    "nvd_published_at" : "2025-07-30T14:15:29Z"
  }
}