FortiSIEM Rules

Linux: File Permission Modification in Writable Relative Directory By non-root user

Rule ID

PH_Rule_TH_Linux_relative_dir_10

Default Status

Enabled

Description

Identifies file permission modifications in common writable directories by a non-root user. Adversaries often drop files or payloads into a writable directory and change permissions prior to execution. This requires process monitoring via FortiSIEM Linux agent. Note that auditd CWD events will only trigger this rule, as operations such as chmod, when executed within target directory such as /tmp will show a relative path name in the PATH auditd log

Severity

7

Category

Security

MITRE ATT&CK® Tactics

Defense Evasion

Defense Evasion consists of techniques that adversaries use to avoid detection throughout their compromise. Techniques used for defense evasion include uninstalling/disabling security software or obfuscating/encrypting data and scripts. Adversaries also leverage and abuse trusted processes to hide and masquerade their malware. Other tactics’ techniques are cross-listed here when those techniques include the added benefit of subverting defenses.

https://attack.mitre.org/tactics/TA0005

MITRE ATT&CK® Techniques


T1222.002

File and Directory Permissions Modification: Linux and Mac File and Directory Permissions Modification

Adversaries may modify file or directory permissions/attributes to evade access control lists (ACLs) and access protected files. Adversaries may use these commands to make themselves the owner of files and directories or change the mode if current permissions allow it. They could subsequently lock others out of the file. Specific file and directory modifications may be a required step for many techniques, such as establishing Persistence via .bash_profile and .bashrc or tainting/hijacking other instrumental binary/configuration files via Hijack Execution Flow.

https://attack.mitre.org/techniques/T1222/002

Impacts

Server

Data Source

Linux Process Monitoring via FortiSIEM Agent

Detection

Correlation

Remediation Guidance

No remediation guidance specified

Time Window

If the following pattern or patterns match an ingested event within the given time window in seconds, trigger an incident.

300 seconds

Trigger Conditions

If the following defined pattern/s occur within a 300 second time window.

SYSCALL AND CWD

Global Constraint

This defines how two or more distinct events are related in a time-series based action. e.g. An event occurs followed by another event if the source IP, user, and messageId are the same

SYSCALL.msgId = CWD.msgId AND SYSCALL.hostName = CWD.hostName

SubPattern Definitions

SubPattern Name: SYSCALL

This is the named definition of the event query, this is important if multiple subpatterns are defined to distinguish them.

SubPattern Query

This is the query logic that matches incoming events

eventType IN ("LINUX_PROCESS_EXEC","LINUX_Auditd_SYSCALL")  AND  procName IN ("chattr","chgrp","chmod","chown")  AND  userId != "0"

Group by Attributes

This defines how matching events are aggregated, only events with the same matching attribute values are grouped into one unique incident ID

msgId,commandPath,procName,userId,user,hostName

Aggregate Constraint

This is most typically a numerical constraint that defines when the rule should trigger an incident

COUNT(*) >= 1
Operator Rank: 0 Operator Type: AND

This operator defines the logic condition relating to the prior event subpattern clause and the following event subpattern clause

SubPattern Name: CWD

This is the named definition of the event query, this is important if multiple subpatterns are defined to distinguish them.

SubPattern Query

This is the query logic that matches incoming events

eventType = "LINUX_Auditd_CWD"  AND  commandPath REGEXP "^\/dev\/shm|^\/tmp|^\/var\/tmp"

Group by Attributes

This defines how matching events are aggregated, only events with the same matching attribute values are grouped into one unique incident ID

hostName,commandPath,msgId

Aggregate Constraint

This is most typically a numerical constraint that defines when the rule should trigger an incident

COUNT(*) >= 1

Incident Attribute Mapping

This section defines which fields in matching raw events should be mapped to the incident attributes in the resulting incident.

The available raw event attributes to map are limited to the group by attributes and the aggregate event constraint fields for each subpattern

hostName=SYSCALL.hostName,
userId=SYSCALL.userId,
user=SYSCALL.user,
procName=SYSCALL.procName,
msgId=SYSCALL.msgId,
commandPath=CWD.commandPath