CVE-2023-23913
Medium · 6.3CVSS
6.3
EPSS
0.6%
Published
Jan 9, 2025
CISA due date
—
Cloudanix analysis
A flaw in a popular web development framework could allow an attacker to take over a user's account by tricking them into pasting specially crafted text into a web page.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Moderate
- Impact
- Data Tampering
- Component
- Web Framework
- Class
- XSS
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
A DOM-based Cross-Site Scripting (XSS) vulnerability exists in the rails-ujs component of Ruby on Rails. The flaw occurs because the library does not properly sanitize HTML content pasted from the clipboard into an element with the `contenteditable` attribute. If an attacker can convince a user to paste specially crafted HTML containing `data-method`, `data-remote`, or `data-disable-with` attributes, it can lead to the execution of arbitrary JavaScript in the context of the user's browser session on the affected website.
Why it matters to the business
Exploitation of this vulnerability can lead to the compromise of user accounts, theft of sensitive data visible to the user, and unauthorized actions performed on behalf of the user. This can result in loss of user trust, reputational damage, and potential regulatory issues if sensitive user information is compromised. The requirement for user interaction (pasting content) lowers the risk compared to a zero-click vulnerability, but the impact on an affected user can still be significant.
How an attack unfolds
An attacker first crafts a malicious HTML snippet containing attributes like `data-remote="true"` and `data-url="[attacker-controlled-script]"`. They then use social engineering tactics to persuade a user of a vulnerable Rails application to copy this snippet to their clipboard. The user, believing the content to be benign, then pastes it into a rich text editor or another `contenteditable` field within the application. The rails-ujs library, failing to sanitize the pasted content, processes these special `data-*` attributes, triggering the execution of the attacker's script in the user's browser. This script can then be used to steal session cookies, exfiltrate data from the page, or perform actions as the user.
How to fix it
To remediate this vulnerability, developers should update their Ruby on Rails applications to a version that includes the security patch. The fix was introduced in commit `5037a13614d71727af8a175063bcf6ba1a74bdbd`. Review your application's dependencies and update the `rails` gem to the latest secure version that incorporates this patch.
How to confirm the fix worked
To validate the vulnerability, set up a test environment with the application and create a page with a `contenteditable` element. Copy an HTML snippet like `<div data-remote="true" data-url="/some-endpoint" href="/some-endpoint">Test</div>` to your clipboard and paste it into the editable area. Monitor the browser's network requests. If a request is made to `/some-endpoint`, the application is vulnerable. A patched version should strip or neutralize these `data-*` attributes upon pasting, preventing the request. Ensure your application's `rails` version includes commit `5037a13614d71727af8a175063bcf6ba1a74bdbd` or a later fix.
Typical attack path
- An attacker crafts malicious HTML content containing special `data-*` attributes designed to execute code.
- The attacker uses a social engineering lure (e.g., a forum post, email, or chat message) to convince a target user to copy the malicious HTML snippet.
- The user navigates to a vulnerable Ruby on Rails application and pastes the content into a `contenteditable` field, such as a comment box or profile editor.
- The unsanitized content is processed by the rails-ujs library on the client-side.
- The malicious `data-*` attributes are triggered, causing arbitrary JavaScript to execute in the victim's browser within the security context of the application.
- The attacker's script steals the user's session token or performs other malicious actions.
How to detect it
Detecting exploitation of this DOM-based XSS is challenging as the initial attack occurs entirely within the user's browser. Server-side logs will not show the exploit itself. However, post-exploitation activity may be detectable. Analyze web server and WAF logs for unusual or anomalous requests originating from a legitimate user's session, such as rapid API calls or attempts to access endpoints inconsistent with normal user behavior. On the client side, EDR or proxy logs might show the compromised browser making outbound connections to unknown or malicious domains if the payload attempts to exfiltrate data.
What your security team should do
- Identify all applications using the Ruby on Rails framework and determine if they utilize the `rails-ujs` component with `contenteditable` fields.
- Prioritize patching for public-facing applications and applications that handle sensitive data, especially those with rich text editing features.
- Update affected applications to a version of Rails that incorporates the security fix from commit `5037a13614d71727af8a175063bcf6ba1a74bdbd`.
- As a defense-in-depth measure, review and strengthen your Content Security Policy (CSP) to restrict where scripts can be loaded from and executed, which can help mitigate the impact of XSS vulnerabilities.
The record
There is a potential DOM based cross-site scripting issue in rails-ujs which leverages the Clipboard API to target HTML elements that are assigned the contenteditable attribute. This has the potential to occur when pasting malicious HTML content from the clipboard that includes a data-method, data-remote or data-disable-with attribute.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| RubyGems | actionview | 5.1.0 | 6.1.7.3 |
| RubyGems | actionview | 7.0.0 | 7.0.4.3 |
| Debian:11 | rails | 0 | 2:6.0.3.7+dfsg-2+deb11u2 |
| Debian:12 | rails | 0 | 2:6.1.7.3+dfsg-1 |
| Debian:13 | rails | 0 | 2:6.1.7.3+dfsg-1 |
| SUSE:Linux Enterprise High Availability Extension 15 SP1 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| SUSE:Linux Enterprise High Availability Extension 15 SP2 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| SUSE:Linux Enterprise High Availability Extension 15 SP3 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| SUSE:Linux Enterprise High Availability Extension 15 SP4 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| SUSE:Linux Enterprise High Availability Extension 15 SP5 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| Ubuntu:20.04:LTS | rails | 0 | No fix |
| Ubuntu:22.04:LTS | rails | 0 | No fix |
| Ubuntu:24.04:LTS | rails | 0 | No fix |
| Ubuntu:24.10 | rails | 0 | No fix |
| Ubuntu:25.04 | rails | 0 | No fix |
| Ubuntu:25.10 | rails | 0 | No fix |
| Ubuntu:Pro:16.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:18.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | rails | 0 | No fix |
| Ubuntu:Pro:22.04:LTS | rails | 0 | No fix |
| gem | actionview | 5.1.0 | 6.1.7.3 |
| gem | actionview | 7.0.0 | 7.0.4.3 |
| openSUSE:Leap 15.4 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
| openSUSE:Leap 15.5 | rubygem-actionview-5_1 | 0 | 5.1.4-150000.3.9.1 |
Related vulnerabilities
- CVE-2022-27777 A XSS Vulnerability in Action View tag helpers >= 5.2.0 and < 5.2.0 which would allow an… Also affects actionview
- CVE-2016-0752 Directory traversal vulnerability in Action View in Ruby on Rails before 3.2.22.1, 4.0.x… Also affects actionview
- CVE-2025-55193 Active Record connects classes to relational database tables. Also affects rails
- CVE-2023-28120 There is a vulnerability in ActiveSupport if the new bytesplice method is called on a… Also affects rails
- CVE-2023-28362 The redirect_to method in Rails allows provided values to contain characters which are… Also affects rails
- CVE-2023-38037 ActiveSupport::EncryptedFile writes contents that will be encrypted to a temporary file. Also affects rails
- CVE-2024-54133 Action Pack is a framework for handling and responding to web requests. Also affects rails
- CVE-2024-47889 Action Mailer is a framework for designing email service layers. Also affects rails