Directory Traversal Vulnerability in Ruby Mail Package

ruby-mail Updated 02 Oct 2025

Summary

18/07/2012
N/A
Yes i
Unrated
Not published

CVE-2012-2139: Directory traversal vulnerability in lib/mail/network/delivery_methods/file_delivery.rb in the Mail gem before 2.4.4 for Ruby allows remote attackers to read arbitrary files via a .. Affects ruby-mail versions < 2.4.4-1. Fixed in 2.4.4-1. 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The Ruby Mail package is a popular library used for handling email delivery in Ruby applications. It provides a simple interface for composing and sending emails, supporting various delivery methods. However, prior to version 2.4.4, the Mail gem contained a directory traversal vulnerability that allowed attackers to exploit the 'to' parameter to read arbitrary files on the server. This vulnerability poses a significant risk to applications that utilize this package, especially if they handle user input without proper validation.

Vulnerability Detail

The vulnerability, identified as CVE-2012-2139, originates from a flaw in the file_delivery.rb component of the Mail gem. It allows remote attackers to manipulate the 'to' parameter by including a '..' (dot dot) sequence, which can traverse the directory structure of the server. This can lead to unauthorized access to sensitive files, potentially exposing configuration files, user data, or other critical information. The vulnerability affects multiple Debian ecosystems, including versions 11, 12, and 13, and was fixed in version 2.4.4-1.

How To Fix

Minimum fixed version

2.4.4-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade ruby-mail

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

Workaround

If immediate updating is not feasible, a temporary workaround is to implement input validation on the 'to' parameter to prevent the inclusion of '..' sequences. This can be done by sanitizing user input before processing it. For example, you can use the following Ruby code snippet to validate the input:

if params[:to].include?('..') raise 'Invalid email address' end

Conclusion

The directory traversal vulnerability in the Ruby Mail package poses a significant risk to applications using this library. It is crucial to update to version 2.4.4-1 or later to mitigate this risk. Implementing input validation can serve as a temporary workaround until the update can be applied. Regular monitoring for vulnerabilities, such as through tools like Vulert, can help maintain the security of your applications.

See every vulnerability recorded for ruby-mail →

Share this vulnerability

FAQ

CVE-2012-2139 is a directory traversal vulnerability found in the Ruby Mail package that allows attackers to read arbitrary files on the server.

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

Versions of the Ruby Mail package prior to 2.4.4 are affected by this vulnerability across multiple Debian ecosystems.

If you cannot update the package, implement input validation on the 'to' parameter to prevent directory traversal attacks as a temporary measure.

Yes, if exploited, this vulnerability can lead to unauthorized access to sensitive files, potentially exposing critical information.

Related vulnerabilities

Recent vulnerabilities recorded for ruby-mail.

How To Fix

Minimum fixed version

2.4.4-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade ruby-mail

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