Heap-buffer-overflow in mruby

mruby Updated 02 Oct 2025

Summary

19/09/2023
MEDIUM
Yes i
Medium
Not published

OSV-2023-881: Heap-buffer-overflow in read_tmpl. Affects mruby versions >= 1e1184f62d4b530061c33341f297c017851d28f7, < 393aaada64a7ec77313ef2516fce1c2052b547c8. Fixed in 393aaada64a7ec77313ef2516fce1c2052b547c8. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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 mruby is a heap-buffer-overflow issue that can lead to a crash when reading a template file.

Vulnerability Detail

The vulnerability occurs in the read_tmpl function of mruby. It is triggered by a heap-buffer-overflow when attempting to read data from a template file. This can result in a crash and potentially allow an attacker to execute arbitrary code or cause a denial-of-service. The vulnerability was discovered through the OSS-Fuzz project.

How To Fix

Minimum fixed version

393aaada64a7ec77313ef2516fce1c2052b547c8

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

If updating mruby is not immediately feasible, a possible workaround is to implement input validation and bounds checking when reading template files. This can help mitigate the risk of a heap-buffer-overflow. Here is an example of how to perform input validation in Ruby:

def read_tmpl(file)
  # Perform input validation
  raise 'Invalid file' unless File.exist?(file)
  raise 'Invalid file type' unless File.file?(file)

  # Read template file
  data = File.read(file)

  # Process template data
  # ...
end

Conclusion

The heap-buffer-overflow vulnerability in mruby can be resolved by updating to a version that includes the fix. If immediate updating is not possible, implementing input validation and bounds checking can provide a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mruby →

Share this vulnerability

FAQ

mruby is a lightweight implementation of the Ruby programming language designed to be embedded in other applications.

The vulnerability occurs when reading a template file, leading to a heap-buffer-overflow.

The vulnerability can result in a crash and potentially allow an attacker to execute arbitrary code or cause a denial-of-service.

To fix the vulnerability, update mruby to a version that includes the fix.

If updating mruby is not immediately feasible, implementing input validation and bounds checking when reading template files can help mitigate the risk.

Related vulnerabilities

Recent vulnerabilities recorded for mruby.

How To Fix

Minimum fixed version

393aaada64a7ec77313ef2516fce1c2052b547c8

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