Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(smtp): pin resolved IP to prevent DNS rebinding (TOCTOU)
Use the pre-resolved IP from validateDatabaseHost instead of the
original hostname when creating the nodemailer transporter. Set
servername to the original hostname to preserve TLS SNI validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
waleedlatif1 and claude committed Mar 28, 2026
commit 4c0aa7acde4de8e24f47439436a65d058cc5671d
19 changes: 10 additions & 9 deletions apps/sim/app/api/tools/smtp/send/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,23 @@ export async function POST(request: NextRequest) {
secure: validatedData.smtpSecure,
})

// Use the pre-resolved IP to prevent DNS rebinding attacks (TOCTOU).
// Set servername to the original hostname for correct TLS SNI/certificate validation.
const resolvedHost = hostValidation.resolvedIP ?? validatedData.smtpHost
const tlsOptions =
validatedData.smtpSecure === 'None'
? { rejectUnauthorized: false, servername: validatedData.smtpHost }
: { rejectUnauthorized: true, servername: validatedData.smtpHost }

const transporter = nodemailer.createTransport({
host: validatedData.smtpHost,
host: resolvedHost,
port: validatedData.smtpPort,
secure: validatedData.smtpSecure === 'SSL',
auth: {
user: validatedData.smtpUsername,
pass: validatedData.smtpPassword,
},
tls:
validatedData.smtpSecure === 'None'
? {
rejectUnauthorized: false,
}
: {
rejectUnauthorized: true,
},
tls: tlsOptions,
})

const contentType = validatedData.contentType || 'text'
Expand Down
Loading