isAllowedImapPort (email/imap-safety.ts)

nextcrm-app · lib/email/imap-safety.ts · typescript · MIT
email

Safety helpers for user-supplied IMAP/SMTP connection details. Motivation (GHSA-f5r5-f2v5-74ww follow-up): the email-account actions let any authenticated user open a TCP connection to an arbitrary host:port and, on failure, reflected the raw driver error back to the caller. That

// Source: https://github.com/pdovhomilja/nextcrm-app | License: MIT | Copyright 2023 Pavel Dovhomilja
// Provided via justclaw.it.com; keep this notice with the code.
// Safety helpers for user-supplied IMAP/SMTP connection details.
//
// Motivation (GHSA-f5r5-f2v5-74ww follow-up): the email-account actions let any
// authenticated user open a TCP connection to an arbitrary host:port and, on
// failure, reflected the raw driver error back to the caller. That turned the
// "test connection" / "discover folders" features into a non-blind internal
// port scanner (Postgres 5432, MinIO 9000/9001, Inngest 8288, cloud metadata,
// …) and a service-fingerprinting oracle via leaked protocol/banner text.
//
// This module provides two of the mitigations that need no network work:
//   1. a port al

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key