SMTP Command Injection Vulnerability in Ruby Mail Package

ruby-mail Updated 02 Oct 2025

Summary

12/06/2017
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2015-9097: The mail gem before 2.5.5 for Ruby (aka A Really Ruby Mail Library) is vulnerable to SMTP command injection via CRLF sequences in a RCPT TO or MAIL FROM command, as demonstrated by CRLF sequences immediately before and a... Affects ruby-mail versions < 2.6.1+dfsg1-1. Fixed in 2.6.1+dfsg1-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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

The Ruby Mail package is a widely used library in Ruby applications that facilitates the sending and receiving of emails. It provides a simple interface for constructing and sending email messages, handling attachments, and managing email protocols. However, prior to version 2.5.5, the Ruby Mail package is susceptible to a critical vulnerability that allows attackers to exploit SMTP commands, potentially compromising the integrity of email communications.

Vulnerability Detail

The vulnerability arises from improper handling of CRLF (Carriage Return Line Feed) sequences in SMTP commands, specifically within the RCPT TO or MAIL FROM commands. This flaw enables attackers to inject arbitrary SMTP commands, leading to unauthorized actions such as email spoofing or message manipulation. The vulnerability was identified in versions of the Ruby Mail package before 2.5.5, and it poses significant risks to applications relying on this library for email functionalities.

How To Fix

Minimum fixed version

2.6.1+dfsg1-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

As a temporary measure, you can sanitize input to the RCPT TO and MAIL FROM commands by stripping out any CRLF sequences before processing. This can be done using the following Ruby code snippet:

def sanitize_smtp_command(command)
  command.gsub(/\r\n/, '')
end

This function will help mitigate the risk until the package is updated.

Conclusion

The Ruby Mail package has a critical vulnerability that allows SMTP command injection through improper handling of CRLF sequences. It is crucial to update to the patched version to safeguard your applications from potential exploits. Additionally, implementing input sanitization can provide a temporary solution until the update is applied.

See every vulnerability recorded for ruby-mail →

Share this vulnerability

FAQ

Ruby Mail is a library that allows Ruby applications to send and receive emails easily, providing functionalities for constructing messages and managing email protocols.

The vulnerability allows attackers to inject arbitrary SMTP commands through CRLF sequences, potentially leading to email spoofing and manipulation.

You can use the Vulert platform to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected without needing to sign up.

Failing to address this vulnerability can lead to unauthorized email actions, data breaches, and damage to your application's reputation.

Yes, you can sanitize SMTP commands by removing CRLF sequences from user inputs as a temporary workaround until the package is updated.

Related vulnerabilities

Recent vulnerabilities recorded for ruby-mail.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

2.6.1+dfsg1-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