Skip to content

SpamAssassin

Overview

SpamAssassin is a computer program used for e-mail spam filtering. SpamAssassin uses a variety of spam-detection techniques, including DNS-based and fuzzy-checksum-based spam detection, Bayesian filtering, external programs, blacklists and online databases. It is released under the Apache License 2.0 and is now part of the Apache Foundation.

  • Vendor: Apache Software Foundation
  • Supported environment: On Premise
  • Version compatibility: 3.4.6 (Latest version as of now)
  • Detection based on: Telemetry
  • Supported application or feature: Email spam filtering

High-Level Architecture Diagram

  • Type of integration: Outbound (PUSH to Sekoia.io)
  • Schema

spamassassin_architecture

Alternative

This will not be detailed in this documentation, but logs can also be sent directly to Sekoia.io over HTTPS using the Sekoia.io Endpoint Agent and the "Collect logs in files" method. This provides an alternative to the specified syslog collection method and may be preferable in certain environments.

Specification

Prerequisites

  • Resource:
    • Self-managed syslog forwarder
  • Network:
    • Outbound traffic allowed
  • Permissions:
    • Administrator or Root access to the SpamAssassin host
    • Root access to the Linux server with the syslog forwarder

Transport Protocol/Method

  • Indirect Syslog

Logs details

  • Supported functionalities: See section Overview
  • Supported type(s) of structure: Plain Text
  • Supported verbosity level: Informational

Note

Log levels are based on the taxonomy of RFC5424. Adapt according to the terminology used by the editor.

  • Default Log Location: /var/log/spamd.log

Step-by-Step Configuration Procedure

Instructions on the 3rd Party Solution

Forward SpamAssassin Logs to Sekoia.io

This setup guide will show you how to forward logs produced by your SpamAssassin servers to Sekoia.io by means of an rsyslog transport channel.

Detailed Procedure:

  1. Install and Configure Rsyslog:
  2. Ensure that the rsyslog package is installed on your server.
  3. Load the imfile module to read log files:

    $ModLoad imfile
    
  4. Configure Rsyslog to Monitor SpamAssassin Log Files:

  5. Add the following configuration to your rsyslog configuration file (usually found in /etc/rsyslog.conf or /etc/rsyslog.d/):

    $InputFileName /var/log/spamd.log
    $InputFileStateFile stat-apache-spamassassin
    $InputFileSeverity notice
    $InputFileFacility local5
    $InputFilePollInterval 1
    $InputRunFileMonitor
    
  6. Forward Logs to a Concentrator:

  7. Configure rsyslog to forward logs to a syslog concentrator:

    *.* action(type="omfwd"
       target="<Concentrator_FQDN_or_IP>"
       port="<Remote_Port>"
       protocol="tcp"
       TCP_Framing="octet-counted"
    )
    

Note

If you encounter any issues during the configuration specified in this section "Instructions on the 3rd Party Solution," please do not hesitate to contact your editor. We also welcome any suggestions for improving our documentation to better serve your needs.

Instruction on Sekoia

Configure Your Intake

This section will guide you through creating the intake object in Sekoia, which provides a unique identifier called the "Intake key." The Intake key is essential for later configuration, as it references the Community, Entity, and Parser (Intake Format) used when receiving raw events on Sekoia.

  1. Go to the Sekoia Intake page.
  2. Click on the + New Intake button at the top right of the page.
  3. Search for your Intake by the product name in the search bar.
  4. Give it a Name and associate it with an Entity (and a Community if using multi-tenant mode).
  5. Click on Create.
  6. You will be redirected to the Intake listing page, where you will find a new line with the name you gave to the Intake.

Note

For more details on how to use the Intake page and to find the Intake key you just created, refer to this documentation.

Configure a forwarder

To forward events using syslog to Sekoia.io, you need to update the syslog header with the intake key you previously created. Here is an example of your message before the forwarder

<%pri%>1 %timestamp:::date-rfc3339% %hostname% %app-name% %procid% LOG RAW_MESSAGE
and after
<%pri%>1 %timestamp:::date-rfc3339% %hostname% %app-name% %procid% LOG [SEKOIA@53288 intake_key=\"YOUR_INTAKE_KEY\"] RAW_MESSAGE

To achieve this you can:

  • Use the Sekoia.io forwarder which is the official supported way to collect data using the syslog protocol in Sekoia.io. In charge of centralizing data coming from many equipments/sources and forwarding them to Sekoia.io with the apporpriated format, it is a prepackaged option. You only have to provide your intake key as parameter.
  • Use your own Syslog service instance. Maybe you already have an intance of one of these components on your side and want to reuse it in order to centralize data before forwarding them to Sekoia.io. When using this mode, you have to configure and maintain your component in order to respect the expected Sekoia.io format.

Warning

Only the Sekoia.io forwarder is officially supported. Other options are documented for reference purposes but do not have official support.

Raw Events Samples

In this section, you will find examples of raw logs as generated natively by the source. These examples are provided to help integrators understand the data format before ingestion into Sekoia.io. It is crucial for setting up the correct parsing stages and ensuring that all relevant information is captured.

2019-09-06T17:20:42+02:00 hostfoo spamd[15185]: dns: new_dns_packet: domain is utf8 flagged: ns-1547.awsdns-01.co.uk
2019-09-10T16:27:15+02:00 hostfoo spamd[22559]: spamd: processing message <20190910142045.453A7E0933@gatewayxl.corp.net> for debian-spamd:119
2019-09-10T16:23:03+02:00 hostfoo spamd[13943]: spamd: result: . -1 - DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_FONT_LOW_CONTRAST,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS scantime=2.9,size=55475,user=debian-spamd,uid=117,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=46152,mid=<18470d5a9beea70020c028d49a50c882@corp.com>,autolearn=disabled

Detection section

The following section provides information for those who wish to learn more about the detection capabilities enabled by collecting this intake. It includes details about the built-in rule catalog, event categories, and ECS fields extracted from raw events. This is essential for users aiming to create custom detection rules, perform hunting activities, or pivot in the events page.

The following Sekoia.io built-in rules match the intake Apache SpamAssassin. This documentation is updated automatically and is based solely on the fields used by the intake which are checked against our rules. This means that some rules will be listed but might not be relevant with the intake.

SEKOIA.IO x Apache SpamAssassin on ATT&CK Navigator

Cryptomining

Detection of domain names potentially related to cryptomining activities.

  • Effort: master
Dynamic DNS Contacted

Detect communication with dynamic dns domain. This kind of domain is often used by attackers. This rule can trigger false positive in non-controlled environment because dynamic dns is not always malicious.

  • Effort: master
Exfiltration Domain

Detects traffic toward a domain flagged as a possible exfiltration vector.

  • Effort: master
Remote Access Tool Domain

Detects traffic toward a domain flagged as a Remote Administration Tool (RAT).

  • Effort: master
SEKOIA.IO Intelligence Feed

Detect threats based on indicators of compromise (IOCs) collected by SEKOIA's Threat and Detection Research team.

  • Effort: elementary
Sekoia.io EICAR Detection

Detects observables in Sekoia.io CTI tagged as EICAR, which are fake samples meant to test detection.

  • Effort: master
TOR Usage Generic Rule

Detects TOR usage globally, whether the IP is a destination or source. TOR is short for The Onion Router, and it gets its name from how it works. TOR intercepts the network traffic from one or more apps on user’s computer, usually the user web browser, and shuffles it through a number of randomly-chosen computers before passing it on to its destination. This disguises user location, and makes it harder for servers to pick him/her out on repeat visits, or to tie together separate visits to different sites, this making tracking and surveillance more difficult. Before a network packet starts its journey, user’s computer chooses a random list of relays and repeatedly encrypts the data in multiple layers, like an onion. Each relay knows only enough to strip off the outermost layer of encryption, before passing what’s left on to the next relay in the list.

  • Effort: master

Event Categories

The following table lists the data source offered by this integration.

Data Source Description
Email gateway SpamAssassin logs the spam details along with message ID and email recipient.
Mail server SpamAssassin logs the spam details along with message ID and email recipient.

Transformed Events Samples after Ingestion

This section demonstrates how the raw logs will be transformed by our parsers. It shows the extracted fields that will be available for use in the built-in detection rules and hunting activities in the events page. Understanding these transformations is essential for analysts to create effective detection mechanisms with custom detection rules and to leverage the full potential of the collected data.

{
    "message": "2019-09-06T17:20:42+02:00 hostfoo spamd[15185]: dns: new_dns_packet: domain is utf8 flagged: ns-1547.awsdns-01.co.uk",
    "related": {
        "hosts": [
            "ns-1547.awsdns-01.co.uk"
        ]
    },
    "source": {
        "address": "ns-1547.awsdns-01.co.uk",
        "domain": "ns-1547.awsdns-01.co.uk",
        "registered_domain": "awsdns-01.co.uk",
        "subdomain": "ns-1547",
        "top_level_domain": "co.uk"
    }
}
{
    "message": "2019-09-10T16:27:15+02:00 hostfoo spamd[22559]: spamd: processing message <20190910142045.453A7E0933@gatewayxl.corp.net> for debian-spamd:119",
    "related": {
        "hosts": [
            "gatewayxl.corp.net"
        ],
        "user": [
            "debian-spamd"
        ]
    },
    "source": {
        "address": "gatewayxl.corp.net",
        "domain": "gatewayxl.corp.net",
        "registered_domain": "corp.net",
        "subdomain": "gatewayxl",
        "top_level_domain": "net"
    },
    "user": {
        "id": "119",
        "name": "debian-spamd"
    }
}
{
    "message": "2019-09-10T16:23:03+02:00 hostfoo spamd[13943]: spamd: result: . -1 - DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_FONT_LOW_CONTRAST,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS scantime=2.9,size=55475,user=debian-spamd,uid=117,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=46152,mid=<18470d5a9beea70020c028d49a50c882@corp.com>,autolearn=disabled",
    "related": {
        "hosts": [
            "corp.com"
        ],
        "ip": [
            "127.0.0.1"
        ],
        "user": [
            "debian-spamd"
        ]
    },
    "source": {
        "address": "corp.com",
        "domain": "corp.com",
        "ip": "127.0.0.1",
        "port": 46152,
        "registered_domain": "corp.com",
        "top_level_domain": "com"
    },
    "user": {
        "id": "117",
        "name": "debian-spamd"
    }
}

Extracted Fields

The following table lists the fields that are extracted, normalized under the ECS format, analyzed and indexed by the parser. It should be noted that infered fields are not listed.

Name Type Description
source.domain keyword The domain name of the source.
source.ip ip IP address of the source.
source.port long Port of the source.
user.id keyword Unique identifier of the user.
user.name keyword Short name or login of the user.

For more information on the Intake Format, please find the code of the Parser, Smart Descriptions, and Supported Events here.

Further readings