Attachments are a significant security risk associated with emails. Effective attachment filtering reduces the likelihood of malicious content reaching a user’s workstation. Mitigation strategies associated with attachment filtering are discussed below.
Convert attachments to another format
Converting attachments to another format is a highly effective method of removing malicious content or rendering it ineffective, for example, by converting Microsoft Office documents to PDF documents. To decrease the impact to users, but at the expense of an increased security risk, original emails and attachments can be quarantined with a release facility available in case the originals are required for editing purposes.
Whitelist attachments based on file typing
File typing inspects the content of a file to determine its file type rather than relying on its extension. File types that have a legitimate business purpose and an acceptable risk profile for organisations should be whitelisted. Whitelisting is recommended as it is more proactive and thorough than blacklisting. It ensures only specified file types can be received, while all others are blocked. File extensions can be changed and therefore a mismatch between a file’s type and its stated extension should be treated as suspicious and quarantined.
Block password protected archives and unidentifiable or encrypted attachments
Content within password protected archives can’t be trusted since email content filters can’t decrypt and inspect their contents. Any protected archive or otherwise encrypted attachments should be blocked until such time that they can be deemed safe. Unidentifiable content is less of a security risk if effective whitelisting and file typing of attachments is used. Where organisations have corporately approved encrypted email communications, such as S/MIME or PGP, these can be whitelisted to prevent disruption to legitimate business.
Perform automated dynamic analysis of attachments run in a sandbox
Dynamic analysis uses behaviour-based detection capabilities instead of relying on the use of signatures, enabling organisations to detect malware that has yet to be identified by vendors. Performing automated dynamic analysis of attachments run in a sandbox may detect suspicious behaviour including network traffic, new or modified files, or changes to the Windows registry.
Analysis could be performed in an instrumented sandbox located either in a gateway environment, on a user’s workstation or in the cloud subject to concerns about data sensitivity, privacy and security of the communications channel.
Organisations should block any attachments detected as malicious, paying particular care to do so before they are accessed by users, by using a product that is regularly updated by the vendor to mitigate evolving evasion techniques that challenge the effectiveness of this mitigation strategy.
Sanitise attachments to remove active or potentially harmful content
Active content removal products should scan attachments for undesirable active content based on keywords or heuristics, and rewrite those elements rendering them inert. Complete and comprehensive sanitisation of an attachment is a difficult process.
Disable or control macros in Microsoft Office files
An increase in the use of macros in Microsoft Office files being used as a malware delivery vector has been observed. These macros are written in the Visual Basic for Applications (VBA) programming language, a feature built into Microsoft Office applications. Macros are commonly used for task automation; however, adversaries are also using macros to perform a variety of malicious activities including the download and execution of malware on the host computer.
Organisations should configure Microsoft Office to disable all macros by default and only run macros vetted as trustworthy and placed in ‘trusted locations’ which typical low-privileged users can’t write to.
Controlled inspection of archive files
Archive files can be used to bypass poorly configured email content filters. By placing a malicious file in an archive file and sending it to the target, the archive file might bypass content filtering checks. To mitigate this, the contents of archive files should be subjected to the same level of inspection as un-archived attachments. The archive files should be decompressed and the files within inspected. A directory listing of the files inside an archive file is not always an accurate representation of the files actually in the archive file since file attributes, such as file name, could be stored in two places for each file.
Archived content should be inspected in a controlled manner to avoid exploits associated with archive files, such as directory traversal and denial of service via recursion. For example, a text file which is 1GB in size and consists only of spaces, could compress to 1MB but consume significant computing resources when it is processed by an email content filter. As another example, a zip file containing 16 zip files, each of which contain 16 zip files, each of which contain 16 zip files etc. to a depth of 5, could cause an email content filter to process over one million files. To mitigate this, quotas and timeout values can be used on CPUs, memory and disks so that decompression is blocked or failed if it takes longer than the specified time or uses excessive computing resources.
Archive files decompress starting from the end of the file, stopping when all the files have been extracted. As a result of this an archive file can be appended to the end of a legitimate image file and still be a valid archive from which files can be extracted. In this case, depending on the file type checking, the file could pass file type checks as an image. This behaviour can be exploited by adversaries to avoid controlled inspection of archive files. To mitigate this, organisations should attempt to decompress all attachments, with all decompressed files submitted to the security controls for attachments and the original attachment blocked if any decompressed files fail.
Whitelist attachments based on file extension
Allowing attachments based on file extension is less robust than file typing as the extension can be trivially changed to disguise the true nature of the file, for example, by renaming readme.exe to readme.doc. Only file extensions with a legitimate business purpose should be whitelisted.
Blacklist attachments based on file typing
Blacklisting attachments based on file typing is less proactive and thorough than whitelisting attachments based on file typing or file extension, and the overhead of maintaining a list of all known bad file types is far greater than maintaining a list of all known good file types.
Scan attachments using antivirus software
Attachments should be scanned using vendor supported antivirus software with up-to-date signatures, reputation ratings and other heuristic detection capabilities. To maximise the chance of detecting malicious content, antivirus software from a different vendor to that used for user workstations should be used.
Blacklist attachments based on file extension
Blacklisting attachments based on file extension is less proactive and thorough than whitelisting attachments based on file typing or file extension. Blacklisting attachments based on file extension is less robust than file typing as the extension can be trivially changed to disguise the true nature of the file, for example, by renaming readme.exe to readme.doc.