Closes C3, and fixes a worse vector the finding did not describe.
The mail body is built by joining lines with \r\n and sent raw, so whatever
reaches it decides the wire format. The inspected domain lands in the subject;
event.details lands in the body with arbitrary keys and values.
Header injection — validatedHeaderValue refuses any value carrying a line
break, and send throws before assembling the message if the sender address,
the recipient list or the subject fails one. A bare CR or LF ends the header
line and whatever follows is read as further headers, so a domain carrying one
could add a Bcc the user never wrote.
Premature end of DATA — not in the original finding, and the more serious
of the two. A body line holding nothing but . ends the DATA command, after
which the remainder is read as SMTP commands. dotStuffed implements RFC 5321
§4.5.2 over the whole body.
Both are pure internal functions on a new SMTPMessage, because SMTPClient
is file-private and otherwise untestable.
At the sources, two different behaviours on purpose:
- The deep link refuses a value containing a control character. It is the only path into these values from outside the app, and a tainted domain travels on into tracked rows and from there into mail headers.
- Import strips and keeps the row. Refusing rows at restore would cost someone their watchlist over a hand-edited backup, which is an explicit anti-goal.
14 tests. One of them corrected my own first assertion: %0D is trimmed before
the refusal check runs, so a trailing break leaves a clean value and the link
is honoured — only an interior break survives trimming. The test now states
both halves rather than the false general claim.
156 tests, 0 failures on iOS 18.6 and iOS 27.0.
Noted, not fixed: DomainDataPortabilityService carries two byte-identical
copies of normalizeDomain, and both needed the same edit.