socsigmadetection
MDstable
NoteSnippetChecklistPlaybook
Règles Sigma — Détection SOC
Écrire, convertir et déployer des règles Sigma pour SIEM
snippetadvanced 2025-05-13 7 min read
socsigmadetectionSIEMrulesSplunkElastic
Structure d'une règle Sigma
yaml
Variables
{{BLOG_REFERENCE_URL}}
title: Nom court et descriptif de la règleid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # UUID uniquestatus: stable | test | experimental | deprecateddescription: >Description détaillée de ce que détecte la règle,contexte et TTPs couverts.author: Nom Auteurdate: 2025/05/13modified: 2025/05/13references:- https://attack.mitre.org/techniques/T1059/001/- https://{{BLOG_REFERENCE_URL}}logsource:category: process_creation # ou network_connection, dns_query, etc.product: windows # ou linux, aws, azure, etc.# service: security # pour event_id spécifiquesdetection:selection:# Champs de détection (AND implicite dans un même bloc)Image|endswith: '\powershell.exe'CommandLine|contains|all:- '-EncodedCommand'- '-NonInteractive'filter_legitimate:# Exclusions (NOT)ParentImage|startswith:- 'C:\Windows\System32\msiexec.exe'condition: selection and not filter_legitimatefields:- Image- CommandLine- ParentImage- Userfalsepositives:- Legitimate administrative scripts using encoded commands- Software deployment tools (SCCM, Intune)level: high # informational | low | medium | high | criticaltags:- attack.execution- attack.t1059.001
Exemple 1 — PowerShell Encoded Command (T1059.001)
yaml
title: PowerShell Encoded Command Executionid: b9d9cc83-380b-4ba3-8d8f-60c0c9d2e8dbstatus: stabledescription: >Détecte l'exécution de PowerShell avec un argument EncodedCommand,technique fréquente pour contourner la détection de scripts malveillants.author: SOC Teamdate: 2025/05/13references:- https://attack.mitre.org/techniques/T1059/001/logsource:category: process_creationproduct: windowsdetection:selection_main:Image|endswith:- '\powershell.exe'- '\pwsh.exe'CommandLine|contains:- ' -EncodedCommand '- ' -enc '- ' -ec '- ' -EnC 'filter_known_software:# Exclure les outils légitimes connus (ajuster selon environnement)ParentImage|endswith:- '\msiexec.exe'- '\ccmexec.exe' # SCCMCommandLine|contains:- 'Microsoft.PowerShell.Commands.Internal'filter_admin_workstations:Computer|startswith:- 'ADMIN-'- 'JUMP-'User|startswith:- 'svc-deploy'- 'svc-ansible'condition: selection_main and not 1 of filter_*fields:- Image- CommandLine- ParentImage- ParentCommandLine- User- Computerfalsepositives:- Software deployment agents (SCCM, Intune, Ansible)- Legitimate automation scripts from authorized admin hostslevel: hightags:- attack.execution- attack.defense_evasion- attack.t1059.001- attack.t1027
Exemple 2 — Mouvement latéral via PsExec (T1569.002)
yaml
title: Lateral Movement via PsExecid: 42e3c936-9c8d-4f8d-8b8d-5b8d5b8d5b8dstatus: stabledescription: >Détecte l'exécution de PsExec ou PsExec64, outil d'administration légitimefréquemment utilisé pour le mouvement latéral. Filtré pour exclure les usagesautorisés depuis les jump servers.author: SOC Teamdate: 2025/05/13references:- https://attack.mitre.org/techniques/T1569/002/- https://docs.microsoft.com/en-us/sysinternals/downloads/psexeclogsource:category: process_creationproduct: windowsdetection:selection_image:Image|endswith:- '\psexec.exe'- '\psexec64.exe'- '\PsExec.exe'- '\PsExec64.exe'selection_service:# PsExec crée un service PSEXESVCImage|endswith: '\PSEXESVC.exe'filter_authorized_sources:Computer|startswith:- 'JUMP-'- 'BASTION-'- 'SCCM-'User|startswith:- 'svc-ops'- 'svc-deploy'filter_system:User: 'NT AUTHORITY\SYSTEM'ParentImage|endswith: '\services.exe'condition: (1 of selection_*) and not 1 of filter_*fields:- Image- CommandLine- ParentImage- User- Computer- TargetObjectfalsepositives:- Legitimate remote administration from authorized jump servers- IT operations using PsExec for maintenancelevel: hightags:- attack.lateral_movement- attack.execution- attack.t1569.002- attack.t1021.002
Exemple 3 — Accès LSASS (T1003.001)
yaml
title: LSASS Memory Access - Credential Dumpingid: f73d81e7-c53f-4573-9855-6d5bfe26a783status: stabledescription: >Détecte les accès à la mémoire du processus LSASS pour extraction de credentials.Couvre Mimikatz, procdump, Task Manager dump, et accès via OpenProcess/ReadProcessMemory.author: SOC Teamdate: 2025/05/13references:- https://attack.mitre.org/techniques/T1003/001/logsource:category: process_accessproduct: windowsdetection:selection_lsass_target:TargetImage|endswith: '\lsass.exe'GrantedAccess|contains:- '0x1010' # PROCESS_VM_READ | PROCESS_QUERY_LIMITED_INFORMATION- '0x1410' # ReadProcessMemory- '0x1438' # Mimikatz default- '0x143a' # Mimikatz sekurlsa- '0x1f0fff' # Full access- '0x1fffff' # Full access variantfilter_legitimate:SourceImage|startswith:- 'C:\Windows\System32\svchost.exe'- 'C:\Windows\System32\werfault.exe'- 'C:\Windows\System32\taskmgr.exe'GrantedAccess: '0x1000' # Minimal access from Task Managerfilter_edr:# Exclure les agents EDR (ajuster selon EDR déployé)SourceImage|contains:- 'CrowdStrike'- 'SentinelOne'- 'MDE'condition: selection_lsass_target and not 1 of filter_*fields:- SourceImage- TargetImage- GrantedAccess- CallTracefalsepositives:- Security tools and EDR agents- Crash dump utilities on critical failureslevel: criticaltags:- attack.credential_access- attack.t1003.001
Conversion Sigma — sigma-cli
bash
# Installationpip install sigma-clisigma plugin install splunksigma plugin install elasticsearch# Conversion vers Splunk SPLsigma convert -t splunk -p splunk_windows ruleyml# Conversion vers Elastic ESQLsigma convert -t elasticsearch -p ecs_windows ruleyml# Conversion vers plusieurs formats en lotfor rule in rulesyml; doecho "=== Converting: $rule ==="sigma convert -t splunk -p splunk_windows "$rule" 2>/dev/null>> /output/splunk_all_rules.confdone# Avec pipeline personnalisésigma convert-t splunk-p splunk_windows-p my_custom_pipelineyml--output-format savedsearchesrules/lateral_movement/# Conversion Elastic avec mapping ECSsigma convert-t elasticsearch-p ecs_windows-p ecs_zeek_beats--output-format kibana_ndjsonrules/network/
Processus — Detection Engineering
1 LOG SOURCEIdentifier les sources disponibles Windows Event Sysmon EDR NetflowValider la prsence des champs ncessaires CommandLine ParentImage2 HYPOTHESIS"Un attaquant qui fait X laissera y observable dans log z"Sappuyer sur MITRE ATT&CK threat intel incident passs3 RULE WRITINGcrire en Sigma format universelCouvrir les variantes connues noms alternatifs casing pathsAjouter les filtres ds lcriture4 TEST MALICIOUSAtomic Red Team https//github.com/redcanaryco/atomic-red-teamSimuler manuellement la techniqueValider que la rgle se dclenche5 TEST BENIGNTester sur les logs des 30 derniers joursMesurer le taux de faux positifsAffiner les filtres6 TUNERatio FP acceptable < 5 pour high/criticalAjouter les exclusions lgitimes documentes7 DEPLOYCommit dans le dpt Sigma GitCI/CD test automatique avant mergeDploiement SIEM avec monitoring du volume dalertes8 MONITORSuivre le ratio VP/FP hebdomadaireRviser si > 20 FP ou 0 VP sur 30 jours
Gaps de détection courants
| Gap | Cause | Solution |
|---|---|---|
| Pas de CommandLine dans Event 4688 | Audit non configuré | Activer Include command line in process creation events via GPO |
| Pas de ParentImage | Source Sysmon non déployé | Déployer Sysmon avec config SwiftOnSecurity ou Neo23x0 |
| Faux négatifs sur encodage PS | Règle trop stricte sur casing | Utiliser |contains|all avec nocase en Sigma |
| Pas de visibilité WMI | Audit WMI non activé | Event 4688 + Sysmon Event 19/20/21 |
| Logs réseau sans contenu | NetFlow seulement | Ajouter proxy logs, DNS logs, ou Zeek |
| EDR alert sans contexte SIEM | Silos de données | Forwarder EDR alerts vers SIEM |
MITRE ATT&CK — Mapping dans Sigma
yaml
# Référence des tags Sigma ↔ MITRE ATT&CKtags:# Tactiques- attack.reconnaissance # TA0043- attack.initial_access # TA0001- attack.execution # TA0002- attack.persistence # TA0003- attack.privilege_escalation # TA0004- attack.defense_evasion # TA0005- attack.credential_access # TA0006- attack.discovery # TA0007- attack.lateral_movement # TA0008- attack.collection # TA0009- attack.command_and_control # TA0011- attack.exfiltration # TA0010- attack.impact # TA0040# Techniques (exemples)- attack.t1059.001 # PowerShell- attack.t1059.003 # Windows Command Shell- attack.t1003.001 # LSASS Memory- attack.t1547.001 # Registry Run Keys- attack.t1053.005 # Scheduled Task- attack.t1078 # Valid Accounts- attack.t1110.003 # Password Spraying
SigmaHQ — Ressources
bash
# Cloner le dépôt officiel de règles Sigmagit clone https//github.com/SigmaHQ/sigma.git# Structure du dépôt# sigma/rules/# windows/ — règles Windows (process_creation, registry, etc.)# linux/ — règles Linux# cloud/ — AWS, Azure, GCP# network/ — Suricata, Zeek, firewall# web/ — Web server logs# Chercher des règles par technique MITREgrep -r "t1059.001" sigma/rules/ --include="*.yml" -l# Valider une règlesigma check rules/my_rule.yml# Pipeline de CI pour validationsigma check --validation-config validationyml rules
💡 Tip — Tester les règles Sigma contre un jeu de logs bénins (30 jours de production) AVANT le déploiement en production — un taux de FP > 10% sur une règle "high" va rapidement saturer les analystes et conduire à l'alert fatigue. Utiliser Atomic Red Team pour valider la détection côté malveillant, et les logs de production pour calibrer les filtres.
OPS·BRAIN v1.075 notes · Securitylocal