REXML XML Round-Trip Issue in Ruby Package - CVE-2021-28965

ruby Updated 02 Oct 2025

Summary

21/04/2021
N/A
Yes i
High
7.5

ALPINE-CVE-2021-28965: The REXML gem before 3.2.5 in Ruby before 2.6.7, 2.7.x before 2.7.3, and 3.x before 3.0.1 does not properly address XML round-trip issues. Affects ruby versions < 2.5.9-r0. Fixed in 2.5.9-r0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Ruby is a dynamic, open-source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. The REXML gem is a part of Ruby's standard library, providing tools for parsing and manipulating XML documents. However, prior versions of REXML have been found to have vulnerabilities that can lead to incorrect XML document generation after parsing and serialization.

Vulnerability Detail

The vulnerability identified as CVE-2021-28965 affects the REXML gem in Ruby versions prior to 2.6.7, 2.7.x before 2.7.3, and 3.x before 3.0.1. This issue arises from improper handling of XML round-trip processes, which can result in the generation of incorrect XML documents. The ramifications of this vulnerability include potential data integrity issues, as malformed XML documents may lead to unexpected behavior in applications that rely on accurate XML parsing and serialization.

How To Fix

Minimum fixed version

2.5.9-r0

This is the first release that contains the fix.

sudo apk add --upgrade ruby

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can avoid using the REXML gem for XML parsing and serialization until the package is updated. Alternatively, consider using other XML processing libraries that do not exhibit this vulnerability.

Conclusion

CVE-2021-28965 presents a significant risk to applications using vulnerable versions of the REXML gem in Ruby. It is crucial for developers to update their Ruby packages to the patched versions to mitigate potential data integrity issues. Utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for ruby →

Share this vulnerability

FAQ

CVE-2021-28965 is a vulnerability in the REXML gem of Ruby that can lead to incorrect XML document generation due to improper handling of XML round-trip processes.

Ruby versions before 2.6.7, 2.7.x before 2.7.3, and 3.x before 3.0.1 are affected by this vulnerability.

The primary risk is the generation of malformed XML documents, which can lead to data integrity issues and unexpected behavior in applications relying on accurate XML processing.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score of CVE-2021-28965 is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for ruby.

How To Fix

Minimum fixed version

2.5.9-r0

This is the first release that contains the fix.

sudo apk add --upgrade ruby

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback