File extensions
Attachments are a common way to deliver malware. Attackers send executables and scripts as attachments, nest archives inside archives to hide their contents from scanners, and give files a name that claims one type while the declared content type says another.
The spam filter recognises these tricks by checking the name and the content type of every attachment against a table of file extensions. Each entry of the table is a SpamFileExtension object, found in the WebUI under Settings › Spam Filter › Lists › File Extensions. The rule set provides about 130 entries, covering common document, image, archive and executable formats.
Fields and tags
Section titled “Fields and tags”The filter takes the extension from the last dot of the attachment’s file name, in lower case. For names such as invoice.pdf.exe, it also takes the extension before it, because a second extension is a common way to make an executable look like a document. The fields of the matching entry then decide which tags the attachment adds:
| Field | Meaning | Tag added |
|---|---|---|
extension | The extension, without the leading dot. | |
isBad | The extension is dangerous in an email attachment, such as exe, scr or bat. | MIME_BAD_EXTENSION (2.0), or MIME_DOUBLE_BAD_EXTENSION (2.0) when the extension before it is also marked bad |
isArchive | The extension is an archive format, such as zip or rar. | MIME_ARCHIVE_IN_ARCHIVE (5.0) when the name has two archive extensions, as in files.zip.rar |
contentTypes | The content types expected for the extension. An empty set accepts any content type. | MIME_BAD_ATTACHMENT (4.0) when the declared content type is not in the set and is not application/octet-stream |
isNz | Recorded with the entry; the built-in analysis does not use it. |
Some names hide their extension in other ways. An attachment name that contains invisible or direction-changing Unicode characters, which can disguise the real extension, receives MIME_BAD_UNICODE (8.0). The scores are those of the rule set, and can be changed as described in Scores.
Adding or changing an extension
Section titled “Adding or changing an extension”An entry describes one extension, and the decisions it records are whether the extension is dangerous, whether it is an archive, and which content types are expected for it. The following object declares that PDF attachments must carry a PDF content type:
{ "extension": "pdf", "contentTypes": {"application/pdf": true, "application/x-pdf": true}, "isArchive": false, "isBad": false, "isNz": false}The following object marks batch files as dangerous, whatever their declared type, by setting isBad and leaving the set of content types empty:
{ "extension": "bat", "contentTypes": {}, "isArchive": false, "isBad": true, "isNz": false}Changes to the entries of the rule set do not last. A rule set update replaces the entries it defines with its own version, so a local change to one of them is lost at the next update. Extensions that the rule set does not define are kept.