Skip to content

cf-execd: dot-stuff mailed agent output lines starting with '.' - #6411

Open
Dhanu-dynamic wants to merge 1 commit into
cfengine:masterfrom
Dhanu-dynamic:execd-mail-dot-stuffing
Open

Dhanu-dynamic wants to merge 1 commit into
cfengine:masterfrom
Dhanu-dynamic:execd-mail-dot-stuffing

Conversation

@Dhanu-dynamic

Copy link
Copy Markdown
Contributor

MailResult() in cf-execd/cf-execd-runner.c writes each line of the agent output into the SMTP DATA section without the dot-stuffing RFC 5321 section 4.5.2 requires, so a line that is just "." (e.g. a continuation line of a multi-line report whose text comes from a file or command) ends the mail early and every line after it is read by the relay as an SMTP command in cf-execd's session. output carrying MAIL FROM / RCPT TO / DATA lines can therefore send an arbitrary message through the relay on behalf of the host, and lines that merely start with "." lose their first character. a leading "." is now doubled at the one place the body is written. the new acceptance test 25_cf-execd/mail_dot_line.cf reports "CorrectString1\n.\nCorrectString2": before the change the mock SMTP server receives the bare "." line, after it receives "..". the rest of 25_cf-execd passes locally (slow/dies_in_time.cf is timing-sensitive here and passes when run on its own, with or without the patch).

MailResult() copies each line of the agent output file into the SMTP
DATA section as is. RFC 5321, section 4.5.2 requires the client to
double a leading '.', because a line consisting of a single '.' marks
the end of the message.

Without it, a lone "." in the agent output, such as a continuation line
of a multi-line report whose text comes from a file or command, ends
the mail early. Every following output line is then read by the mail
server as an SMTP command in cf-execd's session, so output containing
e.g. "MAIL FROM:", "RCPT TO:" and "DATA" lines makes the relay send an
arbitrary message on behalf of the host. Lines that merely start with
'.' also lose their first character.

Send an extra '.' before any line that starts with '.'. The new
acceptance test fails before this change (the lone "." reaches the mock
SMTP server unescaped) and passes after it.

Changelog: Title
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
@CLAassistant

CLAassistant commented Oct 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@larsewi

larsewi commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants