Skip to main content

5. Security Considerations

Care must be taken when displaying messages on a terminal or terminal emulator. Powerful terminals may act on escape sequences and other combinations of US-ASCII control characters with a variety of consequences. They can remap the keyboard or permit other modifications to the terminal which can lead to denial of service or even damaged data. They can trigger (sometimes programmable) answerback messages that can allow messages to be sent under the guise of the recipient. They can also effect the operation of other devices attached to the terminal (such as printers).

Message viewers may wish to remove potentially dangerous terminal escape sequences from a message prior to display. However, other escape sequences appear in messages for useful purposes (see ISO 2022, RFC 2045, RFC 2046, RFC 2047, RFC 2049, RFC 4288, RFC 4289), and therefore should not be removed indiscriminately.

Primary Security Concerns

1. Terminal Escape Sequence Attacks

Threat: Malicious escape sequences can control terminal behavior

Risks:

  • Keyboard remapping
  • Terminal settings modification
  • Automatic command execution
  • Impact on connected devices (e.g., printers)

Mitigation:

  • Filter dangerous escape sequences before display
  • Preserve legitimate escape sequences (e.g., ISO 2022, MIME encoding)
  • Use sandboxed or restricted display environments
Dangerous examples:
ESC]0;Malicious TitleBEL → Modify terminal title
ESC[2J → Clear screen
Specific control sequences → Keyboard remapping

2. Non-Text Object Transmission

The transmission of non-text objects in messages raises additional security issues. These issues are discussed in RFC 2045, RFC 2046, RFC 2047, RFC 2049, RFC 4288, and RFC 4289.

MIME-related risks:

  • Executable attachments
  • Script injection
  • Buffer overflows
  • Malicious content types

3. Bcc Field Information Disclosure

Many implementations use the "Bcc:" (blind carbon copy) field described in Section 3.6.3 to facilitate sending messages to recipients without revealing the addresses of one or more of the addressees to the other recipients. Mishandling of this use of "Bcc:" has the potential to reveal confidential information which can lead to security problems through knowledge of even the existence of a particular email address.

Scenario 1: Removing Bcc Line

If the first method described in Section 3.6.3 is used, where the "Bcc:" line is removed from the message, blind copy recipients have no explicit indication that they have been sent a blind copy, except insofar as their address does not appear in the header section of the message. Because of this, one of the blind copy recipients could potentially send a reply to all of the shown recipients and accidentally reveal that the message went to the blind copy recipient.

Issue:
Original message:
To: [email protected]
Bcc: [email protected] (this line removed)

[email protected] receives:
To: [email protected]
(unaware they are Bcc)

Risk:
[email protected] clicks "Reply All":
To: [email protected] ← Exposes [email protected]

Scenario 2: Preserving Bcc Field

When the second method from Section 3.6.3 is used, where the blind copy recipient's address appears in the "Bcc:" field of a separate copy of the message:

  • If the sent "Bcc:" field contains all blind copy recipients, all "Bcc:" recipients will be seen by each "Bcc:" recipient
  • Even when separate messages are sent to each "Bcc:" recipient with only that individual's address, implementations still need to be careful about handling replies to the message to avoid accidentally revealing the blind copy recipient to other recipients
Problem scenario:
Message sent to each Bcc recipient:
To: [email protected]
Bcc: [email protected]

Message sent to another Bcc recipient:
To: [email protected]
Bcc: [email protected]

Risk:
If reply handling is improper, may expose other Bcc recipients

Security Best Practices

For Message Viewers

PracticeDescription
Filter Control CharactersRemove or escape potentially dangerous control characters
Whitelist Escape SequencesOnly allow known-safe escape sequences
Sandbox RenderingRender message content in restricted environment
Warn UsersAlert users to potentially dangerous content

For Email Clients

PracticeDescription
Bcc HandlingProperly implement Bcc field privacy protection
Reply HandlingPrevent accidental exposure of Bcc recipients
Attachment ScanningScan attachments for malicious content
Content ValidationValidate MIME content types and encodings

For Email Servers

PracticeDescription
Content FilteringFilter known malicious patterns
Size LimitsLimit message and attachment sizes
Rate LimitingPrevent spam and DoS attacks
AuthenticationImplement SPF, DKIM, DMARC

Threat Scenario Summary

High-Risk Threats

  1. Terminal Control Attacks

    • Impact: System control
    • Mitigation: Filter escape sequences
  2. Bcc Information Disclosure

    • Impact: Privacy breach
    • Mitigation: Proper Bcc implementation
  3. Malicious Attachments

    • Impact: Code execution
    • Mitigation: Scanning and isolation

Medium-Risk Threats

  1. Social Engineering

    • Impact: User deception
    • Mitigation: User education, sender verification
  2. Spam

    • Impact: Resource consumption
    • Mitigation: Filtering and rate limiting

Security Implementation Checklist

Message Display

  • Filter or escape control characters
  • Validate and limit escape sequences
  • Render HTML in sandboxed environment
  • Warn about suspicious content
  • Limit automatic downloads

Bcc Handling

  • Properly remove or isolate Bcc field
  • Prevent Bcc exposure on reply
  • Create separate copies for Bcc recipients
  • Test various Bcc scenarios

MIME Handling

  • Validate Content-Type
  • Check Content-Transfer-Encoding
  • Scan attachments
  • Limit nesting levels
  • Enforce size limits
  • RFC 2045-2049: MIME Security Considerations
  • RFC 5321: SMTP Security Considerations
  • RFC 6376: DKIM (DomainKeys Identified Mail)
  • RFC 7208: SPF (Sender Policy Framework)
  • RFC 7489: DMARC (Domain-based Message Authentication, Reporting, and Conformance)

Summary

Security considerations when implementing RFC 5322 focus on three main areas:

  1. Display Security: Preventing terminal escape sequence attacks
  2. Privacy Protection: Proper handling of Bcc field
  3. Content Security: Safe handling of MIME and attachments

All implementations should adopt a defense-in-depth strategy, implementing security controls at multiple layers and remaining vigilant for new threats.


Next: 6. IANA Considerations

Previous: 4. Obsolete Syntax