Skip to content

Fix Sender.Email leaking mailbox-owner address when authoritative sender properties are absent#515

Merged
Sicos1977 merged 1 commit into
Sicos1977:masterfrom
tariqgitspace:fix/sender-email-recipient-leak
Jun 2, 2026
Merged

Fix Sender.Email leaking mailbox-owner address when authoritative sender properties are absent#515
Sicos1977 merged 1 commit into
Sicos1977:masterfrom
tariqgitspace:fix/sender-email-recipient-leak

Conversation

@tariqgitspace

Copy link
Copy Markdown

Problem

When a .msg file is saved from a recipient's mailbox (rather than the original sender's Sent Items), the authoritative MAPI sender properties

  • PR_SENDER_EMAIL_ADDRESS (0x0C1F)
  • PR_SENDER_SMTP_ADDRESS (0x5D01)

are often absent. SetEmailSenderAndRepresentingSender then falls through to non-authoritative sources:

  • PR_SENDER_SMTP_ADDRESS_ALTERNATE (0x6512)
  • InternetAccountName
  • PR_PRIMARY_SEND_ACCT (0x0E28)

On items saved by Outlook from a recipient's mailbox, those fields are often populated with the mailbox owner's own SMTP address rather than the real sender's. The observable result is:

  • Sender.DisplayName is correct (from PR_SENDER_NAME) — shows the real sender's name.
  • Sender.Email is wrong — it contains the mailbox owner's SMTP address, i.e. one of the message's recipients.

This is misleading and causes downstream consumers to attribute the message to the wrong party.

Fix

  1. Track whether the resolved sender email came from an authoritative property (PR_SENDER_EMAIL_ADDRESS or PR_SENDER_SMTP_ADDRESS) via a new local flag senderEmailIsAuthoritative.

  2. Just before constructing the Sender object, if the email is not authoritative and matches the SMTP address of any entry in _recipients (OrdinalIgnoreCase), clear it. DisplayName is preserved, so consumers still see the real sender's name; only the misleading mailbox-owner address is suppressed.

Why this is safe

The guard is intentionally narrow — it only fires when both:

  • the fallback path was used (no authoritative sender property was present), and
  • the resolved address actually collides with a known recipient on the message.

Messages with correctly-populated PR_SENDER_EMAIL_ADDRESS / PR_SENDER_SMTP_ADDRESS are completely unaffected, as are fallback-resolved addresses that don't collide with any recipient.

Scope

  • Single file changed: MsgReader/Outlook/Message.cs
  • No public API change.
  • Logger.WriteToLog emits one line when the guard fires, to aid diagnosis.
  • No unit test added — hand-crafting a synthetic CFB .msg to exercise this property combination is non-trivial; happy to add one if a recommended approach exists in the repo.

…der properties are absent

When a .msg file is saved from a recipient's mailbox (rather than the original sender's
Sent Items), the authoritative sender properties PR_SENDER_EMAIL_ADDRESS (0x0C1F) and
PR_SENDER_SMTP_ADDRESS (0x5D01) are often absent. The existing fallback chain in
SetEmailSenderAndRepresentingSender then falls through to non-authoritative sources:

  - PR_SENDER_SMTP_ADDRESS_ALTERNATE (0x6512)
  - InternetAccountName
  - PR_PRIMARY_SEND_ACCT (0x0E28)

On items saved by Outlook from a recipient's mailbox these fields can be populated with
the mailbox owner's own SMTP address rather than the real sender's. The result is that
Sender.DisplayName correctly shows the real sender (from PR_SENDER_NAME) while
Sender.Email reports the mailbox owner's address — i.e., one of the recipients of the
message. This is misleading and can cause downstream consumers to attribute the message
to the wrong party.

Fix:

  1. Track whether the resolved sender email came from an authoritative property
     (PR_SENDER_EMAIL_ADDRESS or PR_SENDER_SMTP_ADDRESS) via a new local flag
     `senderEmailIsAuthoritative`.

  2. Just before constructing the Sender object, if the email is NOT authoritative and
     matches the SMTP address of any entry in `_recipients` (OrdinalIgnoreCase),
     clear it. DisplayName is preserved, so consumers still see the real sender's name
     (typically from PR_SENDER_NAME), but the misleading mailbox-owner address is no
     longer reported as the sender's email.

The guard is intentionally narrow: it only fires when (a) the fallback path was used
AND (b) the resolved address actually collides with a known recipient — so messages with
correctly-populated authoritative properties, or fallback-resolved addresses that don't
match a recipient, are unaffected.

No public API change. Logger.WriteToLog emits a single line when the guard fires, to aid
diagnosis.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tariqgitspace tariqgitspace force-pushed the fix/sender-email-recipient-leak branch from 165556e to 45fc9bd Compare May 31, 2026 00:13
@Sicos1977 Sicos1977 merged commit 9c83b21 into Sicos1977:master Jun 2, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants