Best practices for configuring the core file monitoring feature

Updated at:

The core file monitoring feature of Security Center monitors file access on your servers in real time, including read, write, delete, rename, and permission change operations. It sends timely alerts to help prevent critical files from being stolen or tampered with. This topic describes guidelines and examples for configuring core file monitoring rules, and explains how to set up DingTalk chatbot alert notifications to help you make better use of this feature.

How core file monitoring complements host intrusion detection

Cybersecurity best practices recommend a multi-layered defense-in-depth strategy. Host intrusion detection identifies suspicious intrusion behaviors in most scenarios. Its detection logic is based on behavioral patterns and focuses on known or unknown malicious behaviors and system activities. Core file monitoring focuses on the integrity of files and directories in the file system and detects unauthorized changes.

The two features complement each other to provide more comprehensive security protection and improve the ability to detect complex threats. Understanding attacker behavior is critical during a security incident. If an attacker reads or modifies files within the scope of rule protection, the alert records from core file monitoring help operations staff trace the attacker's specific activities and perform effective incident response and forensic analysis.

Core file monitoring also detects internal threats such as malicious insider behavior or operational errors. All such activities are recorded by core file monitoring.

Rule configuration guidelines and examples

This section provides configuration guidelines and examples for core file monitoring rules, covering common scenarios and rule configuration instructions. Rules may trigger false positives when they match legitimate operations on different systems. The last column in the following table provides examples of normal operations that may trigger corresponding policy alerts.

To minimize the impact of false positives on system operations, use a gradual rollout approach before broadly deploying rules:

  • Pilot testing — When initially configuring rules, select a small number of machines for a pilot deployment.

  • Close monitoring — During the rule trial period, closely observe the conditions under which each rule is triggered to verify rule accuracy and applicability.

  • Iterative refinement — Based on detection results, add whitelist rules for confirmed benign operations in a timely manner to ensure critical operations do not trigger alerts and reduce the volume of alerts requiring attention.

  • Full deployment — After multiple trials and rule optimizations, when rule triggers stabilize and false positives largely disappear, deploy the configurations to more servers.

Type

Description

Subtype

Actions

Example file paths

Potential false positives

Core system files

These directories contain most system commands and shared libraries. Monitoring these directories helps detect potential attacker tampering, including planting malicious binaries or altering system library dependencies.

System executable binary directories

write, delete

  • /bin/*

  • /usr/bin/*

  • /sbin/*

  • /usr/sbin/*

Package management installations or updates also write to these directories. Additionally, manually compiling and installing software from source (typically using make && make install) may involve writes to these directories. Configure appropriate whitelist rules based on your actual situation to avoid alerts from such normal operations.

Shared library directories

write, delete

  • /usr/lib/*

  • /usr/lib64/*

Configuration files

Attackers may modify various critical system configuration files for different malicious purposes. For example:

  • By adding or modifying user records, attackers can persistently gain or escalate system access privileges.

  • By modifying DNS resolution settings, attackers can perform DNS hijacking.

  • By modifying logging configurations, attackers can interfere with or evade auditing.

  • By modifying or disabling certain security configurations, attackers can achieve their attack objectives.

  • By tampering with operational application configuration files, attackers can hijack the authentication process, thereby bypassing security measures or escalating specific user privileges.

  • By modifying web service configuration files, attackers can load malicious library files or alter parsing configurations to redirect traffic to malicious sites.

User and permission files

write

  • /etc/passwd

  • /etc/shadow

  • /etc/group

  • /etc/gshadow

  • /etc/sudoers

  • /etc/sudoers.d/*

Normal user management commands such as useradd, usermod, userdel, and passwd may write to these files. You can add appropriate whitelist rules based on your specific operational procedures, or use the alert data as audit logs.

Critical system configuration files

write, delete

  • /etc/resolv.conf

  • /etc/hosts

Routine operational changes to network settings, name resolution, and kernel parameters may modify these files.

Configuration files for operational applications

write

  • /etc/ssh/sshd_config

  • /etc/security/pam_env.conf

  • /*/.ssh/authorized_keys

During system maintenance, configuration updates, security hardening, or periodic key rotation, these files may be modified. Configure corresponding whitelist rules.

Security audit configuration files

write, delete

  • /etc/audit/auditd.conf

  • /etc/audit/rules.d/*

  • /etc/selinux/config

  • /etc/rsyslog.conf

  • /etc/rsyslog.d/*

Initial setup of the audit framework, or adjustments to monitoring policies based on compliance or security requirements, may require modifications to these files.

Web service configuration files

write

  • /etc/httpd/conf/httpd.conf

  • /etc/httpd/conf.d/*

  • /etc/apache2/apache2.conf

  • /etc/apache2/sites-available/*

  • /etc/apache2/sites-enabled/*

  • /etc/nginx/nginx.conf

  • /etc/nginx/conf.d/*

Initial web service configuration, post-installation setup, module additions and removals, and web service updates may all result in modifications to these monitored files.

Database configuration files

write

  • /etc/my.cnf

  • /etc/mysql/my.cnf

  • /etc/postgresql/*/main/postgresql.conf

  • /etc/postgresql/*/main/pg_hba.conf

  • /etc/mongod.conf

  • /etc/redis/redis.conf

Database service installation and operational changes may cause modifications to these configuration files. Add whitelist rules based on your actual situation.

Common persistence locations

Attackers typically add scheduled tasks, malicious services, or startup scripts to maintain persistent access during periodic execution or after system restarts.

Cron-related files

write

  • /etc/crontab

  • /etc/cron.d/*

  • /var/spool/cron

  • /etc/cron.hourly/*

  • /etc/cron.daily/*

  • /etc/cron.weekly/*

  • /etc/cron.monthly/*

Normal operations may add, adjust, or remove existing crontab entries, thereby modifying corresponding files.

Service-related files

write

  • /etc/init.d/*

  • /etc/rc.d/rc.local

  • /etc/systemd/system/*

  • /lib/systemd/system/*

Installing service-based applications involves adding or modifying system services.

Shell configuration files

write

  • /*/.bashrc

  • /*/.bash_profile

  • /etc/profile

Operations staff may modify these files when changing default environment settings or creating aliases for frequently used long commands.

Web service code directories

Configuring file monitoring rules for web service code directories helps ensure web application security. Attackers typically exploit vulnerabilities or unauthorized access to upload webshell malicious files. Through these webshell files, attackers can further remotely access, control, and manage compromised servers. Monitoring web service code directories effectively detects potential webshell uploads and unauthorized changes, including web page tampering, malicious script injection, and other malicious activities.

Web code directories

write, permission change

/var/www/html/<code dir>/*.php

During normal business and maintenance operations, service updates and deployments, as well as CMS plugin and theme installations and updates, may write web script files to code directories. Automation deployment tools (such as Jenkins, GitLab CI/CD, and Ansible) also write files during CI/CD processes. In this case, configure specific write process rules, exclude externally uploadable directories, and restrict specific file extensions to ensure security.

Files containing sensitive information

Leakage of sensitive authentication information is one of the major cybersecurity risks. After gaining access to a host, attackers typically search for sensitive authentication information to perform lateral movement and expand the scope of intrusion. Configuring read operation monitoring for files containing sensitive information can effectively and promptly detect such risks or malicious behaviors.

Cloud service CLI authentication information

read

  • /*/.aliyun/config.json

  • /*/.ossutilconfig

Files containing sensitive information are typically read by their associated applications. For example, Alibaba Cloud CLI reads ~/.aliyun/config.json to load authentication information, and kubectl reads ~/.kube/config to obtain Kubernetes certificate information. Additionally, some security software may scan files containing sensitive information to identify malicious files. Therefore, when configuring whitelist rules, you need to consider these legitimate read behaviors.

Version control authentication information

read

/*/.git-credentials

Database configuration

read

/*/config/database.yml

Private keys for operations and orchestration systems

read

/*/.ssh/id_rsa, /*/.kube/config

Configure DingTalk chatbot notifications

After you configure DingTalk chatbot notifications, you can receive real-time threat alert information identified by Security Center through a DingTalk group.

Note

Only Security Center Enterprise Edition and Ultimate Edition support DingTalk chatbot notifications.

Prerequisites

You have created a custom chatbot in the DingTalk group where you want to receive notifications and obtained the chatbot webhook URL. When creating the custom chatbot, configure the corresponding custom keyword in the Security Settings area based on the notification language:

  • Chinese: 云安全中心

  • English: Security

Note

For specific instructions on creating a custom chatbot and obtaining the webhook URL, see Create a custom chatbot and Obtain the webhook URL of a custom chatbot.

Procedure

  1. Log on to Security Center console.

  2. In the left-side navigation pane, choose System Configuration > Notification Settings. In the upper-left corner of the console, select the region where the asset to be protected is located: Chinese Mainland or Outside Chinese Mainland.

  3. On the Notification Settings page, click the DingTalk Chatbot tab, and then click Add Chatbot.

  4. In the Add DingTalk Chatbot panel, complete the configuration, and click Add.

    Parameter

    Description

    Example

    Chatbot Name

    Customize a name for the DingTalk chatbot. Enter a name that is easy to identify.

    Core file alert notification

    Webhook URL

    The webhook URL of the chatbot. You can find the webhook URL of the chatbot in the DingTalk group where you want to use this chatbot.

    Important

    Keep the webhook URL confidential. Do not publish it on external websites. A leaked webhook URL may pose security risks.

    https://oapi.dingtalk.com/robot/send?access_token=XXXX

    Asset Groups

    Select an asset group created in Security Center Asset Center. After selection, the DingTalk chatbot sends alert notifications related to assets in the selected group.

    Alibaba Cloud

    Notify On

    Select the alert types (Vulnerability, Baseline Check, Alert, AccessKey Leak Detection, Cloud Honeypot, RASP, Anti-Ransomware, Core File Monitoring, and Malicious File Detection) and risk levels for which you want the DingTalk chatbot to send notifications.

    Core File Monitoring/Alert Level/Urgent

    Notification Interval

    The notification interval of the DingTalk chatbot. Options: 1 minute, 5 minutes, 10 minutes, 30 minutes, or No limit (send a notification in real time for each detected alert).

    After you select No limit, a maximum of 20 notifications can be sent per minute per webhook.

    30

    Language

    The language of notifications sent by the DingTalk chatbot. Options: Chinese or English.

    Chinese

    The newly created DingTalk chatbot notification is in the Enable state by default. After configuration is complete, Security Center sends notifications according to your configured notification policy.

  5. (Optional) In the DingTalk chatbot list, find the newly created DingTalk chatbot, and in the Actions column, click Test to verify whether the DingTalk chatbot notification is connected to the DingTalk group.

Related topics