Phlexing on the XSS Filters: A Comedy of Errors in Ruby Views
Vulnerability ID: GHSA-W67G-2H6V-VJGQ
CVSS Score: 8.1
Published: 2026-02-06
Phlex, a Ruby library designed to write object-oriented HTML, suffered from a catastrophic failure in its Cross-Site Scripting (XSS) mitigation logic. Despite intended protections, the library failed to account for the chaotic nature of HTML parsing, allowing attackers to inject malicious JavaScript via four distinct vectors: attribute splatting, dynamic tag generation, HTML entity encoding, and SVG context manipulation. The vulnerability stems from an over-reliance on regular expressions for sanitization without understanding the full breadth of browser parsing behaviors.
TL;DR
Phlex attempted to sanitize HTML generation using blocklists but failed to account for browser parsing quirks. Attackers can bypass XSS protections using HTML entities (e.g., 'javascript:'), attribute injection via whitespace/slashes, or malicious dynamic tag names. Update immediately.
⚠️ Exploit Status: POC
Technical Details
- Attack Vector: Network (Input to View Layer)
- CVSS: 8.1 (High)
- CWEs: CWE-79 (XSS), CWE-116 (Improper Encoding)
- Exploit Status: PoC Available / Functional Exploit
- Components: Attribute Splatting, Dynamic Tag Helper, Protocol Filter
- Fix Complexity: Low (Library Update)
Affected Systems
- Ruby on Rails applications using Phlex
- Sinatra applications using Phlex
- Hanami applications using Phlex
- Any Ruby application using Phlex for HTML generation
-
phlex: < Feb 6 2026 Release (Fixed in:
Feb 6 2026 Release)
Code Analysis
Commit: 9f56ad1
Main fix implementation for attribute splatting and entity decoding
UNSAFE_ATTRIBUTE_NAME_CHARS = %r([<>&"'/=\s\x00])
Commit: 74e3d86
Refinement of fix across branches
...
Exploit Details
- GitHub Advisory: Proof of Concept provided in the advisory and test suite commits.
Mitigation Strategies
- Update Phlex gem to patched version
- Sanitize keys in attribute hashes before passing to Phlex
- Strictly validate URLs using a proper URI parser, not regex
- Avoid passing user input directly to dynamic tag generation
Remediation Steps:
- Check current version:
bundle list phlex - Update gem:
bundle update phlex - Verify update: Ensure version corresponds to post-Feb 6, 2026 release
- Review codebase for usage of
tagwith user input - Review codebase for usage of double-splat
**attributes with user input
References
Read the full report for GHSA-W67G-2H6V-VJGQ on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)