/

CVE-2026-41113

Severity:

HIGH RISK

(8.1)

OS Command Injection in sagredo qmail notlshosts_auto

CVE-2026-41113

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution on Mail Server

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

sagredo qmail before 2026.04.07 contains an OS command injection vulnerability in the notlshosts_auto handling within qmail-remote.c, where user-controlled data is passed to popen() without proper sanitization.

A remote attacker who can influence TLS-related parameters (such as those used when tls_quit is triggered) may execute arbitrary commands on the mail server under the privileges of the qmail-remote process.

Affected context

The vulnerability occurs within sagredo qmail's remote delivery component (qmail-remote.c), specifically in the logic around notlshosts_auto and TLS negotiation behavior.

It is exposed when the software constructs shell commands that are executed via popen() and incorporates data that can be influenced by remote input (for example, hostnames or connection parameters evaluated when TLS is disabled or when tls_quit is processed).

Deployments that use sagredo qmail versions prior to 2026.04.07 and rely on TLS-related host handling are more likely to be affected, especially where external, potentially untrusted SMTP peers can control portions of the values fed into notlshosts_auto.

Exploit preconditions

  • Attack surface: SMTP service exposed to remote systems (e.g., Internet-facing mail server).
  • Required access: Ability to establish an SMTP connection and influence the data processed by qmail-remote during TLS-related decision paths (such as hostnames or parameters that flow into notlshosts_auto).
  • Trigger point: Execution of popen() in notlshosts_auto logic when handling tls_quit or related TLS configuration conditions.
  • Why exploitation is possible: Data derived directly or indirectly from the remote peer is concatenated or interpolated into a shell command string executed by popen() without robust validation, escaping, or avoidance of shell interpretation, enabling injection of arbitrary shell metacharacters and commands.

Why this happens

This issue stems from constructing shell commands that include attacker-controlled or attacker-influenceable data and then executing those commands via popen() in qmail-remote.c.

The pattern maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the program relies on the shell to interpret a command line and fails to neutralize metacharacters such as ;, |, &, or backticks.

Instead of using safer APIs that pass arguments directly to the OS without invoking a shell, the code delegates parsing to the shell, turning crafted input into executable logic whenever TLS-related functions like notlshosts_auto are invoked.

Potential impact

  • Remote execution of arbitrary shell commands with the privileges of the qmail-remote process.
  • Full compromise of the affected mail server, including reading or tampering with email in transit as accessible to that component.
  • Abuse of the mail server as a platform for further lateral movement within the network.
  • Use of the compromised host as a spam relay or part of a botnet, damaging reputation and potentially triggering blacklisting.
  • Modification or disruption of outbound mail delivery, resulting in denial of service for legitimate email traffic.

General mitigation guidance

Effective mitigation focuses on eliminating shell-based command construction and reducing trust in remotely influenced input:

  • Prefer APIs that do not invoke a shell (e.g., direct exec-style calls with argument vectors or library calls) instead of popen() with a string command.
  • Avoid embedding hostnames, TLS parameters, or other data derived from remote SMTP peers directly into shell commands; if external tools must be called, pass such data as safely encoded arguments.
  • Apply strict validation and canonicalization to any configuration or runtime values used by notlshosts_auto, limiting them to well-defined character sets (such as alphanumeric, dot, and dash for hostnames).
  • Run the mail delivery components with the least privileges necessary and segregate them into dedicated OS users or containers to limit blast radius if compromise occurs.
  • Prefer secure-by-design configurations that do not depend on external shell commands for TLS or host classification logic where feasible.

How teams detect issues like this

Detection often combines code-centric review with runtime monitoring:

  • Static analysis: Configure static analysis or grep-based checks to flag uses of popen(), system(), or similar functions where arguments are built from variables tied to network input, environment variables, or configuration files.
  • Code review signals: During manual review, treat any shell command construction in qmail-remote.c or related TLS/host handling code as high risk, especially where string concatenation or formatting is used to create command lines.
  • Policy enforcement: Introduce secure coding policies that prohibit shell execution with untrusted input and require justification and peer review for any remaining popen() usage.
  • Runtime and log analysis: Monitor SMTP logs and system audit logs for anomalous command invocations originating from qmail processes, unexpected child process trees, or spikes in outbound connections that could signal exploitation attempts.

Sources

SourceLink
blog.calif.ioblog.calif.io/p/we-asked-claude-to-audit-sagredos
github.comgithub.com/califio/publications/tree/main/MADBugs/qmail
github.comgithub.com/sagredo-dev/qmail/commit/749f607f6885e3d01b36f2647d7a1db88f1ef741
github.comgithub.com/sagredo-dev/qmail/pull/42
github.comgithub.com/sagredo-dev/qmail/releases/tag/v2026.04.07
openwall.comopenwall.com/lists/oss-security/2026/04/18/5

Frequently asked

questions

Yes. An external attacker who can connect to the SMTP service and influence values processed by qmail-remote in the notlshosts_auto path may be able to trigger command execution without local access.

The attacker typically only needs the ability to act as a remote SMTP peer. They do not require shell access or valid mailbox credentials, but they must be able to control or influence the data that flows into the vulnerable popen() call.

The safest pattern is to remove reliance on shell command execution for TLS/host handling logic: replace popen() with safer, non-shell APIs or native library calls, and ensure that any remaining external command invocations do not include unsanitized, attacker-controlled content.

Adopt a defensive coding strategy that bans or strongly restricts shell invocation with dynamic strings, integrates static analysis rules for command execution functions, and enforces rigorous code review for any code paths that combine external input with system-level operations.

Find out what's already
exploitable in your codebase.