Overview
Recently, NSFOCUS CERT monitored a security advisory released by Ruby patching a remote code execution vulnerability (CVE-2026-132825), dubbed “Ruby2Shell”. When Ruby performs case conversion on strings encoded in certain single-byte encodings such as ISO-8859-1 and Windows-1252, output buffer boundary checks fail to cover the actual write length. An attacker can trick an application into performing case conversion on a specially crafted string, triggering a heap buffer overflow that can lead to remote code execution under specific conditions. With a CVSS score of 7.4, affected users are urged to take protective measures as soon as possible.
Reference Links:
https://github.com/ruby/ruby/security/advisories/GHSA-34m4-m9fh-gqp5
https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string
Scope of Impact
Affected Versions
- 2.4.0 <= Ruby <= 3.3.13
- 3.4.0 <= Ruby <= 3.4.12
- 4.0.0 <= Ruby <= 4.0.9
Note: This vulnerability is only triggered when performing case conversion on strings encoded in certain single-byte encodings such as ISO-8859-1 or Windows-1252; UTF-8 strings are not affected. Rails and classic-mode Sinatra applications are known to be affected under default configurations. Ruby 3.2 and earlier versions are officially End-of-Life (EOL).
Unaffected Versions
- Ruby 3.3.x >= 3.3.14
- Ruby 3.4.x >= 3.4.13
- Ruby 4.0.x >= 4.0.10
Detection
Manual Detection
Users can determine whether their current application falls within the affected scope by checking the Ruby version and encoding conversion behavior:
1. Check the current Ruby version:
| ruby -v |
2. Confirm whether the application uses Rails or classic-mode Sinatra by running the following command in the project root directory and the active Bundle environment:
| bundle list | grep -E ‘rails|sinatra’ |
3. Search the codebase for case conversion calls on single-byte encoded strings:
| # Search business logic and key dependencies for single-byte encoding (e.g., ISO-8859-1, Windows-1252) settings or conversion logic: grep -rniE ‘(iso[-]8859[-][0-9]+|windows[-_]125[0-8]|cp125[0-8]|force_encoding\b|\.encode\b|encoding:)’ –include=’*.rb’ . # Search for case conversion and case-insensitive comparison calls: grep -rnE ‘\.(upcase!?|downcase!?|capitalize!?|swapcase!?|casecmp\??)([^a-zA-Z0-9_]|$)’ –include=’*.rb’ . |
If the current Ruby version is within the affected range and the application runs Rails or classic-mode Sinatra in default configurations—or performs case conversion on single-byte encoded strings such as ISO-8859-1 or Windows-1252—a security risk may exist.
Mitigation
Official Upgrade
The vendor has released updated versions to fix this vulnerability. Affected users are advised to upgrade promptly. Download link: https://www.ruby-lang.org/en/downloads/
Note: Users running custom-built software with embedded Ruby or OS distribution packages should install the patched versions released by the corresponding vendors.
Temporary Mitigations
Without impacting normal business operations, users can apply the following temporary mitigation measures:
Avoid performing case conversion directly on untrusted input, or strictly validate and filter input string lengths and encodings. If business logic relies on affected single-byte encodings such as ISO-8859-1 or Windows-1252, convert strings to an unaffected encoding such as UTF-8 prior to sensitive processing paths.
Statement
This advisory is only used to describe a potential risk. NSFOCUS does not provide any commitment or promise on this advisory. NSFOCUS and the author will not bear any liability for any direct and/or indirect consequences and losses caused by transmitting and/or using this advisory. NSFOCUS reserves all the rights to modify and interpret this advisory. Please include this statement paragraph when reproducing or transferring this advisory. Do not modify this advisory, add/delete any information to/from it, or use this advisory for commercial purposes without permission from NSFOCUS.
About NSFOCUS
NSFOCUS, a pioneering leader in cybersecurity, is dedicated to safeguarding telecommunications, Internet service providers, hosting providers, and enterprises from sophisticated cyberattacks.
Founded in 2000, NSFOCUS operates globally with over 3000 employees at two headquarters in Beijing, China, and Santa Clara, CA, USA, and over 50 offices worldwide. It has a proven track record of protecting over 25% of the Fortune Global 500 companies, including four of the five largest banks and six of the world’s top ten telecommunications companies.
Leveraging technical prowess and innovation, NSFOCUS delivers a comprehensive suite of security solutions, including the Intelligent Security Operations Platform (ISOP) for modern SOC, DDoS Protection, Continuous Threat Exposure Management (CTEM) Service and Web Application and API Protection (WAAP). All the solutions and services are augmented by the Security Large Language Model (SecLLM), ML, patented algorithms and other cutting-edge research achievements developed by NSFOCUS.