diff --git a/src/lib/__tests__/mdn-header-injection.test.ts b/src/lib/__tests__/mdn-header-injection.test.ts new file mode 100644 index 00000000..40f8f132 --- /dev/null +++ b/src/lib/__tests__/mdn-header-injection.test.ts @@ -0,0 +1,199 @@ +import { describe, it, expect } from 'vitest'; +import { buildMdnMessage } from '../mdn'; + +// GHSA-w38p-hpqv-g89c: every value that lands in a header of the read receipt +// originates with the sender of the message being answered, and Stalwart hands +// it back already RFC 2047-decoded. A bare CRLF smuggled inside an encoded-word +// used to be interpolated verbatim into the Subject: line, letting the sender +// append From/Reply-To/Content-Type headers and a body to a message the +// user's own account files into Sent and submits. + +const base = { + to: 'sender@other.com', + fromEmail: 'me@example.com', + originalMessageId: 'orig@other.com', +}; + +// The decoded subject from the advisory's proof of concept. +const INJECTED_SUBJECT = + 'Invoice\r\nFrom: IT Helpdesk \r\nReply-To: attacker@evil.test\r\n' + + 'Content-Type: text/html; charset=utf-8\r\n\r\n

Forged