CVE-2016-2338
Description
An exploitable heap overflow vulnerability exists in the Psych::Emitter start_document function of Ruby. In Psych::Emitter start_document function heap buffer "head" allocation is made based on tags array length. Specially constructed object passed as element of tags array can increase this array size after mentioned allocation and cause heap overflow.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A heap overflow in Ruby's Psych::Emitter start_document allows arbitrary code execution via a specially crafted YAML tags array.
Vulnerability
A heap buffer overflow vulnerability exists in the Psych::Emitter start_document function of Ruby versions 2.2.2 and 2.3.0 dev. The function allocates a heap buffer head based on the length of the tags array at line 166 using xcalloc. However, during the subsequent loop (lines 169-191), each element of the tags array is accessed and may be modified via Ruby object mutation (e.g., using a specially constructed object that increases the array size). This causes the loop to write beyond the originally allocated buffer [1].
Exploitation
An attacker must provide a specially crafted YAML tags array to the affected Ruby interpreter. The attacker controls the tags array passed to start_document. By including elements that are mutable objects (e.g., a custom Ruby object that modifies the tags array when accessed), the attacker can increase the array size after the initial allocation. This causes the loop to write to heap memory beyond the buffer, leading to heap overflow. The attack requires no authentication or special network position; it can be triggered by parsing attacker-supplied YAML [1].
Impact
Successful exploitation leads to a heap buffer overflow, which can corrupt adjacent heap memory. This can potentially allow an attacker to achieve arbitrary code execution with the privileges of the Ruby process. The primary impact is on the integrity and availability of the system, and may lead to information disclosure or complete compromise [1].
Mitigation
Ruby released a fix for this vulnerability. Users should upgrade to Ruby versions later than 2.2.2 and 2.3.0. The fix was included in Ruby 2.2.3, 2.3.1, and later releases. No workaround is available. The vulnerability is not listed on CISA's Known Exploited Vulnerabilities catalog [1].
AI Insight generated on May 26, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2- Ruby/Psych::Emitter start_document functiondescription
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
3News mentions
0No linked articles in our index yet.