---
id: "CVE-2026-128068"
page: "https://infrastack.ai/live/CVE-2026-128068"
kind: "vulnerability"
aliases: ["CVE-2026-128068", "GHSA-cpgf-5mjf-73p7"]
title: "rails-html-sanitizer: Possible regular expression denial of service with certain configurations"
severity: "medium"
cvss: 5.3
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "rails-html-sanitizer", "fixed": ["1.7.2"], "affected": ">= 1.0.3, < 1.7.2", "ecosystem": "rubygems"}]
ecosystems: ["rubygems"]
tags: ["cwe-1333", "cwe-400", "loofah", "package", "rails", "rails-html-sanitizer", "ruby"]
not_affected_if: ["default-config", "managed-hosting", "ruby-3.2-or-later"]
published_at: "2026-11-13T17:54:38+00:00"
first_seen_at: "2026-11-13T17:56:44+00:00"
updated_at: "2026-11-13T17:57:01+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-cpgf-5mjf-73p7", "first_seen_at": "2026-11-13T17:56:44+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-128068", "first_seen_at": "2026-11-13T18:49:29+00:00"}]
exploit_sources: []
---

# rails-html-sanitizer: Possible regular expression denial of service with certain configurations

Link for people: https://infrastack.ai/live/CVE-2026-128068 (this .md is for agents)

rails-html-sanitizer's PermitScrubber uses a regular expression that takes quadratic time on long runs of whitespace in SVG href attributes. An attacker who submits such HTML can consume CPU out of proportion to the input size, slowing or stalling the sanitizing process.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- rubygems:rails-html-sanitizer affected >= 1.0.3, < 1.7.2 fixed 1.7.2

## How to check

- Run `ruby --version`; affected only on Ruby 3.1 and earlier, since Ruby 3.2 and later match the pattern in linear time.
- Check the Gemfile.lock for `rails-html-sanitizer` between `1.0.3` and `1.7.2` (exclusive of `1.7.2`).
- Search the app for overrides of the sanitizer's allowed tags that add `use` (an SVG reference element) together with `href` or `xlink:href` in allowed attributes.
- Check whether Loofah is used directly, since its own copy of the check is affected until Loofah `2.25.3`.

## Fix

- `rails-html-sanitizer` `1.7.2`
- Loofah `2.25.3` for applications that use Loofah directly
- Alternatively, run Ruby 3.2 or later

## Timeline

- 2026-11-13T17:56:44+00:00 ghsa https://github.com/advisories/GHSA-cpgf-5mjf-73p7
- 2026-11-13T18:49:29+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-128068

## Documents

- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/rails/rails-html-sanitizer/security-advisories/GHSA-cpgf-5mjf-73p7
- [advisory] Maintainer's advisory: github.com https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-cpgf-5mjf-73p7
- [fix] Patch: github.com https://github.com/rails/rails-html-sanitizer/commit/f776f963b9d9346271aade9cb903e793fd38e865
- [fix] Release: github.com https://github.com/rails/rails-html-sanitizer/releases/tag/v1.7.2

## From the sources

## Summary

`Rails::HTML::PermitScrubber` restricts the `href` and `xlink:href` attributes of SVG reference elements to local references. That check matched the attribute value against `/^\s*[^#\s].*/m`. In Ruby `^` anchors to every line start and `\s` matches newlines, so an all-whitespace value made the engine rescan the value from each of its line starts, taking time quadratic in its length.

- Versions affected: `>= 1.0.3, < 1.7.2`
- Not affected: `< 1.0.3`
- Fixed versions: `1.7.2`

Only Ruby 3.1 and earlier are affected. Ruby 3.2 added linear-time regexp matching, which makes the pattern linear.

## Impact

An attacker who supplies HTML to be sanitized can consume CPU out of proportion to the input size, by sending an SVG reference element whose `href` or `xlink:href` is a long run of whitespace.

Applications are affected only when the allowed tags are overridden to include an SVG reference element such as `use`, along with `href` or `xlink:href` in the allowed attributes. The default allowed tags include no SVG elements, so the default configuration is not affected. Applications that use Loofah directly are exposed through its own copy of the check, fixed in Loofah 2.25.3.

## Workarounds

Run Ruby 3.2 or later, which matches the pattern in linear time, or remove the SVG reference elements from the overridden allowed tags.

## Credit

Reported by scyoon through the Rails HackerOne program.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
