Module 4 - Email Protection Handout
Module 4 - Email Protection Handout
Course Agenda
• Module 1: Architecture and Troubleshooting basics
• Module 2: Network Protection
• Module 3: Web Protection
• Module 4: Email Protection
• Module 5: Webserver Protection
• Module 6: Authentication
• Module 7: Synchronized Security and Central Management
• Module 8: Site-to-Site and Remote connections
• Module 9: Wireless Protection
• Module 10: High Availability
• Module 11: XGS Hardware and Troubleshooting
Page 2 of 110
Module 4 – Email Protection
Module objectives
Once you complete this module you will be able to:
ü Explain how the MTA mode functions works
ü MTA mode features working and troubleshooting
ü Explain SASI integration
ü Explain how the Legacy mode functions works
ü Legacy mode features working and troubleshooting
ü Explain POP3 and IMAP proxy function and troubleshooting
Page 3 of 110
Module 4 – Email Protection
Page 4 of 110
Module 4 – Email Protection
Email Protection
Scenario
Internet
External network
[Link]/30
WAN
31 Recipient validation
Mail and content checks
Server
LAN
Internal network
2
2 [Link]/28
Switch
1 3
Mail client Mail client
Email Protection
Scenario
Before we look at how to troubleshoot issues, let’s look at how the XG is commonly configured as an SMTP
proxy. As this diagram shows, we have an internal and external network with a XG is in-between; we also
have a mail server, and a couple of computers with mail clients on the internal network.
[Click]
When a mail client sends an email, the mail client connects to the mail server, which accepts the email and
sends it to the XG. The SMTP proxy on the XG will perform any outbound checks that are configured, for
example data protection checks, then forward the email to the email server for the recipient's domain. This
would typically mean sending out to a server on the Internet through the WAN port.
[Click]
The XG will accept inbound emails for its list of configured internal domains. The SMTP proxy will validate
the recipient and perform content checks before delivering the email to the mail server on the internal
network that is configured for the recipient domain. The mail client on the internal computer will collect
the email from the mail server.
Note: When email subscription is Expired/unsubscribed only SMTP routing, Smart host and SMTP DoS will
be applied for both Legacy and MTA mode.
Page 5 of 110
Module 4 – Email Protection
MX
First, our sender writes an email to TECHSUPTraining@[Link] and clicks send. The senders mail client
will send the email to their company’s mail server. The first thing the mail server has to do is figure out
where the mail server for [Link] is. To do this it uses DNS.
The DNS server responds with the mail exchanger (MX) record for the recipients domain ([Link])
which is configured to be the Sophos Central email servers.
Page 6 of 110
Module 4 – Email Protection
Recipient
Now the mail server knows that to deliver the email to TECHSUPTraining@[Link] it needs to send it
to the Sophos Firewall.
When the Firewall receives the email it scans the email for viruses and spam and checks the sender against
the allow and block list.
If the email is clean then the firewall delivers the email to the recipients mail servers, and from there, the
recipients mail client will download the email.
Page 7 of 110
Module 4 – Email Protection
The interaction between the SMTP client and the SMTP server mentioned in the first step of the SMTP
procedure represents the actual SMTP session. The rest of the SMTP procedure i.e. forwarding the e-mail
via SMTP from the server to the recipient is covered in a separate article. Each session consists of a
sequence of SMTP commands from the client and responses in the form of status codes from the server.
We’ll do a live demo shortly but the MAIL FROM and RCPT TO can be considered as the “envelope from” or
“recipient to”
Page 8 of 110
Module 4 – Email Protection
Email Protection
Forwarding SMTP requests to a SMTP-Relay-Server
Smart host Server
XG Forward to
Internal Mail Server SmartHost server
SMTP Policy
check on XG Step-4
Step-2 Step-3
Smarthost
Step-1 server Step-5
SMTP forward to
HELO recipient
Process server
*6
Outbound mail
Inbound mail
Internal User Recipient mail
Server
Email Protection
Forwarding SMTP requests to a SMTP-Relay-Server
Smarthost is an MTA host which allows a mail server to route emails to an intermediate mail server rather
than directly to the recipient's mail server.
In a normal scenario, the internal mail server send emails to Sophos Firewall which initiates connection to
the recipient’s mail server. But when using a Smarthost, the internal mail server initiates connection to
Sophos Firewall, which as an MTA, opens an SMTP connection to the configured Smarthost and routes
emails to the recipient’s mail server via the Smarthost. In this case, Smarthost server works as an
intermediate emails routing server. It can be configured from Email > General Settings > Smarthost
settings
It is a 5 steps process:
From the below email logs and header, we can see that:
[Link] email server ([Link]) received email from [Link] server ([Link]).
[Link] ([Link]) received an email from Sophos Firewall ([Link] [[Link]]).
The email was generated from an internal PC (PC001-PC [[Link]]).
Page 9 of 110
Module 4 – Email Protection
Step -1 :- When an internal user sends an email, the internal mail server establishes a connection with
the recipient’s mail server and performs the SMTP EHLO HELO process, the internal server will then send
emails to the Sophos Firewall.
MSG Sep 27 [Link] [T_ACCEPTOR]: Firewall Info: [client fd: 27 fwid: 5 connid: -1951135712 uid: 0 gid: 0
sport: 23759 ]
MSG Sep 27 [Link] [0x2000033d]: New SMTP Session Initialized [Link]:53084 ==>
[Link]:25
INF Sep 27 [Link] [0x2000033d]: init_cache_node: mail transaction started with UID=0xc000000d
INF Sep 27 [Link] [0xc000000d]: Response: 220 [Link] ESMTP ready
INF Sep 27 [Link] [0xc000000d]: Request: 'EHLO SRV001'
INF Sep 27 [Link] [0xc000000d]: Response: [Link] Hello SRV001 [[Link]]
250 STARTTLS
INF Sep 27 [Link] [0xc000000d]: Request: 'STARTTLS'
INF Sep 27 [Link] [0xc000000d]: Response: 220 Ready to start TLS
INF Sep 27 [Link] [0xc000000d]: h-ver '0' , chel-ver '0'
INF Sep 27 [Link] [0xc000000d]: valid client hello
INF Sep 27 [Link] [0xc000000d]: h-ver '3' , chel-ver '5'
INF Sep 27 [Link] [0xc000000d]: initializing ssl session with ss client ctx
INF Sep 27 [Link] [T___WORKER]: Number of ssl renegotiation in this session:'1'
INF Sep 27 [Link] [0xc000000d]: SSL session established with client: '[Link]’
Step -2 :- When the XG receives these emails, it performs a SMTP policy check before sending them out.
Step -3 :- The XG then closes the connection with the internal mail server after the policy check.
INF Sep 27 [Link] [T___WORKER]: header length = '33' header type = '3'
INF Sep 27 [Link] [T___WORKER]: header[12] = '’
INF Sep 27 [Link] [T___WORKER]: header length = '2' header type = '0'
INF Sep 27 [Link] [0xc000000d]: message id 'c000000d-1506501410' for current mail
INF Sep 27 [Link] [T___WORKER]: matchpolicy: sender profile is avail
INF Sep 27 [Link] [0x2000033e]: Request: 'QUIT'
INF Sep 27 [Link] [0x2000033e]: Response: 221 [Link] closing connection
Step - 4 :- The XG checks whether any Smarthost is configured on global policy. In this scenario,
Smarthost is configured, so the XG sends emails to recipient’s mail server via smarthost
INF Sep 27 [Link] [T___WORKER]: matchpolicy: sender profile is avail
MSG Sep 27 [Link] [0xc000000d]: [0xc000000d0] FROM: inuser1@[Link] , TO:
exuser2@[Link]
INF Sep 27 [Link] [T___WORKER]: Relate with Firewall rule id: 5 mtuple flags: 2
MSG Sep 27 [Link] [0xc000000d]: Mail Transaction Started from [Link]:53084 to
[Link]:25 (fdid:27)
Page 10 of 110
Module 4 – Email Protection
Step -5 :- Lastly, when the XG receives confirmation that the email has successfully been sent to the
recipient’s mail server from the Smarthost server, it will terminate the connection. Recipient users will
think that the email was received from the internal server (which is behind the XG), but when the email
headers are opened, the complete details are shown.
Should the receipient reply to the Email it will get directly to Sophos Firewall and the host headers is as
follows:
Return-Path: <inuser1@[Link]>
Received: from [Link] (UnknownHost [[Link]]) by [Link] with SMTP;
Wed, 27 Sep 2017 [Link] +0530
Received: from [Link] (UnknownHost [[Link]]) by [Link] with SMTP;
Wed, 27 Sep 2017 [Link] +0530
Received: from [[Link]] (PC001-PC [[Link]])
by SRV001 with ESMTPA
; Wed, 27 Sep 2017 [Link] +0530
Subject: Re: Hello Bob!!!!
To: exuser2@[Link]
References: <031471c590b54cd7a17fdcca998195f2@[Link]>
Note: The difference between Smart host server and an Open relay server is, Smart host only allows
authenticated SMTP traffic, whereas Open relay allows anyone to send emails from it.
Page 11 of 110
Module 4 – Email Protection
SMTP Request
TCP 25
EHLO check
DOS check
TCP 587 Cyren spam scan
SSL check Avira/Sophos Malware scan
Relay permission exim-in queue DLP scanning
Allow & block list Sophos Sandstorm scanning
SPF & BATV
(Acceptor) Work Queue File extension and TFT filter
Recipient verification SPX Encryption
Grey listing
RBL check Mail SCANNER
IP reputation SMTPd
QMAN
Act as service manager Quarantine
Quarantine queue
exim-out queue
(Forwarder)
Routing (MX, Static, DNS)
Smart host
Require/skip TLS settings
Relay to mail server
The XG uses Exim(4.91) for handling email, which is an open-source Message Transfer Agent (MTA). The
SMTP daemon (SMTPd), starts Exim processes to listen on the following ports:
• 25 : the default SMTP port
• 587 : authenticated message submission
Note :- MTA listens on Port 25 (for Plain & STARTTLS ) and Port 587 where Port 25 available by default for
scanning but you need to perform CLI operations to allow 587 i.e. set service-param SMTP add port 587.
We do not support MTA on Port 465.
Exim-in (Acceptor) :- All emails are accepted into the exim-in queue where the Exim works as front-end
MTA, it accept all emails on port no 25. Exim accepter takes /static/proxy/smtp/[Link] as configuration
[Link] is going to verify email policies like EHLO check, DOS check, SSL check, Relay permission check, Allow
& block list, SPF, BATV, Recipient verification, Grey listing, RBL check and IP reputation and then it is going
to forward to the SMTPD Queue Manager (QMAN).
Page 12 of 110
Module 4 – Email Protection
SMTPD Qman :- SMTPD is the service manager. It invokes all process, assigns work to respective processes,
maintains their configuration state and handles failures (restart them if required)of child [Link]
QMAN sends email to the Work Queue, which has a SCANNER queue and a Quarantine queue.
Work Queue :- Once in the Work Queue emails are processed by the SCANNER queue, where the content
checks take place, including all of the antivirus and antispam checks. If the email fails the checks it is sent to
the Quarantine queue, which quarantines the email. Mail scanner is scanner process. SMTPD sends mails
to scanner for batch policy processing. SMTPD maintains the pool of scanners. on each email SMTPD picks
one scanner. Scanner process loads the policies and apply email scanning policies like
1) Avira/Sophos Malware scan
2) Cyren spam scan
4) DLP scanning
5) Sophos Sandstorm scanning
6) File extension and TFT filter
7) SPX Encryption
Exim-out (Forwarder) :- Exim also works as backend MTA. SMTPD invokes Exim forwarder with
configuration file /static/proxy/smtp/[Link]. Exim forwarder takes Emails from /var/spool/output/input
and forwards them as per the forwarding [Link] the email passes all of the content checks it is
forwarded to the exim-out queue, where it is then be relayed to the mail server configured for the recipient
domain. This module will send mail to mail server as per configuration for routing(MX, Static, DNS), smart
host and In case if it fails to send mail, mail will be submitted to queue
When the XG is sending outgoing emails, SMTPd forks an Exim process that acts as an SMTP client,
connecting to the destination SMTP server for the recipient domain to deliver the message.
Page 13 of 110
Module 4 – Email Protection
Email Protection
MTA mode log files
Log file Description
/log/[Link] /log/[Link] /log/[Link] (since v19) Antispam scanning, CTIP Antispam daemon
Email Protection
Log files
The whole process of accepting the email, moving it between queues, and performing the checks can be
tracked in the smtpd_main.log. Emails are tracked using the message ID <6>-<6>-<2>-H/-D , which changes
as the message moves between queues. we are having other logs files as well i.e. smtpd_panic.log and
smtpd_error.log which are used for mails that mailscanner is not able to processed
The exim-in queue performs all of the connection and routing checks for the emails, including relay,
recipient verification and real-time blackhole list (RBL) checks.
All of the checks on the content of the email itself are performed in the SCANNER queue.
Note: Running the ‘service smtpd:debug -ds nosync‘ is used to enable debug and running same command
a second time, will disable debug logging.
Page 14 of 110
Module 4 – Email Protection
Email Protection
Mail Logs on the WebAdmin
Email Protection
Mail Logs on the WebAdmin
The above mail logs shows different mail actions such as Dropped, Delivered, Filtered and Quarantine as
per policy.
Rejected messages at SMTP transaction will not appear on log viewer in XG v17.5. In MTA mode, we see
that from the GUI --> Email --> Mail logs page but in legacy mode, it's not possible to see logs from the
GUI.
It is a known behavior that log viewer for email will show all the email communication as firewall rule ID ‘0’
only , whereas SMTPd logs and conntrack shows correct marking of firewall rule.
Page 15 of 110
Module 4 – Email Protection
Email Protection
Enabling, disabling and verify the debug mode for the smtpd service
# service smtpd:debug -ds nosync
200 OK
Email Protection
Enabling, disabling and verify the debug mode for the smtpd
service
When debugging smtpd, it uses standard XG debug command which is #service smtpd:debug –d –s nosync
and same command is used to disable it.
As you can see above, running the #service –S | grep smptd displays the current service status of smptd
The smtpd_main.log allows us to verify if the debug mode was successfully [Link] Message
MSG Apr 16 [Link] [ T_SMTPD-W]: Toggling log level to: DBG that debugging is running.
service smtpd:exim_debug -ds nosync is specifically used if you want to get some more details for
debugging ex. If you want to know about which RBL blocked. The Message MSG Nov 25 [Link] [
T_SMTPD-W]: [MT] running exim in debug mode that debugging is running.
Note: Ensure to disable any DEBUG status on ANY XG service. The longer you retain the DEBUG status, the
more log entries generated in the corresponding log file and increased the amount of DISK SPACE occupied.
Page 16 of 110
Module 4 – Email Protection
The main 2 directory's for SMTP configurations/policy are /static/proxy/smtp/ and /cfs/proxy/smtp which
includes all information for MTA, SMTP, SPX and exim.
# cd /cfs/proxy/smtp/conf/
# ls
[Link] exim_macro.conf [Link] [Link] [Link] [Link] [Link]
exim_fqdn.conf exim_profile [Link] [Link] [Link] [Link]
# cd /static/proxy/smtp/
# ls
[Link] [Link] exim_default.conf [Link] [Link]
[Link] exim_db.sql [Link] [Link]
MTA Mode
Database tables
The above database commands gives us detail about mail logs and mail spool. We have below other
important database tables as well which can be useful for troubleshooting
List of relations
Schema | Name | Type | Owner
--------+------------------------+-------+--------
config | tblmtalist | table | pgroot
config | tblmtalistdetail | table | pgroot
config | tblmtaspxconfigrel | table | pgroot
config | tblmtaspxconfiguration | table | pgroot
config | tblmtaspxtemplates | table | pgroot
(5 rows)
Page 18 of 110
Module 4 – Email Protection
Email Protection
Log example for a SMTP connection in “smtpd_main.log”
# cat /log/smtpd_main.log | grep -e "1iZCtl-0002Lk-TQ" -e "YPM7sO-E0t1fq-ZK"
2019-11-25 [Link].017 [9036] 1iZCtl-0002Lk-TQ <= jbrown@[Link] H=[Link] Exim
([Link]) [[Link]]:44532 I=[[Link]]:25 P=esmtp S=930 M8S=8 RT=0.086s message id
id=[Link]@[Link] T="SMTP Plain" from
<jbrown@[Link]> for frogers@[Link]
MSG Nov 25 [Link] [ T_SMTPD-M]: new mail queued, add to inqueue '1iZCtl-0002Lk-TQ-D'
MSG Nov 25 [Link] [ T_SMTPD-W]: Mail assigned to 'MS-2861' for scanning '1iZCtl-0002Lk-TQ-D'
MSG Nov 25 [Link] [ MS-2861]: scan request 1iZCtl-0002Lk-TQ-D
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: spam scanning result: 'not spam'
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: Sophos Antivirus Scanned result: Clean (file number:-1)
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: [0x8543e700] FROM: jbrown@[Link] , TO:
frogers@[Link]
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: [0x8543e700](frogers@[Link])SF Policy Action: ACCEPT
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: move 'YPM7sO-E0t1fq-ZK' to forwarder queue
MSG Nov 25 [Link] [1iZCtl-0002Lk-TQ]: YPM7sO-E0t1fq-ZK <= jbrown@[Link] R=1iZCtl-0002Lk-
TQ
MSG Nov 25 [Link] [ MS-2861]: processing for 1iZCtl-0002Lk-TQ completed
MSG Nov 25 [Link] [ T_SMTPD-W]: [SMTPD] mail '1iZCtl-0002Lk-TQ-D' processed sucessfully
2019-11-25 [Link].418 [9102] YPM7sO-E0t1fq-ZK => frogers@[Link] F=<jbrown@[Link]>
P=<jbrown@[Link]> R=static_route_hostlist T=static_smtp S=1267 H=[Link]
[[Link]]:25 I=[[Link]]:33581 C="250 Requested mail action okay, completed" QT=18s
DT=0.036s
2019-11-25 [Link].419 [9102] YPM7sO-E0t1fq-ZK Completed QT=18s
Troubleshooting MTA
Log example for a SMTP connection
Every email connection will be having 2 unique exim message ID in format <6>-<6>-<2>-H/-D for header
and data so we need to grep connection based on that unique ID
# tail -f /log/smtpd_main.log
DBG Nov 14 [Link] [ T_SMTPD-M]: ignore temp file '1iVBtB-0004pF-La-H'
2019-11-14 [Link].692 [18553] 1iVBtB-0004pF-La <= jbrown@[Link] H=[Link]
([Link]) [[Link]]:44040 I=[[Link]]:25 P=esmtp S=930 M8S=8 RT=0.014s
id=[Link]@[Link] T="SMTP Debug" from
<jbrown@[Link]> for frogers@[Link]
MSG Nov 14 [Link] [ T_SMTPD-M]: new mail queued, add to inqueue '1iVBtB-0004pF-La-D'
MSG Nov 14 [Link] [ T_SMTPD-W]: Mail assigned to 'MS-17086' for scanning '1iVBtB-0004pF-La-D'
MSG Nov 14 [Link] [ MS-17086]: scan request 1iVBtB-0004pF-La-D
INF Nov 14 [Link] [ MS-17086]: start processing new mail /sdisk/spool/input/work/1iVBtB-0004pF-La-
[Link]
DBG Nov 14 [Link] [ MS-17086]: parse_file_name: mail msg_id = 1iVBtB-0004pF-La
id 1iVBtB-0004pF-La
Page 19 of 110
Module 4 – Email Protection
Page 20 of 110
Module 4 – Email Protection
Page 21 of 110
Module 4 – Email Protection
DBG Nov 14 [Link] [ MS-17086]: queries = update tblmailspool set out_mail_id = '1JDVpq-WPclCU-FE',
m_subject = 'SMTP Debug', filename = '1JDVpq-WPclCU-FE', m_reason = 0 where mail_id='1iVBtB-0004pF-
La' and rcpt_to = 'frogers@[Link]';
MSG Nov 14 [Link] [ MS-17086]: processing for 1iVBtB-0004pF-La completed
MSG Nov 14 [Link] [ T_SMTPD-W]: [SMTPD] mail '1iVBtB-0004pF-La-D' processed sucessfully
2019-11-14 [Link].118 [18558] 1JDVpq-WPclCU-FE => frogers@[Link]
F=<jbrown@[Link]> P=<jbrown@[Link]> R=static_route_hostlist T=static_smtp S=1267
H=[Link] [[Link]]:25 I=[[Link]]:52144 C="250 Requested mail action okay, completed"
QT=9s DT=0.009s
2019-11-14 [Link].118 [18558] 1JDVpq-WPclCU-FE Completed QT=9s
DBG Nov 14 [Link] [ MPOLLER]: handle_inotify_event: file received in msglog queue '1JDVpq-WPclCU-
FE'
DBG Nov 14 [Link] [ MPOLLER]: file received in [Link] queue '1JDVpq-WPclCU-FE'
DBG Nov 14 [Link] [ MPOLLER]: process_omsg_file: file path =
/sdisk/spool//output/[Link]/1JDVpq-WPclCU-FE
DBG Nov 14 [Link] [ MPOLLER]: get_maildata_from_spool: query = select mail_id, mail_from, rcpt_to,
m_subject, time_stamp, m_size, m_reason from tblmailspool where out_mail_id='1JDVpq-WPclCU-FE'
DBG Nov 14 [Link] [ MPOLLER]: get_maildata_from_spool: 0th column value is 1iVBtB-0004pF-La
DBG Nov 14 [Link] [ MPOLLER]: insert_into_maillog: Query is 'insert into
tblmaillog(mail_id,mail_from,rcpt_to,m_subject,recv_time,m_size,m_status,m_reason,decription,fwd_tim
e,out_mail_id) values('1iVBtB-0004pF-La','jbrown@[Link]','frogers@[Link]','SMTP
Debug','2019-11-14 [Link]', '930', 2, 0, 'Mail sent successfully.', to_timestamp('1573725498'), '1JDVpq-
WPclCU-FE')'
DBG Nov 14 [Link] [ MPOLLER]: delete_from_spool: query = delete from tblmailspool where
out_mail_id='1JDVpq-WPclCU-FE'
DBG Nov 14 [Link] [ MPOLLER]: spool updated for '/sdisk/spool//output/[Link]/1JDVpq-
WPclCU-FE'
DBG Nov 14 [Link] [ MPOLLER]: process_msg_file: precessing 1JDVpq-WPclCU-FE
The Email proxy determined that the content was having infected malware file which has been blocked
Note :- Current scanning time interval is 2 mins. Every re-scanning time it will pick updated policy, if it is
dual then both will be scanned, if it is single only primary AV will be scanned.
Page 22 of 110
Module 4 – Email Protection
Page 23 of 110
Module 4 – Email Protection
Page 24 of 110
Module 4 – Email Protection
Page 25 of 110
Module 4 – Email Protection
The Email proxy determined that the content is a spam so it has been quarantine as per policy
Page 27 of 110
Module 4 – Email Protection
The Email proxy determined that the content is a having MIME filtering so it has been blocked as per
policy
Page 28 of 110
Module 4 – Email Protection
The Email proxy determined that the content was confidential data and has to be encrypted with SPX.
The SPX generation worked without failure.
Page 29 of 110
Module 4 – Email Protection
Page 30 of 110
Module 4 – Email Protection
Log example for Encrypted PDF generated and sent to the recipient
The recipient gets access to the Firewall portal to generate his own password, the URL and recipient are
added. The PDF is generated and saved and attached to the Email actually delivered to the recipient.
Note: the Email body was removed from the slide, but you’ll find it in the Student handout.
Page 31 of 110
Module 4 – Email Protection
<p>
… <email body text> …
Page 32 of 110
Module 4 – Email Protection
Page 33 of 110
Module 4 – Email Protection
Email Protection
Recipient verification
Email Protection
Recipient verification
Recipient verification is as process that identify and validate the Recipient address with mail server.
Recipient verification is required and implemented to address the following risk factors:
• Accepting mail for non-existent recipients wastes CPU time as the message is unnecessarily scanned for
spam.
• Trying to deliver mail to non-existent recipients may cause SFOS or the back-end server to create Non-
Delivery Notifications Receipts (NDR). These useless notifications are called backscatter and can get the
SFOS machine IP address or your back-end mail server blacklisted.
Page 34 of 110
Module 4 – Email Protection
MTA Troubleshooting
Troubleshooting MTA
MTA doesn’t accept emails
• Verify Antispam service is running and the /var partition has free space
1
• Verify the Device Access and ACL settings allowing SMTP relay
3
Page 35 of 110
Module 4 – Email Protection
Troubleshooting MTA
MTA doesn’t accept emails
Note: As per architecture, Firewall policy doesn’t get applied on inbound mails received from internet and
are expected to delivered to mails server hosted on cloud like O365 and G-suite. So SNAT policy is not
applied for those mails. To apply firewall policy for all traffic, update disable_offline_relate to ‘no’ in the file
/static/proxy/smtp/[Link] and restart the SMTPd service.disable_offline_relate = no
Page 36 of 110
Module 4 – Email Protection
Scenario for Disable_offline_relate option :- XG is being used as an external mail relay for a client on the
WAN side. This client is set to send to the XG. The XG accepts the email fine. Then the XG has a policy to
route emails destined for the client's domain via MX. The mail server is Office 365. Traffic flow is perfect.
Only problem is NAT policy in which if we have configured SNAT policy then it will not work so we require to
enable this option.
This option Disable_offline means "firewall rule binding will be enabled for only outbound if below option is
'yes'"
We can enable disable offline relate option from GUI also from General settings > Advanced SMTP settings
> Route inbound mail through gateway and it is persisted through a firmware upgrade.
Page 37 of 110
Module 4 – Email Protection
Troubleshooting MTA
MTA doesn’t accept emails
Page 38 of 110
Module 4 – Email Protection
When “Reject invalid HELO or missing RDNS” is enabled from the General settings under the
Advanced SMTP settings, the mail can be rejected with “550 Missing RDNS entry.” If no RDNS
available for sender domain.
Check Maillogs for specific rejected mail and hover the mouse over status to see the reason. It will
show “No RDNS entry for [Link].”.
Disable “Reject invalid HELO or missing RDNS” or configure an exception to skip RDNS/HELO check
for specific source hosts/domains or sender/recipient mail addresses to accept the mails. [not
advisable]
Check DNS configuration via [Network>>DNS] and configure the valid DNS servers which resolve the
RDNS.
Is that invalid RDNS record causing this?
When “Do strict RDNS checks” is enabled from the General settings under the Advanced
SMTP settings, the mail can be rejected with “550 Invalid RDNS entry for [Link].” If
resolved RDNS not matched back to sender domain.
Check Maillogs for specific rejected mail and hover the mouse over status to see the reason.
It will show “Invalid RDNS entry for [Link].”.
Disable “Do strict RDNS checks” or configure an exception to skip RDNS/HELO check for
specific source hosts/domains or sender/recipient mail addresses to accept the mails. [not
advisable]
Is that SPF fail causing this?
When “Reject based on SPF” is enabled in SMTP profile under spam protection
section, then the mail is rejected with “550 [Link] is not allowed to send mail
from [Link]”.
Check Maillogs for specific rejected mail and hover the mouse over status to see the
reason. It will show “SPF check failed: [Link] is not allowed to send mail from
[Link]” for sender host
Disable “Reject based on SPF” or configure an exception to skip SPF check for specific
source hosts/domains or sender/recipient mail addresses to accept the mails. [not
advisable]
Is that your source IP listed in any of the RBL?
When “Reject based on RBL” in SMTP profile under spam protection section or
“Reject based on IP Reputation” in SMTP settings under the General settings is
enabled, then the mail is rejected with “550-Sophos Anti Spam Engine has blocked
this Email because the sender IP Address is blacklisted.”.
Check Maillogs for specific rejected mail and hover the mouse over the status to see
the reason. It will show “Sophos Anti Spam Engine has blocked this Email because
the sender IP Address is blacklisted.”
Disable “Reject based on RBL” or “Reject based on IP Reputation” or configure an
exception to skip RBL check for specific source hosts/domains or sender/recipient
mail addresses to accept the mails.
Page 39 of 110
Module 4 – Email Protection
Troubleshooting MTA
Verifying Email connectivity using telnet
# telnet [Link] 25
ehlo [Link]
mail from:jdoe@[Link]
rcpt to:jsmith@[Link], janedoe@[Link]
data
Subject: Hello World
Hello,
This is my first email test using telnet.
Virtually Yours,
Jane Doe
.
250 OK id=4QGw3m-023484q-l5
quit
Troubleshooting MTA
Verifying Email connectivity using telnet
The above sample shows how to use TELNET when performing testing via SFOS without authentication.
When performing telnet command, reminders are:
• TELNET is normally disabled since its not a secured protocol. It broadcast transmissions in clear text
• When performing TELNET command to test email transmission, ensure its in the LAN zone and not
coming from outside
• Some customers have their SMTP Server Banner Greeting disabled when performing TELNET, which
result in SMTP Server Banner greeting 220 not be displayed
• Should testing be done with SFOS protecting Microsoft Exchange on-premise servers (2007, 2010, 2013
and 2016), TELNET service is disabled by default. Enabled it before testing.
Page 40 of 110
Module 4 – Email Protection
Troubleshooting MTA
Verifying Email connectivity using telnet with authentication
# telnet [Link] 25
220 [Link] ESMTP Exim 4.71 - "ATLAS SMTP Service" Wed, 13 Jul 201 1 [Link] +0100
EHLO [Link]
[Link] Hello [Link] [[Link]]
250-SIZE 31457280
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
AUTH LOGIN
334 DXNl4gddhbWU3
cwtui3lAcmlja2ljaeFoYewuY2 (Base 64 encoded username)
334 UGFzc3dvcmQ6
YeGjc3ducmE (Base 64 encoded password)
235 Authentication succeeded
MAIL FROM: emailaddress@[Link]
250 OK
RCPT TO: recipent@[Link]
250 Accepted
DATA
354 Enter message, ending with "." on a line by itself
Subject Test using Telnet
250 OK id=4Qgw3m-023484q-I5
quit
Troubleshooting MTA
Verifying Email connectivity using telnet with authentication
When sending email with authentication, its crucial that the Base 64 encoded username and equivalent
password is used. This ensures a security layer is added when performing TELNET testing.
Since EHLO command is invoked, this means that EHLO verbs are used in conjunction with SMTP
extensions.
When performing TELNET test, ensure that the following SMTP codes are received:
220 - This means that the target SMTP Server or domain has its SMTP Service Ready
250 - Means that the Requested Mail Action has completed. Examples of SMTP Extensions used in this
example are:
SIZE = which gives the server the estimated size of the message before its transmitted and for certain sizes,
provide the client with a warning that it will not accept those which exceeds the size limitation.
PIPELINING = This means that during connection, the client is not required to wait for a response when
sending the next or subsequent request.
AUTH PLAIN LOGIN = which simply means that the AUTHENICATED USER IS USING PLAIN LOGIN
Page 41 of 110
Module 4 – Email Protection
HELP = Likewise self-explanatory and does not changed the EHLP SMTP arguments
In the example entry of AUTH LOGIN, this invokes the use of the PLAIN mechanism which resulted in having
the Server responded with a 334 reply code. What happens next is that first the Base 64 Logon account is
entered and followed by the corresponding Base64 encoded password. Although the keyword PLAIN is
used when initiating the AUTH command, the username and password are NOT SEND IN PLAIN TEXT.
The 2nd graphic in this slide is just the normal way of performing TELNET email testing.
Page 42 of 110
Module 4 – Email Protection
Troubleshooting MTA
MTA accepts emails but emails do not appear on Email Spool
1. Check the error queue of the mail spool
2. Verify the number of scanners
3. Check smtpd debug logs for any abnormal activity and errors
Troubleshooting MTA
MTA accepts emails but emails do not appear on Email Spool
Page 43 of 110
Module 4 – Email Protection
Page 44 of 110
Module 4 – Email Protection
Troubleshooting MTA
Emails get stuck in the mail spool
1
• Verify Antivirus service is running
2
• Verify recipient address is reachable
3
• Verify the recipient servers in the Exim DB
4
• Check if a Sandbox result is pending
5
• Check if DLP requested the recipient to register for SPX password
6
• Check if a temporary reject message was received from the Mail server
Troubleshooting MTA
Emails get stuck in the mail spool
Page 45 of 110
Module 4 – Email Protection
admin can delete Exim db by below command to deliver all those mails immediately when mail
server is available to receive the mails.
rm -rf /var/spool/output/db/
defer (-53): retry time not reached for any host in the smtpd_main.log
• Exim will retry to deliver the mail in every 2mins for first 2hrs if mail delivery is failed. Then after first
2hrs to next 16hrs, it will get retried on every 1h with an expansion factor of 1.5. Then after from 18hrs
to next 3days, it will get retried on every 6h. If mail is still getting undelivered then bounce mail gets
generated with the message “retry time exceeded”.
Note :- this behaviour is domain specific not mail specific.
• In XG, Exim’s queue runner is running in interval of 15secs. On every run, it will check all pending mails
and check whether deliver first time header is present or not in mail file. This header is added only once
and gets removed in case of mail delivery failure. So, if deliver first time header is set, then that mail will
get tried by queue runner. If it fails to deliver the mail, then it will get retried by next queue runner. But
due to unreachability of retry time, the queue runner prints the message “defer (-53): retry time not
reached”. So once retry time gets reached then mail will get retried. If mail delivery gets failed, then it
will get requeued and get retried by next queue runner. If mail is sent successfully then retry time for
that domain gets reset.
• One can explicitly reset the retry time db by deleting files located at spool/output/db/retry*. Afterwards
you may want to retry the all queued mails by command “exim -qff” or restart the smtpd service. Mails
may put on in retry loop if they get undelivered.
Ref:- [Link]
Note: If a new Email policy was created on top of the one already matched be the old rule will also cause
this. The Emails in spool are not matching the new rule and retry indefinatly. In such a case we have move
the spooled emails to the new rule.
Page 46 of 110
Module 4 – Email Protection
If any error is found during the analysis, then admin must release manually from sandstorm activity
page and mail would be delivered to recipient accordingly.
• Does any temporary rejection message receive from Mail server?
If any server rejects the message with 4xx error in response, then SMTPd forwarder updates the
message with proper error and one can see that message by hovering mouse over the status of
message.
Page 47 of 110
Module 4 – Email Protection
Troubleshooting MTA
Emails are not scanned
1. Verify using Packet Capture
2. Scroll down to SMTP Settings and verify the value set in Don’t Scan Emails Greater
Than * & select Action for Oversized Emails
3. Verify relevant scanning SMTP/S,POP3,IMAP scanning is applied or not
4. Use TCPDUMP at port 25 to capture SMTP traffic
5. Verify X-CTCH headers in /log/smtpd_main.log file or /log/[Link]
add_header:’X-CTCH-Spam: spam’
add_header:’X-CTCH-Pver:0000001’
add_header:’X-CTCH-Spam:Unknown’
add_header:’X-CTCH-RefID:
add_header:’X-CTCH-VOD:Unknown’
str=0001.0A150207.55C9C689.0291,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,
add_header:’X-CTCH-Flags:0’
cld=1,fgs=0’
add_header:’X-CTCH-
RefID:str=0001.0A150207.55C9C689.0291,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1
add_header:’X-CTCH-Spam:Unknown’
,cld=1,fgs=0’
add_header:’X-CTCH-RefID:
add_header:’X-CTCH-Score:0.000’
str=0001.0A150207.55C9C689.0291,ss=1,re=0.000,recu=000,reip=0.000,cl=1,cl
add_header:’X-CTCH-ScoreCust:0.000’
d=1fgs=0’
add_header:’X-CTCH-Rules:’
Troubleshooting MTA
Emails not scanned
• Verify using Packet Capture MONITOR & ANALYZE > Diagnostics > Packet Capture
• Scroll-down to SMTP Settings and verify the value in Don’t Scan Emails Greater Than * & select Action
for Oversized Emails
• Verify relevant scanning SMTP/S,POP3,IMAP scanning is applied or not
• Use TCPDUMP at port 25 to capture SMTP traffic
• Verify X-CTCH headers in /log/smtpd_main.log file or /log/[Link]
Page 48 of 110
Module 4 – Email Protection
Troubleshooting MTA
Not able to trigger file/MIME filter for MTA
• File protection is applied on inbound emails only
• Enable File protection in SMTP profile & configure:
o Block file types
o MIME whitelist
• MIME type or file extension should match the configured file protection
• Check for configured exceptions
• Check smtpd_main.log and using grep, search for “DOFILTER”
DBG Nov 15 [Link] [ MS-2920]: do_filter: 1_filter
DBG Nov 15 [Link] [ MS-2920]: search_tft_cache_entry() Entry
'TFT/UTF8-A' found-> hash '336’
INF Nov 15 [Link] [ MS-2920]: Blocking Attachment: '[Link]'
DBG Nov 15 [Link] [ MS-2920]: do_filter: filtered: '[Link]'
DBG Nov 15 [Link] [ MS-2920]: add_header: 'Subject: [filtered] File
Type Email'
Troubleshooting MTA
Not able to trigger file/MIME filter for MTA
Page 49 of 110
Module 4 – Email Protection
SASI integration
Page 50 of 110
Module 4 – Email Protection
New to version 18.5 MR3+ and v19.0 EAP 2, the Sophos Firewall is moving away from Cyren to our in house
Sophos Labs Spam engine. The Sophos Firewall is the last Sophos product still utilizing Cyren services.
From the customers perspective and configuration side, nothing is changed as the changes made are under
the hood updates.
Previously, the CTIPD service was used for IP reputation checks and CTASD for anti-spam scanning, which
are all parts of the third party Cyren services. After updating, the SXL and SASI services will take over for
reputation/AS checks.
In the event a false positive or false negative needs to be submitted use the following article:
[Link]
Page 51 of 110
Module 4 – Email Protection
SASI engine v4.1.4 is used which is our own anti-spam solution developed by Sophos Labs. The only change
on the UI is under the pattern updates, it now lists Anti-spam. This means any future false positive or false
negative spam emails should be submitted using the following article:
[Link]
Page 52 of 110
Module 4 – Email Protection
SASI Troubleshooting
Location of the file Description
/bin/sasi SASI binary (built for Linux 32-bit)
/lib/sasi/bin/rsync This is the rsync binary SASI uses to merge downloaded deltas to to its DB
/cfs/sasi/[Link] SASI Configuration file
/conf/certificate/cacerts/curl-ca- CA certificate to validate Sophos signature server, every time
[Link] SASI downloads the updates from the database.
/sdisk/sasi/[Link] SASI Database Location
/log/[Link] SASI Logs
SASI Troubleshooting
The following may be used for SASI troubleshooting. The primary SASI troubleshooting log is [Link], which
will log any pattern updates and statuses. While the SASI pattern updates and antispam database files are
stored in the /sdisk/sasi directory.
Managing the antispam engine service uses the standard service commands.
The curl command listed below can be performed to run a basic health check of the SASI daemon. Below is
a snippet of a healthy SASI database.
Page 53 of 110
Module 4 – Email Protection
Sample configuration file for SASI: (The SASI configuration file is located at /cfs/sasi/[Link]. It is
generated by an opcode, which means edits to this file are not preserved after a reboot.)
LOG_FILE = /log/[Link]
DEBUG_LEVEL = ERROR
CONSOL_OUTPUT = TRUE
LOG_SIZE = 10485760
LISTENING_PORT = 25315
LISTENING_ADDR = [Link]
TCP_NODELAY = TRUE
SPAMENGINE_DB_PATH = /sdisk/sasi
SPAMENGINE_DB_NAME = [Link]
CLIENT_TIMEOUT = 30
MAX_CONNECTIONS = 12
Page 54 of 110
Module 4 – Email Protection
MAX_THREAD = 4
WEIGHT_ENABLE = TRUE
ENABLE_PRECOMPILED_SIGS = FALSE
SIG_UPDATE_TIMEOUT = 480
SERVER_URL = [Link]
RSYNC_PATH = /lib/sasi/bin
CA_CERT_PATH = /conf/certificate/cacerts/[Link]
CUSTOMER_DEVICE_ID = XG/18.5.3.10061 (SFDemo-nest-vm-08/ecdd938b-5282-4f19-a646-
74a79d510420)
HMAC_TOKEN = none
Page 55 of 110
Module 4 – Email Protection
SASI Logs
/log/ [Link]
2021-04-26.[Link] MESSAGE [9999] [ [Link]] LASE Daemon STARTED
2021-04-26.[Link] MESSAGE [9999] [ [Link]] LASE Daemon Version: 4.1.4
2021-04-26.[Link] MESSAGE [9999] [ [Link]] Lased started on port : 25315
2021-04-26.[Link] MESSAGE [9999] [ [Link]] [Precompile thread]: Signatures are out
of sync. Fetching new signatures.
2021-04-26.[Link] MESSAGE [9999] [ [Link]] Downloaded file
/var/pattern/sasi/[Link] is verified with checksum..
2021-04-26.[Link] MESSAGE [9999] [ [Link]] Database loaded of
version: 2021.4.26.93315
2021-04-26.[Link] MESSAGE [9999] [ [Link]] [Precompile thread]: New signatures are
fetched and successfully loaded.
2021-04-26.[Link] MESSAGE [9999] [ [Link]] Downloaded file
/var/pattern/sasi/[Link] is verified with checksum..
2021-04-26.[Link] MESSAGE [9999] [ [Link]] Database loaded of
version: 2021.4.26.95415
2021-04-26.[Link] MESSAGE [9999] [ [Link]] [Precompile thread]: Signatures are
reloaded with latest delta and verified with checksum of new signatures.
...
This is an example of what the logs will look like during a successful and a failure event. The above displays
the LASEd being updated with the latest version. Where the below output would be displayed in the event
of a failure.
Page 56 of 110
Module 4 – Email Protection
Anti-spam Troubleshooting
Page 57 of 110
Module 4 – Email Protection
No TAG!
“[Link]” mail server 7
No TAG! “i_hate.[Link]” mail server 6
From: <> From: jsmith@[Link]
To: jsmith@[Link] To: lfox@i_hate.[Link]
8 Rejected
lfox@i_hate.[Link] does not exist!! Evil Spammer
BATV is a mechanism wherein an outgoing Email server adds a tag to the Envelope From address of all
outgoing Emails. For example, if an Email address goes out with From address as <info@[Link]>the
Envelope From is changed to <prvs=SBDGAUJ=info@[Link]>, where 'SBDGAUJ' is the added tag. This
tag is generated using an internal mechanism and is different for each email sent.
If any bounce is received by the Incoming email servers, they are checked to see if the Bounce address has
the proper tag (in above case 'SBDGAUJ'). If not, the email is rejected. BATV ensures that your Email users
do not become a victim of bounce floods.
[Click]
1. jsmith@[Link] send a mail to lfox@i_hate.[Link] and hand it off through [Link] mail
server. However, unbeknownst to jsmith, lfox has recently changed her email address.
[Click]
2. [Link] mail server signs SMTP MAIL FROM by adding a cryptographic tag.
[Click]
3. The recipient email server, mail.i_hate_spam.com, sees that the person lfox, does not exist.
[Click]
Page 58 of 110
Module 4 – Email Protection
4. The mail server accepts the message, but then bounces it back with a null sender and puts the original,
signed, MAIL FROM information into the RCPT TO field.
[Click]
5. When the message reaches [Link] mail server, it sees that the message is a bounce. It decrypts
the RCPT TO information which is subsequently verified, so it accepts the message and it is delivered
straight to inbox.
[Click]
6. Meanwhile, evil spammer sends a message to lfox at mail.i_hate_spam.net while forging
jsmith@[Link] address.
[Click]
7. Mail.i_hate_spam.net accepts the message, discovers that it can’t deliver it (because lfox doesn’t exist
there either) and then bounces it back to jsmith since jsmith appear to be the one who sent the message.
[Click]
8. When the bounced message hits [Link] email server, the server sees that the message is an NDR.
However, because the RCPT TO field is not signed, and [Link] email server knows that all genuine
outbound mail from customers is signed, the message is rejected.
Page 59 of 110
Module 4 – Email Protection
In this example, we have 2 different bounce back mail logs in which “virus found: BATV
Demo1” got accepted as it is contained a valid signature and BATV DEMO 2 got rejected due
to an invalid signature
Troubleshooting steps :-
Check smtpd_main.log
2. Email sample of original email (inbound) and where applicable original outbound email (outbox)
Points to remember
• There will be an exception policy for BATV where admin can except BATV for IPs, senders or recipients.
• Rejected bounce mail should be logged to mail log
• Default action of BATV will be a REJECT
Page 60 of 110
Module 4 – Email Protection
• Validity of prvs signed mail is 7 days, after this time tags will expire
• These tags are not stored in the database because they are generated with a prvs secret key and sender
address at the time of mail processing.
• Some mail transfer agents may reject a message whose envelope sender address was modified using
BATV. In this case, you need to create an exception rule for the senders, recipients, or domains affected.
Page 61 of 110
Module 4 – Email Protection
Is
sending server IP
Address in valid SPF
Y address N
SPF Pass SPF Fail
A SPF (Sender policy framework) record is a public DNS TXT entry that specifies the IP addresses that send
email on behalf of your domain.
This is used by receiving mail servers to validate IF envelope sender IP address is authorized to send mail
from the domain for the purposes of email spoof prevention
Sender policy framework (SPF) is an email authentication mechanism that provides both antispam and anti-
phishing protection. This is based on RFC 7208 which replaced the previous release under RFC 4408. As a
validation protocol, it utilizes DNS records to identify legitimate or invalid inbound email. Once enabled,
Sophos Firewall will detect and reject SMTP connections from unauthorized email sender domains.
Page 62 of 110
Module 4 – Email Protection
SPF works by looking at the domain of the Return-Path value included in the email’s headers. The receiving
server extracts the domain’s SPF record and then checks if the source email server IP is approved to send
emails for that [Link] the recipient’s email server receives the email, it takes email domain
[Link] and performs a TXT lookup, looking for the SPF record
[click]
The recipient’s email server [Link] then compares the source IP of the email with the one listed in
the SPF record
[click]
The email is then accepted as the source IP of the email matches what is specified by the SPF record and if
the sender IP not match the SPF record, the email will be dropped
Reference:
RFC 7208: [Link]
SPF has 2 scenarios when processing inbound email. The first one is when rejecting unathorized or
illegitimate connections. The second is once the email source IP is verified via DNS + SPF check, connection
is accepted and inbound email processed.
Though SPF-related log events are stored in ‘/log/smtpd_main.log’, smtpd service must be placed in
‘debug’ mode before SPF log events are recorded. To enable debug logging run the command: ‘#service
smtpd:debug -ds nosync’.
Note: Running the ‘service smtpd:debug -ds nosync‘ command a second time, will disable debug logging.
Page 63 of 110
Module 4 – Email Protection
To perform lookup and check a valid domain SPF record, run the command ‘nslookup –q=txt <domain>’. In
this example, we find the SPF records for [Link].
Page 64 of 110
Module 4 – Email Protection
No Yes No
No
Remove entry
No Known
Add entry in Remove entry from Yes from known
Sender? 7 day limit expired? Sender /
known sender Greylisted table
Inactive for
Yes No 7 days
No
No 4 mins No Yes
Minimum retry Update last
since 24hr limit expired? Already Greylisted?
time not reached access time
Greylisted?
Yes No
Overview
• grey listing is an industry technology which temporarily blocks emails from being received by XG. This is
by rejecting the messages for a specific amount of time. The key item here is to group them by set
(Sender email address, sender IP address, Recipient Address and Message Subject) and block incoming
emails for, say, 4 to 15 minutes.
• Data set is compared with the SMTP proxy internal database; if data is not yet recorded, a corresponding
record entry and time stamp is created in the database. This rejects the email for a period (example: 4
minutes). Once the time expires and email resent again, the message is accepted.
• The positive note is that it doesn’t use pattern, data analytics or heuristics in analyzing the email but on
certain behavior. An example is if an email with the same message subject is received by the recipient
every 4 minutes. The behavior can be construed as malicious and might be a possible spam. grey listing
ensures the message is blocked for the time being.
• grey listing should only be applied to Inbound emails.
• Client sends Inbound email and it will be intercepted by SMTPD service. Sender/Host should be
Greylisted/Temporarily rejected for 4 minutes after first attempt. SMTPD service will wait for same mail
with same mail content and MAIL FROM and RCPT TO content after Grey listing timeout.
• For grey listing, the timer is called at 23:59 daily. So, the entry will be removed after the timer execution
even if 24hr/7days/31days are completed. For example, if the 1st mail is received at 1:00 pm on 13th
August and sender is inactive for next 7 seven days then the entry will be removed at 23:59 on 20th
August.
Identifies the following data set:
Page 65 of 110
Module 4 – Email Protection
MTA service will accept and check against grey list as per below:
• If Spam exception is matched against inbound email, then email will be checked for Trusted host and
RDNS look up respectively. If host/domain is in trusted list and RDNS lookup is successful then, MTA will
accept the mail and as per profile match it forwards the mail to mail server as per routing.
• If there is no match in exception list then it verifies for known sender list, if sender entry is present in
database and if this entry is for more than 31 days then MTA service will remove that entry and perform
the above steps again. If 31st day limit is not expired for that known sender, then it verifies for 7 day limit
expiry where MTA service checks inactivity for that sender. If that sender is inactive for 7 days or more,
entry for that host will be removed. If the sender is active, it updates last access time and an email will
be accepted. Maximum limit in known hosts table is 1 million.
• If the sender is not Greylisted before then it will be added to Greylisted email. After being Greylisted,
email will be rejected. If host does not retry mail, remove entry after 24 hours.
• Sender/Host should be added to Known Hosts if same mail is retried within 5 minutes to 24 hours after
the first attempt.
Note: One notable instance of using grey listing is if a known, legitimate site had been hacked or infected
and in turn, sending out emails which are either spam or virus-infected. grey listing effectively block the
originating MTA and ensure the customer’s domain are protected during the duration of this issue.
Page 66 of 110
Module 4 – Email Protection
The SMTPd log example shows us 2 different logs for initial rejections of mail due to grey listing and then
after 4 minutes mail has been accepted
Database
When the recipient server address was Greylisted
#psql -U nobody -d iviewdb -p 5433 -c "select * from tblgreylisted”
#psql -U nobody -d iviewdb -p 5433 -c "select * from tblmaillog where decription ='Temporary Rejection:
Sender IP address has been Greylisted.’”
Page 67 of 110
Module 4 – Email Protection
SHA-256
Base64 encoding
RSA – 2048bit
Troubleshooting DKIM
Inbound Verification UI
DKIM verification help to validate inbound emails through the source domain name and message integrity
with Cryptographic authentication that prevents email spoofing.
DKIM Inbound eliminate spam and guarantee message contents from domains using DKIM that you trust
Page 68 of 110
Module 4 – Email Protection
SHA-256 [Link]
DNS Validate message
Base64 encoding
using public key from
Return [Link]
DKIM DNS entry
DKIM record
RSA – 2048bit
Was message
unchanged?
Y N
DKIM Pass DKIM Fail
Email Protection
DKIM (Domain Keys Identified Mail) Flow diagram
DomainKeys Identified Mail (DKIM) is a method for E-mail authentication, allowing a person who receives
email to verify that the message actually comes from the domain that it claims to have come from. The
need for this type of authentication arises because spam often has forged headers and improves the
recognition of bogus senders i.e. phishing [Link] example, a spam message may claim in its "From:"
header to be from sender@[Link], when in fact it is not from that address, and the spammer's goal
is only to convince the recipient to click on a link in the body of the email which leads to some other Web
site.
Because the email is not actually from the [Link] domain, the recipient cannot have any effect by
complaining to the system administrator for [Link]. It also becomes difficult for recipients to
establish whether to give good or bad reputations to various domains, and system administrators may have
to deal with complaints about spam that appears to have originated from their systems, but didn't. DKIM
adds a header named "DKIM-Signature" that contains a digital signature of the contents (headers and
body) of the mail message. The default parameters for the authentication mechanism are to use SHA-256
as the cryptographic hash and RSA as the public key encryption scheme, and encode the encrypted hash
using Base64.
The receiving SMTP server then uses the name of the domain from which the mail originated, the string
_domainkey, and a selector from the header to perform a DNS lookup. The returned data includes the
domain's public key. The receiver can then decrypt the hash value in the header field and at the same time
Page 69 of 110
Module 4 – Email Protection
recalculate the hash value for the mail message (headers and body) that was received. If the two values
match, this cryptographically proves that the mail originated at the purported domain and has not been
tampered with in transit.
DKIM Configuration
Step-1 - Generate signing key (public/private key pair)
• The recipient can query DNS to get the public key for the domain and use this to verify to the hashing
and signature of the email to confirm that it was signed be the indicated domain and that the header
has not been tampered with in transit.
• To configure DKIM you first need to create the public and private keys. On the UTM you can do this by
running the commands:
o To create a 2048 bit private key: openssl genrsa –out [Link] 2048
o To extract the public key: openssl rsa –in [Link] –out [Link] –pubout –
form PEM
o To strip unwanted characters from the public key: grep –v –e “^-^ [Link] | tr –d
“\n”
• The public key you will need in the next step is highlighted here. Be careful not to include the hostname
at the end.
Note :- Sophos Firewall quarantines DKIM-signed emails that use RSA SHA-1 or have key length less than
1024 or in excess of 2048 characters.
Page 70 of 110
Module 4 – Email Protection
• The next step is to create a record in DNS. Each domain key requires a selector that is included in the
email so that the receiving server can look it up. In this example I am using the hostname of the XG.
o The hostname for the DKIM record should be <selector>._domainkey.[Link].
o The record is a TXT (text) type record.
o Due to the length of the record, in BIND9 you need to split it across several lines using quote
marks.
o The record should start with the DKIM version and the key algorithm.
• There are other flags that you can include in the DNS record, including “t=y;” which indicates it is for
testing and that recipients should ignore your DKIM signature.
Note :- we can also generate DNS record directly from [Link] but it is not
recommended as it is not secure.
lon-gw1._domainkey.[Link]. IN TXT (
"v=DKIM1; k=rsa;
p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw3ufUTThdalyA2YPKrXM+NSrhs1+vWz57apJKto
4A9SSQlzTwW7KRvqaN7b3zeQTFA6PAnQmo8U2zo4K810yyucDf5fPbef1h+vP1tjQdvH17R9sANNo1UhaKqt0
uvp99tLUjgbket38IuDUeTq7z1PHejRdpG2NK7m4KzRi5/tCdKEKO1xQeb84ROlDCbfVJOkJJmsck5eqZA27OshN
7kzGKn4uP/ZMQsQdkGkN3BSJicqy60A3mpWIzoPQZ5leUD” )
To configure DKIM on the UTM, you need to paste the private key into the DKIM section, enter the selector
name for the key in DNS so that recipients can look it up, and choose which domains you want the UTM to
sign using DKIM.
Note: User's uploaded private key for DKIM signing will be stored at following location on appliance at ls -
lah /var/exim/dkim/
Page 71 of 110
Module 4 – Email Protection
You can test DKIM using Gmail. In an email, use the menu to view the original message and you will see a
summary at the top that shows whether DKIM validation passed or failed.
Database tables
The command psql -U nobody -d corporate -c "select * from tbldkimsigning” will display the DKIM
database table details and tbldkimverification table will give us information about different paramters for
DKIM verifications.
Page 72 of 110
Module 4 – Email Protection
Hash Data
Page 73 of 110
Module 4 – Email Protection
In order to lookup and check a valid domain DKIM record, run the command ‘nslookup –q=txt
<selector>._domainkey.<domain>’. In this example, we find the DKIM records for [Link].
The DKIM header can be retrieve from the received mail as given in below example :-
Page 74 of 110
Module 4 – Email Protection
To validate SPF entries from an Apple, Linux or Unix shell, we can use dig:
#dig txt <selector>._domainkey.<domain>
Page 75 of 110
Module 4 – Email Protection
• To sign outgoing messages with DKIM you have to configure your DNS settings on provider side.
• Please note without a txt record you cannot use DKIM.
Note: We can verify same TXT record from any linux based machine by executing command “dig
nameofthekey._domainkey.[Link] TXT +short”
Page 76 of 110
Module 4 – Email Protection
Yes
DKIM Yes
Verification Apply DKIM Failed Action
failed
No
Invalid Yes
DKIM Apply Invalid DKIM Signature Action
Signature
No
No DKIM Yes
Apply other configured policies to Apply DKIM Signature not found
Signature
mail Action
not found
[Click]
Should DKIM verification fail (e.g. Body hash mismatch with the signature, indicating email body
modification in transit or the signature could not be verified, indicating a forged signature or a header
modification)
The failed DKIM action is applied.
[Click]
An invalid DKIM signature is detected (e.g. the sending domain’s public key was not in the TXT record or it
has an invalid syntax)
The invalid DKIM action is applied.
[Click]
No DKIM signature is found (e.g. the Email does not have a DKIM signature for this domain)
The no DKIM signature found action is applied.
[Click]
Other mail rules are applied
Page 77 of 110
Module 4 – Email Protection
Note: If a single mail is sent to two users an exception policy to skip DKIM verification is created for one
recipient. Should DKIM verification fail for the unexempt user then mail will be rejected for both the
recipients.
Page 78 of 110
Module 4 – Email Protection
Sophos Sandstorm
Page 79 of 110
Module 4 – Email Protection
Sophos Sandstorm
Detecting Zero-Day Threats using Sandstorm
• Supported using MTA (Mail
Transfer Agent) mode
• Applicable to Inbound SMTP policy
• Email > Policy > Add policy >
Malware Protection
Sophos Sandstorm
Detecting Zero-Day Threats using Sandstorm
Page 80 of 110
Module 4 – Email Protection
Sophos Sandstorm
Services and log files
# ls -l /log/sandbox*
Sophos Sandstorm
Services and log files
• To verify if Sandstorm service is running, use the above command: service –S | grep ‘mta\|sandbox’ to
display the following services:
• smtpd à Which is the SMTP MTA service responsible in allowing XG to absorb, process and
handover the entire email + attachment to either downstream or upstream MTA
• Sandboxd which is the main Sandstorm Sandboxing daemon/service
• Sandbox_reportd Is the supporting Sandstorm daemon/service responsible in logging and
displaying all the required statistical information of Sandstorm for XG
• We used smtpd_main.log as the main transactional log file when this feature is enabled in XG. To
support Sandstorm, we add two new additional logs namely:
• Sandbox_reportd.log
• [Link]
Page 81 of 110
Module 4 – Email Protection
Sophos Sandstorm
Log example for Sandbox eligible file detected smtpd_mail.log
MSG Apr 16 [Link] [1hGLkj-0004w0-D5]: Sophos Antivirus Scanned result: Clean (file number:-1)
DBG Apr 16 [Link] [1hGLkj-0004w0-D5]: AV response tlv number: '5'
MSG Apr 16 [Link] [1hGLkj-0004w0-D5]: Avira Antivirus Scanned result: Clean (file number:-1)
DBG Apr 16 [Link] [ MS-3573]: smtp_av_callback_batch: attache no = 0, name =
/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0, avresult = 0
DBG Apr 16 [Link] [1hGLkj-0004w0-D5]: DOSANDSTORM
INF Apr 16 [Link] [ MS-3573]: File '/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0' , sandbox
status: 'Eligible'
DBG Apr 16 [Link] [ MS-3573]: scan_file_for_virus(): Selected Filename:
'/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0'
DBG Apr 16 [Link] [ MS-3573]: decodeAnytoUtf(): string to decode = sandbox_test.exe
DBG Apr 16 [Link] [ MS-3573]: decoded subject : 'sandbox_test.exe'
DBG Apr 16 [Link] [ MS-3573]: scan_file_for_virus(): len='221' data=0x9876a40,
filename='/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0' index='17'
DBG Apr 16 [Link] [1hGLkj-0004w0-D5]: Blocked
DBG Apr 16 [Link] [ MS-3573]: smtp_av_callback_batch: scan result for
/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0 attache_count = 0
DBG Apr 16 [Link] [1hGLkj-0004w0-D5]: AV response tlv number: '32'
INF Apr 16 [Link] [1hGLkj-0004w0-D5]: Sandstorm result: Pending sha1: 84874922-00bb-4e08-8d2f-
9a5cc1745151
DBG Apr 16 [Link] [ MS-3573]: validate_sandstorm_result: Attachement No. = 0, Name =
'/sdisk/spool//attach/0x1hGLkj-0004w0-D5-0', Sandstorm result = Pending
DBG Apr 16 [Link] [ MS-3573]: Sanstorm Result = 'Pending'
Sophos Sandstorm
Log example for Sandbox eligible file detected smtpd_mail.log
Page 82 of 110
Module 4 – Email Protection
Sophos Sandstorm
Log example for the smtpd service polls the Sandstorm result
DBG Apr 16 [Link] [ MPOLLER]: spx list is not updated
DBG Apr 16 [Link] [ MPOLLER]: Check sandbox result 'bc3d1277-d7ee-4dce-a64a-b1f6dcad39dd' '6'
DBG Apr 16 [Link] [ MPOLLER]: Sandbox result Pending for bc3d1277-d7ee-4dce-a64a-b1f6dcad39dd
DBG Apr 16 [Link] [ MPOLLER]: total sandstorm pending result(s) 1
…
DBG Apr 16 [Link] [ MPOLLER]: Check sandbox result 'bc3d1277-d7ee-4dce-a64a-b1f6dcad39dd' '6'
DBG Apr 16 [Link] [ MPOLLER]: Sandbox result Clean for bc3d1277-d7ee-4dce-a64a-b1f6dcad39dd
DBG Apr 16 [Link] [ MPOLLER]: change result '6' to '4'
MSG Apr 16 [Link] [ MPOLLER]: sandbox result found for '/VWQB8t-CadjXu-sh-D', moved to queue
for further processing
DBG Apr 16 [Link] [ T_SMTPD-M]: events: 1
DBG Apr 16 [Link] [ T_SMTPD-M]: _enter in handle_inotify_event
DBG Apr 16 [Link] [ T_SMTPD-M]: ignore temp file 'VWQB8t-CadjXu-sh-H'
MSG Apr 16 [Link] [ T_SMTPD-M]: new mail queued, add to inqueue 'VWQB8t-CadjXu-sh-D'
DBG Apr 16 [Link] [ T_SMTPD-M]: read returned -1(Resource temporarily unavailable)
DBG Apr 16 [Link] [ T_SMTPD-W]: [SMTPD] smtpd write returned 27 bytes
MSG Apr 16 [Link] [ T_SMTPD-W]: Mail assigned to 'MS-3573' for scanning 'VWQB8t-CadjXu-sh-D'
DBG Apr 16 [Link] [ MS-3573]: Number of evetns 1
DBG Apr 16 [Link] [ MS-3573]: read event on smtpd 5
DBG Apr 16 [Link] [ MS-3573]: write event on smtpd 5
Sophos Sandstorm
Log example for the smtpd service polls the Sandstorm result
The smtpd service polls the Sandstorm result until it returns as either clean or malicious. In this example,
its clean.
Afterwards, smtpd service continues with either message delivery or takes the configured action for
malicious AV results.
Virus-infected emails and emails found malicious by Sandstorm can’t be release by SMTP quarantine.
Page 84 of 110
Module 4 – Email Protection
Sophos Sandstorm
Log example for the file eligible result in the Anti-Virus log ([Link])
2016-12-14 [Link] :[INFO] 0
sophos__scanfile: SweepFile(/sdisk/mail_cache/eml/[Link])
Sophos Sandstorm
Log example for the file eligible result in the Anti-Virus log ([Link])
Log Line: 2016-12-14 [Link] :[INFO] 3 sophos__scanfile: write eligible log and check excluded file types
for component: EMAIL
Description: Confirms that the file has been identified by the Mail proxy.
Page 85 of 110
Module 4 – Email Protection
Page 86 of 110
Module 4 – Email Protection
7
AwarrenSMTP2 Packet Flow Proxy Sends data to
Mail server & Checks
Free SMTP
Session in
1 For Email journaling Proxy
SMTP traffic marked EHLO message exchange & unsupported
Mail Client for filtering & ESMTP capabilities filtered by proxy &
3 No
New SMTP Connection submitted to the forward to MUA
awarrenSMTP daemon
6
Email Rejected Yes
Or Dropped due Garner
Is Bypass SPAM check for SMTP
Authentication sessions enabled ? to spam
Yes
No
Is Verify sender IP reputation
REJECT enabled in AS configuration? No
(Notification is sent) Yes
Is Source IP added Spam check Antispam Scan
exception list? Yes
Proxy performs No No
tunnel connection
and frees the Communication with CTIPD engine
SMTP session in Accept CTIPD result
proxy Email Dropped due
Mail size Client starts sending data Proxy writes
configured ACTION
To Virus content Yes
temp file in /var/tmp/tmp directory
is taken
4 5
Drop Yes Mail size exceeds No Yes
CTIPD or SXL
Silent drop configured limit? Result Antivirus Scan
Reject/Tmpreject is sent to
client and connection is closed
Awarrensmtp is module which mainly takes care of email message filtering for Virus, spam content over
SMTP protocol. It includes external communication with mail client, server and internal communication
with Anti Virus Engine (AVIRA) for virus infection, Anti Spam engine (CTASD & CTIPD) for Spam & Virus
Outbreak classification of email message, Logging Daemon (Garner) for reporting purpose. Awarrensmtp
service runs on tcp Port 25
• New TCP connection commence the SMTP transaction since it opening it for an inbound SMTP mail
relay
• When SMTP mail traffic is classified as mark for filtering, it hands it over to AwarrenSMTP daemon to
start the pre-requisite checks
Antivirus scan : Mail will be submitted for Antivirus scanning, clean mail will be forwarded for Anti-spam
verification, infected mails will not be forwarded for anti-spam verification. Mail will be delivered or
dropped as per configuration.
Antispam scan: Virus clean mails will be verified against Anti-spam configuration and forwarded to proxy
for taking decision.
Proxy will act and continue as per result provided
The main identification feature is for ESMTP clients to open a transmission with the
command EHLO (Extended HELLO), rather than HELO (Hello, the original RFC 821 standard). An ESMTP
server would return the code 250 OK in a multi-line reply with its domain and a list of keywords to indicate
supported extensions. A RFC 821 compliant server would return error code 500, allowing ESMTP clients to
try either HELO or QUIT.
IP Reputation
CTIPD Engine
spam classifications, URL categorization, and malware detection
Unsupported ESMTP
Sophos Anti Spam detects Spam mails by checking IP addresses, Domain, Email addresses or RBL (Real-time
Blackhole List). Sophos allows administrators to Whitelist or Blacklist Email Addresses. Emails from
Whitelisted Email Addresses are bypassed during Anti Spam scanning while Emails from Blacklisted
Addresses are blocked.
This article describes how you can create White List and Black List and use them for allowing or blocking
Emails.
Whitelist
Create an Address Group called “Whitelist” consisting of Email Addresses whose Emails are to be bypassed
while Anti Spam scanning.
Blacklist
Create an Address Group called “Blacklist” consisting of Email Addresses whose Emails are to be blocked.
• The logs are populated almost as per below which includes keyword, Log entry and description :-
To start with:
new_smtp_session : This starts the AwarrenSMTP process by showing the new_smtp_session. This means
that a new email is earn mark to the domain being protected by XG
Server greeting message: Generates the server greeting to indicate that SMTP service that actually greets
the Inbound SMTP request. This is ok but to some organization, they do suppress SMTP banner since it
gives information of what service, product and port are opened
EHLO: EHLO or Extended Hello is a part of the ESMTP commands or service [Link] EHLO
command ensure flexibility and is supported by majority of SMTP servers around the world.
MAIL FROM: This simply specifies the email address or account of the message sender
Command AUTH completed: This signifies that the SMTP Proxy processing the inbound email have
successfully verified and authenticated the recipient’s email address or its UPN Universal Principal Name.
This is normally the email address of the recipient if the environment is using Microsoft Windows Active
Directory
Page 89 of 110
Module 4 – Email Protection
DOCTIPDSCAN: The keyword in this SFOS entry is the presence of the CTIPD which is the Cyren scanning
component. Using the handle_ctipd_requests:scan it will check the Source IP Address of the inbound email
message and provide a X-CTCH message header with a corresponding RefID. This classifies if the email
source is CLEAN or MALICIOUS
DOCTIPDSCAN
handle_ctipd_requests:scan:[Link]
handle_ctipd_requests:IN event on ipd_sfd
But is x-ctch-request-id:999
x-ctch-refid:rid=0001.0A150302.529C36D5.0053
ctipd_callback: result for [Link] is CLEAN
For the Mail Size, this depends on the maximum email size configured using the SFOS UI. Take note that in
this example the maximum size of 4096 or 4MB has been exceeded hence the terminal or final action for
the email is dropped. Drop action means that the SMTP connection is terminated and not part of the email
whether it’s a header, body or attachment is saved. Another item to be clear is that Mail Size settings
includes the attachment. Why?
Because as per RFC 2822 and its subsequent RFC that superseded it which is RFC 5322 dictates that the
attachment is folded or included in the email BODY.
RFC 2822
[Link]
RFC 5322
[Link]
ss->mail_size = 5344
mail oversized:exceeds 4096 bytes
CLI > 221 Oversized mail dropped
Page 90 of 110
Module 4 – Email Protection
DOVIRUSSCAN
processing '/var/tmp/ox200000018'
The next stage here is the keyword, result:clean. In this example, the sample testing resulted in having
CLEAN action successfully removed or verified that the email is free from any malware. Checking the Log
Entry, for this row, it displays:
DOFILTER
do_filter:globalsignature
SCANCONTENT AV:1 TFT:0 DLP:0
handle_clean(): Scanned result:clean
BLOCKED is the other way around for this scenario. Instead of having a CLEAN email or action, the email
has detected a malware and should CLEAN Action not successful, BLOCKED action is triggered to ensure
that recipient and organization is protected from POSSIBLE INFECTION.
DO FILTER
do_filter:globalsignature
SCANCONTENT AV:1 TFT:0 DLP:0
client_writer:written:33 byte to av
scan_file_for_virus():len='19' data=9xea600468, filename='var/tmp/0x20000005b' index ='23'
BLOCKED
DLP or Data Loss Prevention ensures that data leaks of sensitive or confidential organizational data is
applied. This is now a standard for a lot of companies whether they are Government, Private Corporation
or even start-ups.
When DLP is ENABLED, SFOS takes its cues from the CCL or the Content Controlled List whether it’s:
Page 91 of 110
Module 4 – Email Protection
the default template downloaded from Sophos Labs used a Customized CCL which is tailor-fit to the
customer’s organization
Typical data points included in a CCL are Social Security Number, Credit Card number that uses the standard
either 15 digits(AMEX) or 16 digits (JCB/VISA/MASTERCARD)
SCANCONTENT AV: 0 TFT:0 DLP:1; CCL's matched; DODLP Action; compared_matched_ccl(); if condition
TRUE; ACCEPT
The keywords applied by AwarrenSMTP when DLP Actions are applied are:
ACCEPT - The email is tagged as ACCEPT by DLP since all conditions are verified as TRUE
REJECT & DROP shared the same final action which is QUARANTINE the Outbound email to the Qbin
directory. The difference is that when REJECT action is applied, a notification is generated and send to the
SENDER while DROP simply drop the connection and no notification generated.
ACCEPT with SPX action provides additional layer of security by converting the email into SPX formatted file
with password applied. This is useful when sender is retrieving its email that is deemed FALSE POSITIVE.
DOIBSCAN
Page 92 of 110
Module 4 – Email Protection
Once the Mail Headers are stamped, it then perform a REFERENCE LOOKUP to the RBL (Real-time Black List)
URLS such as SPAMCOP in this example to verify if the INBOUND email is indeed coming from a LEGITIMATE
& CLEAN SOURCE.
DORBLCHECK
do_rblcheck:looking out for '[Link].[Link]'
rblcheck_done:host [Link].[Link] seems clean
Queued mail for delivery is the queuing process where all CLEAN & VERIFIED email messages with or
without attachments are placed on hold while being delivered to the DOWNSTREAM MTA. The
Downstream MTA can either be either on premise Mail Servers such as Microsoft Exchange or IBM Domino
or Hosted Solutions such as Google Apps or Office365.
Free_smtp_session done. This signifies that the INBOUND email is now completely process and handover
by SFOS to the DOWNSTREAM MTA. This results in freeing the SMTP session for this email and completing
the SMTP cycle.
Page 93 of 110
Module 4 – Email Protection
No
Notify
Is Quarantine Administrator &
Yes
Quarantine Area Enable Receiver action
in rule?
No
Page 94 of 110
Module 4 – Email Protection
The topmost action that triggers antispam scanning is the Anti-Spam Rule matching which verifies the
ACTUAL SENDER & RECIPIENT EMAIL ADDRESS.
Once the top-level action is triggered, this resulted in a systematic scan flow that is performed from LEFT to
RIGHT.
• Antispam scanning is performed by CTASD at port 8080 if its INBOUND and port 8089 if its OUTBOUND.
The idea behind separating the ports is to ensure that mail traffic are processed accordingly in the most
economical and efficient way.
• Once email is identified as either INBOUND or OUTBOUND, the SOURCE IP ADDRESS is matched against
the IP GROUP.
• Furthermore, the IP Address (if its INBOUND) is checked against the RBLs & Trusted IP list. The purpose
is to ensure that IP address are both:
ü Legitimate and not SPOOFED
ü And the Sender IP address reputation is CLEAN and NOT LISTED IN ANY RBLs (Examples are
[Link], [Link], [Link], [Link] and [Link])
• Email Size is also checked to ensure that it follows the Maximum Mail Size configured by SFOS. This
feature based on the experience where DDOS or DOS-based email attacks often have huge file
attachments and eventually occupies the entire FREE DISK SPACE of a MAIL SERVER. This will shutdown
the Mail Server and prevent the organization from sending or receiving emails.
Page 95 of 110
Module 4 – Email Protection
• MIME Headers are also checked if they are completed. Header information such as SUBJECT, FROM, TO
& OTHERS are important part of the email envelope. Having one or many of these often resulted in
having SPOOFED or SPAM emails coming through the organization.
• For OUTBOUND emails, there is special emphasis in implementing DLP or Data Leak Protection which
ensures CONFIDENTIAL and SENSITIVE information ARE NOT DISCLOSED and DISTRIBUTED to the
PUBLIC. Information such as Social Security Number, Passport Number, 15, 16 & 19 digit Credit Card
Numbers are just a few of these IMPORTANT DATA that are being addressed by having using CCL
template or a Customized CCL configured with SFOS.
• Finally SPX Action is applied with a RANDOM GENERATED PASSWORD to ensure that if a email message
is QUARANTINE but needs to be retrieved, additional security layers are applied.
For the Spam Classification, as per Cyren we normally used either of the following above;
• SPAM à If the email is classified as Spam due to the number of hits in terms of keywords present in
the email.
• PROBABLE SPAM This is tagged since the email might be a SPAM but needs verification
• VIRUS OUTBREAK The email contains a virus or other of form of MALWARE that is spreading
through email transmission
• PROBABLE VIRUS OUTBREAK Email containing virus or other forms of malware are spreading but
since its hasn’t reach critical proportion, its tagged PROBABLE VIRUS OUTBREAK
POSSIBLE SMTP ACTIONS are TERMINAL ACTIONS performed by SFOS to emails coming via SMTP. Terminal
actions means that should it find the email message and/or attachment MALICIOUS, it applied BEST MATCH
FILTER ACTIONS which result in having the email processed and SKIP other scanning ACTIONS.
Page 96 of 110
Module 4 – Email Protection
AwarrenSMTP
Service and log files
• Log file is /log/[Link]
• The awarrensmtp daemon can be started, stopped and restarted using the
advanced shell
• Switch to debug mode for troubleshooting
# service awarrensmtp:status -ds nosync
200 RUNNING
AwarrenSMTP
Service and log files
Awarrensmtp service is responsible in processing emails that passes through the SMTP protocol and is
confirmed running by issuing the command:
#service awarrensmtp:status -d –s nosync
If the Firewall or Systems Administrator received a 200 OK or 200 RUNNING, this means that the
awarrrenSMTP service or daemon is running correctly
• In legacy mode, if there are more than 20 recipients in an email and emails are getting delivered to the
first 20 recipients however to the rest of the recipients the emails are not getting delivered or if you
want to retry email sending in legacy mode then we need to enable Fast ISP mode.(console> set service-
param SMTP fast-isp-mode on )
• Fast ISP mode approach is firmware upgrade safe.
• In legacy mode, If grey listing is enabled on the server side, which results mails are getting rejected. This
is because legacy mode doesn't support e-mail retry. If e-mail fails to be sent, legacy mode proxy
generates a notification and inform the sender. So, as per grey listing, failed e-mail should retried but
this is rejected with this log entry: "451 Temporary local problem, please try again!"
• If mail contains multiple recipients, policy rule which match first will apply to all recipient.
Ex. rule1 for yahoo with spam enable
rule2 for gmail with spam disable
Page 97 of 110
Module 4 – Email Protection
if mail contains yahoo and gmail domain recipients, rule 1 will match first so, spam scan apply to both
recipients.
• SPX will work partially. Only sender generated and onetime generate password methods will work with
fast isp mode.
The command switch format is the same as any other SFOS daemons and processes. So for the following
like:
To enable debug, we issue the command: # service awarrensmtp:debug -d -s nosync
This command are broken into the following:
• Service to commence the command line issue that a process or daemon is being tasked to
perform a specific function
• awarrensmtp is the name of the Legacy SMTP process or daemon
• debug is the task being asked to the daemon to perform. For this example, it sets the debug
level from normal to verbose logging. This provides detailed logging for the purpose of isolation,
audit and debugging purpose.
Note:
Ensure to only set the daemon to debug if [Link] the SFOS is running in DEBUG mode and no
troubleshooting is required, ensure to use the same command to disable it. -d -s nosync is used if the
customer is using a single Firewall device. If they are using SFOS on HA (High Availability) either
Active/Passive or Active/Active, removed the -nosync since it stands for No Synchronization.
Synchronization is required if customer deployed [Link], stop and restart are used when troubleshooting
or ensuring that the service is running.
Awarrensmtp communicates with Inbound / Outbound CTASD engine over TCP Port 8088 & 8089 using
HTTP Protocol respectively for Spam & Virus Outbreak classification of email message. CTASD daemon first
looks in its cache file further communicates with CYREN data center if needed
Page 98 of 110
Module 4 – Email Protection
Page 99 of 110
Module 4 – Email Protection
Troubleshooting AwarrenSMTP
Virus attachment is not detected
1
• Verify that AV scanning is configured for the SMTP/SMTPS firewall rule
2
• Verify the configured virus outbreak action
3
• Verify the email header shows "X-Sophos-AV-Policy"
4
• Verify the antivirus rules are configured for “Infected” and “Suspicious”
5
• Verify the "X-Sophos-smtpxv-version" header
6
• Verify “Don’t scan email greater than” configuration in General settings
• Verify if AV scanning is applied on firewall rule where email traffic passes (SMTP & SMTPS)
• Verify if the default Anti-Spam rule for “Virus Outbreak” is configured properly with SMTP/SMTPS and
POP3/IMAP actions.
• Verify the email header "X-Sophos-AV-Policy" to ensure that the mail has been scanned by the antivirus
engine
• Verify if the antivirus rules are configured properly for “Infected” and “Suspicious” emails.
• Verify the "X-Sophos-smtpxv-version" header to ensure that the latest signature pattern versions are
used
• Verify “Don’t scan email greater than” configuration, In PROTECT > Email > General settings, check
whether a limit on the size of email to be scanned is configured, and what action is applied if that size is
exceeded.
We would recommend setting the size to ‘0’, which will scan files up to 50MB, and the action for oversized
emails to ‘Reject’. This will ensure that all emails are scanned for viruses or rejected.
If attachment is not being blocked, check the MIME type of the file which is not being scanned (check
from [Link]
POP-IMAP Proxy
POP-IMAP Proxy
POP-IMAP Proxy
• The warren service handles the email antivirus and anti-spam filtering received using POP/IMAP protocol
• This includes communication with the client application, server, AVIRA antivirus engine, Commtouch
Advanced Security Daemon [CTASD], Commtouch IP Reputation Daemon [CTIPD] and firewall (ipset). The
warren service utilizes TCP Ports 109 for POP3 and 142 for IMAP4 traffic.
• Moreover, warren sends event logs of virus / spam scanning results to the garner logging daemon for
reporting & troubleshooting purposes.
• Sophos Firewall automatically applies the default POP-IMAP scan policy (default-pop-av) to POP3/S and
IMAP/S traffic which strips virus-infected attachments from inbound emails and replaces the message
body with a notification message.
# ls -lah /log/[Link]
-rw-r--r-- 1 root 197.3K Nov 20 21:43 [Link]
POP-IMAP Proxy
Verifying the warren service and communication
Warren Listens on TCP port 109,143 for POP & IMAP respectively :
# netstat -anep | grep warren | grep LISTEN
tcp 0 0 [Link]:109 [Link]:* LISTEN 0 56382 4717/warren
tcp 0 0 [Link]:142 [Link]:* LISTEN 0 56383 4717/warren
Quarantine
File location
• Quarantine messages & attachments are stored in /var/quarantine/Qbin.x
• Can specify the size of quarantine area of 5GB, 10 GB and 15GB from UI
• Each QBin directory has a size of 100 MB.
o Once size is reached, a new Qbin directory is created having the same setup.
# ls -l /var/quarantine/
drwxr-xr-x 2 root 0 4096 Dec 9 09:44 Qbin.1
# ls -l /var/quarantine/Qbin.1/
-rw-r—r-- 1 root 0 3389 Jun 02 12:31 0x2000000b
-rw-r-r—1 1 root 0 2652 June 02 16:29 0x2000000f
-w------- 1 root 0 0 June 02 09:44 1
Quarantine
File location
XG provides only the last 7 days of quarantine mails. Despite the messages stored already in the system,
appliance reporting should be enabled to get the quarantine mail listing.
In Sophos Firewall Quarantine, emails will stay at quarantine area until 90% of quarantine area is filled up.
After 90%, Sophos Firewall checks the quarantine space on each new quarantine mail and it that exceeds
quarantine limit, it remove older quarantine mails.
Quarantine Digest is an email that contains a list of quarantined messages filtered by Sophos Firewall and
stored inside the user Quarantine Area. Once configured, Quarantine Digest is generated and send based
on the configured frequency to the user. The Digest provides a link to User My Account where user can
access their quarantined messages and take necessary actions.
# timer spam_digest_mail:status
“name”:“spam_digest_mail”,“status”:“Enable”,“type”:”repeatjob”, “exec_time”:
“Thu Jun 02 [Link] 2019”, “exec_str”: “opcode_spam_digest_thread text (null)”
# timer spam_digest_mail:status
“name”:“spam_digest_mail”,“status”:“Enable”,“type”:”repeatjob”,
“exec_time”:
“Thu Jun 02 [Link] 2013”, “exec_str”: “opcode_spam_digest_thread text
(null)”
• Check Quarantine digest [Email>>Quarantine digest] is configured and is enabled for users.
• Make sure user’s email address is not added in Skip quarantine reports in [Email>>Quarantine digest].
• Check Mails are quarantined for that user for configured email frequency. Only quarantined spam mails
are included in Quarantine Digest report.
• Check Notification settings [Administrator>>Notification settings] are configured properly.
• Check timer for spam digest mail to send quarantine digest report.
ü timer spam_digest_mail:status
• Test release of Quarantine digest report manually using below command and check [Link] &
smtpd_main.log.
ü opcode spam_digest_thread -ds nosync
ü check mailSize for specific user in [Link]. It should not be zero.
ü Check Mailspool & Maillogs for Quarantine mail release.
Module Objectives
On completion of this module you are now able to:
ü Explain how the MTA mode functions works
ü MTA mode features working and troubleshooting
ü Explain SASI integration
ü Explain how the Legacy mode functions works
ü Legacy mode features working and troubleshooting
ü Explain POP3 and IMAP proxy function and troubleshooting