Rails Active Record: ANSI escape injection in Rails Active Record logging (CVE-2025-55193) #shorts
Summary
Host: Welcome to Secure Rails Today. In this episode, we spotlight CVE-2025-55193, an ANSI escape injection vulnerability discovered in Rails’ Active Record logging. This flaw could allow an attacker to embed control sequences in record IDs, altering or obfuscating terminal output when logs are printed directly to the console. Versions prior to 7.1.5.2, 7.2.2.2, and 8.0.2.1 are affected and have received patches.
Product details
Host: The issue resides in Ruby on Rails, specifically the Active Record component that maps Ruby classes to database tables. Affected releases include all Rails versions from initial releases up to 7.1.5.1, 7.2.0 through 7.2.2.1, and 8.0.0 through 8.0.2.0. The vulnerability was disclosed by GitHub’s security team on August 13, 2025, and fixed in the subsequent maintenance releases 7.1.5.2, 7.2.2.2, and 8.0.2.1.
Vulnerability type summary
Host: CVE-2025-55193 is classified under CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences. In simpler terms, Rails was logging untrusted input—record IDs—without sanitizing or escaping ANSI control sequences, enabling attackers to inject terminal commands or manipulate log appearance.
Details of the vulnerability
Host: Active Record’s find methods accept an ID parameter and log it when an entry is retrieved. If an attacker can influence that ID—through user input, malformed URLs, or malicious payloads—the unescaped ANSI sequences slip directly into the log output. On terminals that honor those sequences, this could change text color, move the cursor, hide text, or even replay earlier log lines. While it doesn’t execute arbitrary code on the server, it can conceal malicious activity, confuse operators, or trick automation that parses logs. The Rails team addressed this by escaping control characters before logging IDs in versions 7.1.5.2, 7.2.2.2, and 8.0.2.1.
Conclusion
Host: If you run any Rails app with Active Record logging to a terminal, update immediately to 7.1.5.2, 7.2.2.2, or 8.0.2.1. Review your logging pipeline and ensure you’re not exposing untrusted data directly to terminal output. Stay on the lookout for other control-sequence injection issues, and subscribe to security advisories for timely updates. Thanks for listening to Secure Rails Today—secure coding starts with vigilance.
Watch the full video on YouTube: CVE-2025-55193
Remediation and exploitation details
This chain involves the following actors
- Malicious User: Supplies crafted record identifiers containing escape codes
- Developer or System Administrator: Runs and maintains the web application and logging environment
This following systems are involved
- Rails Active Record (Maps application objects to database tables and logs queries): Logs incoming record identifiers without escaping special codes
- Terminal (Displays log output to administrator): Interprets and renders escape codes sent in log lines
Attack entry point
- Record lookup method: The method that looks up a record by identifier (for example, find or find_by) which writes the raw identifier into the log
Remediation actions
Exploitation actions
Inject escape sequences into a parameter used as a lookup key
- identifier = "[31mALERT![0m"
Invoke the lookup endpoint or console command that logs the identifier
- GET /users/\u001b[31mALERT!\u001b[0m
Write the malicious identifier directly to the log output
Render text color changes, clear lines, or disguise entries to hide real events
- Logs appear in red, or benign log lines are pushed off screen
Related Content
NOTE: The following related content has not been vetted and may be unsafe.
- https://github.com/rails/rails/security/advisories/GHSA-76r7-hhxj-r776
- https://github.com/rails/rails/commit/3beef20013736fd52c5dcfdf061f7999ba318290
- https://github.com/rails/rails/commit/568c0bc2f1e74c65d150a84b89a080949bf9eb9b
- https://github.com/rails/rails/commit/6a944ca4805e72050a0fbb1a461534eb760d3202
- [2025-08-20] Discussion on Rails CVE-2025-55193 and CVE-2025-24293 vulnerabilities.
- [2025-08-20] Discussion on ANSI escape injection vulnerability in Active Record logging with CVE-2025-55193.
- [2025-08-20] Exploring the impact of ANSI escape injection vulnerability CVE-2025-55193 in Rails after recent security patches.