PT-2021-5297 · Ruby+4 · Ruby+4

Chamal

·

Published

2021-11-25

·

Updated

2025-12-12

·

CVE-2021-41816

CVSS v2.0

10

Critical

VectorAV:N/AC:L/Au:N/C:C/I:C/A:C
Name of the Vulnerable Software and Affected Versions Ruby versions prior to 2.7.5 Ruby versions 3.x prior to 3.0.3 CGI gem versions prior to 0.3.1
Description The issue is caused by an integer overflow and resultant buffer overflow in the CGI.escape html function when a long string is passed to it on platforms where size t and long have different numbers of bytes, such as Windows. This can lead to a buffer overrun when a user passes a very large string to CGI.escape html. The exploitation of this issue may allow a remote attacker to execute arbitrary code in the target system.
Recommendations For Ruby versions prior to 2.7.5, update to version 2.7.5 or later. For Ruby versions 3.x prior to 3.0.3, update to version 3.0.3 or later. For CGI gem versions prior to 0.3.1, update to version 0.3.1 or later. As a temporary workaround, consider restricting the input size to CGI.escape html to prevent buffer overflows until a patch is applied.

Exploit

Fix

Buffer Overflow

Integer Overflow

Weakness Enumeration

Related Identifiers

BDU:2021-06123
CVE-2021-41816
DSA-5067-1
GHSA-5CQM-CRXM-6QPV
MGASA-2021-0579
OPENSUSE-SU-2024:11657-1
OPENSUSE-SU-2024:11658-1
OPENSUSE-SU-2024:11786-1
OPENSUSE-SU-2024:12712-1
OPENSUSE-SU-2024:13623-1
OPENSUSE-SU-2025:14621-1
OPENSUSE-SU-2025:15819-1
RHSA-2022:6855
RHSA-2022:6856
USN-5235-1

Affected Products

Cgi Gem
Linuxmint
Red Os
Ruby
Ubuntu