MHS
Message handling system: used worldwide.
MUA (Message User Agent): SW used by user to send mail.
MSA (Message Submission Agent): SW module with task of injecting the mail into the transport system.
MTA (Message Transfer Agent): the mail transport system is composed of MTAs arranged in a chain. The mail is given to the next MTA until it reaches destination.
Upon reaching destination, the email will be stored in the MS (Message Store).
Receiver will read the mail using MUA when they want. After replying, the reverse MSA will be different than the sending MSA, MTA chain will be different.
Email client-server mode
User has a program that has configured to have mail server or outgoing mail server. It uses SMTP to send mail, the user can close the program and the mail will be submitted, but it does not mean it will be received.
When someone sends a message, it will be injected in the MTA chain and finally be stored in the Post Office (MS, incoming mail server).
When a user wants to read mail, it asks the MS for incoming messages, the user can choose to leave a copy on the server or delete them. For security it’s better to delete, but Post Offices could have illegal copies.

Webmail
MUA is replaced by a web-browser. A virtual MUA is placed inside the web-server, that is automatically configured. An HTTP engine is placed in front of the MUA.
Not good for privacy.

Mail protocols, ports, formats
RFC-822 Messages
Provides pure test mail with only US-ASCII characters on 7 bits (8th used for parity).
Lines must be terminated by (system independentness)
Messages composed of:
RFC-822 header
Written in english.
From: logical sender, some applications allow changing it to an arbitrary value.
Sender: operational sender, usually is the same as From
Date is the time declared by the MUA, easy to forge
Received: contains list of MTAs traversed.
CC: carbon copies.
BCC: blind carbon copies
Return-Receipt-to: when the sender would like to receive an ack.

Issues in securing e-mail
Mail spamming
Spamming strategies
(Open) mail relay
Usually, where there is a domain, there’s also a domain relay.
Configured to accept outgoing mail only if they come from the same domain (e.g. polito.it). Accepts incoming mail only if final destination is the same domain (e.g. polito.it). This is the configuration of a not-open relay.
If the systems is misconfigured or restrictions are not applied, an external user can ask the relay to send email to the outside, the user might be a spammer. For this reason, the relay must distinguish from real from fake users.
Anti-spam for MSA
Restrict use of MSA to authorized users, which must be authenticated.
To authenticate users it is possible to use:
Strategies:
DNSBL lists
There is a number of free/commercial/anonymous listS.
Lists are managed by people that are not easy to be contacted, thus URIs inserted are not easy to be removed. Configuring the MTA correctly is strongly suggested.
Activate/use the abuse@domain address as required by an RFC.
Anti-sapm for incoming MTA
DKIM
DomainKeys Identified Mail: strategy in which the sender uses a signature to guarantee:
SPF
Sender Policy Framework: techniques that consists in declareing which are the outgoin MTA via specific DNS records.
Performing an nslookup on polito.it returns ‘v=spf1 ptr ~all’, which means that any node inside Polito that has a valid reverse address (for which a PTR record exists) is a valid sender of electronic mail, all means that everything should be accepted.
Performing an nslookup on google, gives us the address where to find the exact list of nodes that are outgoing mail servers for google. A mail coming from a google user could be rejected if it not coming from one of those servers.

ESMTP
Extended SMTP: protocol and communication channel. ESMTP client must identify themselves to communicating parites with EHLO hostname.
If the receiving party speaks ESMTP must declare the extensions it supports one per line and its response to EHLO.
Extensions are needed to authenticate the client before accepting messages from it. Useful against spamming because after the EHLO command, the server sends the authentication mechanism supported and the client chooses one and the authentication protocol is executed. If the authentication fails, the communication channel is closed.
ESMTP AUTH examples

ESMPT AUTH challenge-response methods
There are other methods than LOGIN and PLAIN (both sending cleartext passwords).
CRAM-MD5 and DIGEST-MD5 are symmetric challenge response methods.
CRAM-MD5
DIGEST-MD5

Analysis of CRAM-MD5
Pros:
Cons:
SMTP Protection with TLS
STARTTLS = option for EHLO and command
If negotiation is successful, the protocol status is reset, it starts again from EHLO and the supported extensions can differ.
If the negotiation produces a security level below the threshold:

Security services for e-mail
When 2 MTAs are communicating, it is not important to have a TLS channel, because email is cleartext anyway. Email is hop-by-hop service, email messages must be protected.
Main ideas of email security
If all of the above is well-done, message security is only based on the UA of the recipient, not on the security of MTA (untrusted).
Types of secure messages
Steps for secure message creation