Heap-buffer-overflow in heredoc_remove_indent in mruby

mruby Updated 02 Oct 2025

Summary

14/02/2021
MEDIUM
Yes i
Medium
Not published

OSV-2021-392: Heap-buffer-overflow in heredoc_remove_indent. Affects mruby versions >= 0d22e11b757c6fe9b30e55cb7d83ab7421575968, < 94fb86f89b131814201596d301f584dfe4547526. Fixed in 94fb86f89b131814201596d301f584dfe4547526. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

mruby is an open-source lightweight implementation of the Ruby programming language. It is designed to be embedded in other applications to provide scripting capabilities. The vulnerability in question, identified as OSV-2021-392, is a heap-buffer-overflow that occurs in the heredoc_remove_indent function of mruby. This function is responsible for removing indentation from heredoc strings. The vulnerability can be triggered when parsing a string, leading to a heap-buffer-overflow read. The issue was reported through the OSS-Fuzz project.

Vulnerability Detail

The heap-buffer-overflow vulnerability in heredoc_remove_indent can potentially be exploited by an attacker to read beyond the bounds of a heap buffer. This can result in the disclosure of sensitive information or the execution of arbitrary code. The vulnerability is considered to have a medium severity level. The crash state indicates that the issue occurs during the parsing of a string, specifically in the parser_yylex function. The vulnerability was introduced in commit 0d22e11b757c6fe9b30e55cb7d83ab7421575968 and fixed in commit 94fb86f89b131814201596d301f584dfe4547526.

How To Fix

Minimum fixed version

94fb86f89b131814201596d301f584dfe4547526

This is the first release that contains the fix.

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

Workaround

As a temporary workaround, developers can avoid using heredoc strings in their code or ensure that the strings do not trigger the vulnerable code path. This can be achieved by modifying the indentation of the heredoc strings or using alternative string formatting methods.

Conclusion

In conclusion, the mruby package is affected by a heap-buffer-overflow vulnerability in the heredoc_remove_indent function. This vulnerability can be exploited to read beyond the bounds of a heap buffer, potentially leading to the disclosure of sensitive information or the execution of arbitrary code. It is recommended to update the package to a version that includes the fix commit 94fb86f89b131814201596d301f584dfe4547526. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mruby →

Share this vulnerability

FAQ

mruby is an open-source lightweight implementation of the Ruby programming language that can be embedded in other applications.

A heap-buffer-overflow vulnerability occurs when a program reads or writes data beyond the bounds of a heap buffer, potentially leading to information disclosure or arbitrary code execution.

An attacker can exploit this vulnerability by crafting a malicious input that triggers the vulnerable code path, causing a heap-buffer-overflow read.

This vulnerability is considered to have a medium severity level.

To fix this vulnerability, update the mruby package to a version that includes the fix commit 94fb86f89b131814201596d301f584dfe4547526.

Related vulnerabilities

Recent vulnerabilities recorded for mruby.

How To Fix

Minimum fixed version

94fb86f89b131814201596d301f584dfe4547526

This is the first release that contains the fix.

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