Hello,
I'm currently running the version
4.7.3 of Wazuh.
I enabled the archive.log with the logall=true.
I followed the steps of the documentation about the ms-graph integration :
https://documentation.wazuh.com/current/cloud-security/ms-graph/monitoring-ms-graph-activity.html
I'm currently receiving logs on my archive.json and archive.log, testing the decoding with the "default parameter" it's decoded with the json decoder wich trigger an error as i'm looking at Filebeat log :
2024-06-12T14:56:31.280+0200 WARN [elasticsearch] elasticsearch/client.go:408 Cannot index event publisher.Event{Content:beat.Event{Timestamp:time.Time{wall:0xc192849fc9f55d80, ext:1213487100737846, loc:(*time.Location)(0x42417a0)}, Meta:{"pipeline":"filebeat-7.10.2-wazuh-archives-pipeline"}, Fields:{"agent":{"ephemeral_id":"XXXXX","hostname":"XXX","id":"XXXXX","name":"XXX","type":"filebeat","version":"7.10.2"},"ecs":{"version":"1.6.0"},"event":{"dataset":"wazuh.archives","module":"wazuh"},"fields":{"index_prefix":"wazuh-archives-4.x-"},"fileset":{"name":"archives"},"host":{"name":"XXXX"},"input":{"type":"log"},"log":{XXXXXXXXXXXXXXXXX}(status=400): {"type":"mapper_parsing_exception","reason":"failed to parse field [data.ms-graph.status] of type [keyword] in document with id '8N6FDJABhpqQsALiJcug'. Preview of field's value: '{failureReason=Other., errorCode=0, additionalDetails=MFA requirement satisfied by claim in the token}'","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:1318"}}
thus i'm not receiving my logs that are in archive.log/json in the alerts.log/json file as i'm using a rule to trigger this kind of event (which works bacause i'm receiving the email alerts), so this logs aren't displayed on my dashboard.
So i tried to used a custom decoder based on the logs i sent on my first email :
<decoder name="ms-graph-log">
<prematch>^\.*->ms-graph {"integration":"ms-graph","ms-graph":</prematch>
</decoder>
<decoder name="ms-graph-child-log">
<parent>ms-graph-log</parent>
<regex offset="after_parent">^{"id":(\.*),"createdDateTime":(\.*),"userDisplayName":(\.*),"userPrincipalName":(\.*),"userId":(\.*),"appId":(\.*),"appDisplayName":(\.*),"ipAddress":(\.*),"clientAppUsed":(\.*),"correlationId":(\.*),"conditionalAccessStatus":(\.*),"isInteractive":(\.*),"riskDetail":(\.*),"riskLevelAggregated":(\.*),"riskLevelDuringSignIn":(\.*),"riskState":(\.*),"riskEventTypes":(\.*),"riskEventTypes_v2":(\.*),"resourceDisplayName":(\.*),"resourceId":(\.*),"status":{"errorCode":(\.*),"failureReason":(\.*).","additionalDetails":(\.*)},"deviceDetail":{"deviceId":(\.*),"displayName":(\.*),"operatingSystem":(\.*),"browser":(\.*),"isCompliant":(\.*),"isManaged":(\.*),"trustType":(\.*)},"location":{"city":(\.*),"state":(\.*),"countryOrRegion":(\.*),"geoCoordinates":{"altitude":(\.*),"latitude":(\.*),"longitude":(\.*)}},"appliedConditionalAccessPolicies":(\.*),"resource":(\.*),"relationship":(\.*)}}$</regex>
<order>integration,id,createdDateTime,userDisplayName,userPrincipalName,userId,appId,appDisplayName,ipAddress,clientAppUsed,correlationId,conditionalAccessStatus,isInteractive,riskDetail,riskLevelAggregated,riskLevelDuringSignIn,riskState,riskEventTypes,riskEventTypes_v2,resourceDisplayName,resourceId,errorCode,failureReason,additionalDetails,deviceId,displayName,operatingSystem,browser,isCompliant,isManaged,trustType,city,state,countryOrRegion,altitude,latitude,longitude,appliedConditionalAccessPolicies,resource,relationship</order>
</decoder>
i also used this rule :
<group name="MS-Graph">
<rule id="100102" level="13">
<decoded_as>ms-graph-log</decoded_as>
<description>ms-graph test.</description>
<options>alert_by_email</options>
</rule>
</group>
when i'm testing the decoder and rule with the
/var/ossec/bin/wazuh-logtest i get this :
LOG as i am receiving it in archive.log :
2024 Jun 13 16:49:44 glowazlp01->ms-graph {"integration":"ms-graph","ms-graph":{"id":"-a05d-3a28a59c1900","createdDateTime":"2024-06-13T14:44:42Z","userDisplayName":"8-b87b-a881a1f45655","userPrincipalName":"a881a1f45655","userId":"867d82b5a1f45655","appId":"ab1b-5451cc387264","appDisplayName":"Microsoft Teams","ipAddress":"77.105","clientAppUsed":"","correlationId":"4cd5-bfb8-0eb1d7c46d58","conditionalAccessStatus":"notApplied","isInteractive":true,"riskDetail":"hidden","riskLevelAggregated":"hidden","riskLevelDuringSignIn":"hidden","riskState":"none","riskEventTypes":[],"riskEventTypes_v2":[],"resourceDisplayName":"Office 365 Search Service","resourceId":"66a88757-258c-4c72-893c-3e8bed4d6899","status":{"errorCode":50074,"failureReason":"Strong Authentication is required.","additionalDetails":"User needs to perform multi-factor authentication. There could be multiple things requiring multi-factor, e.g. Conditional Access policies, per-user enforcement, requested by client, among others."},"deviceDetail":{"deviceId":"","displayName":"","operatingSystem":"Windows","browser":"Edge 18.19045","isCompliant":false,"isManaged":false,"trustType":""},"location":{"city":"","state":"","countryOrRegion":"","geoCoordinates":{"altitude":null,"latitude":null,"longitude":null}},"appliedConditionalAccessPolicies":[],"resource":"auditLogs","relationship":"signIns"}}
Result with logtest :
**Phase 1: Completed pre-decoding.
full event: '2024 Jun 13 16:49:44 glowazlp01->ms-graph {"integration":"ms-graph","ms-graph":{"id":"-a05d-3a28a59c1900","createdDateTime":"2024-06-13T14:44:42Z","userDisplayName":"8-b87b-a881a1f45655","userPrincipalName":"a881a1f45655","userId":"867d82b5a1f45655","appId":"ab1b-5451cc387264","appDisplayName":"Microsoft Teams","ipAddress":"77.105","clientAppUsed":"","correlationId":"4cd5-bfb8-0eb1d7c46d58","conditionalAccessStatus":"notApplied","isInteractive":true,"riskDetail":"hidden","riskLevelAggregated":"hidden","riskLevelDuringSignIn":"hidden","riskState":"none","riskEventTypes":[],"riskEventTypes_v2":[],"resourceDisplayName":"Office 365 Search Service","resourceId":"66a88757-258c-4c72-893c-3e8bed4d6899","status":{"errorCode":50074,"failureReason":"Strong Authentication is required.","additionalDetails":"User needs to perform multi-factor authentication. There could be multiple things requiring multi-factor, e.g. Conditional Access policies, per-user enforcement, requested by client, among others."},"deviceDetail":{"deviceId":"","displayName":"","operatingSystem":"Windows","browser":"Edge 18.19045","isCompliant":false,"isManaged":false,"trustType":""},"location":{"city":"","state":"","countryOrRegion":"","geoCoordinates":{"altitude":null,"latitude":null,"longitude":null}},"appliedConditionalAccessPolicies":[],"resource":"auditLogs","relationship":"signIns"}}'
timestamp: '2024 Jun 13 16:49:44'
**Phase 2: Completed decoding.
name: 'ms-graph-log'
additionalDetails: '""'
altitude: 'null'
appDisplayName: '"77.105"'
appId: '"Microsoft Teams"'
appliedConditionalAccessPolicies: '"auditLogs"'
browser: 'false'
city: '""'
clientAppUsed: '"4cd5-bfb8-0eb1d7c46d58"'
conditionalAccessStatus: 'true'
correlationId: '"notApplied"'
countryOrRegion: 'null'
createdDateTime: '"8-b87b-a881a1f45655"'
deviceId: '""'
displayName: '"Windows"'
errorCode: '"Strong Authentication is required'
failureReason: '"User needs to perform multi-factor authentication. There could be multiple things requiring multi-factor, e.g. Conditional Access policies, per-user enforcement, requested by client, among others."'
id: '"2024-06-13T14:44:42Z"'
integration: '"-a05d-3a28a59c1900"'
ipAddress: '""'
isCompliant: 'false'
isInteractive: '"hidden"'
isManaged: '""'
latitude: 'null'
longitude: '[]'
operatingSystem: '"Edge 18.19045"'
resource: '"signIns"'
resourceDisplayName: '"66a88757-258c-4c72-893c-3e8bed4d6899"'
resourceId: '50074'
riskDetail: '"hidden"'
riskEventTypes: '[]'
riskEventTypes_v2: '"Office 365 Search Service"'
riskLevelAggregated: '"hidden"'
riskLevelDuringSignIn: '"none"'
riskState: '[]'
state: '""'
trustType: '""'
userDisplayName: '"a881a1f45655"'
userId: '"ab1b-5451cc387264"'
userPrincipalName: '"867d82b5a1f45655"'
**Phase 3: Completed filtering (rules).
id: '100102'
level: '13'
description: 'ms-graph test.'
groups: '["MS-Graph"]'
firedtimes: '3'
mail: 'true'
**Alert to be generated.**Phase 1: Completed pre-decoding.
full event: '2024 Jun 13 16:49:44 glowazlp01->ms-graph {"integration":"ms-graph","ms-graph":{"id":"-a05d-3a28a59c1900","createdDateTime":"2024-06-13T14:44:42Z","userDisplayName":"8-b87b-a881a1f45655","userPrincipalName":"a881a1f45655","userId":"867d82b5a1f45655","appId":"ab1b-5451cc387264","appDisplayName":"Microsoft Teams","ipAddress":"77.105","clientAppUsed":"","correlationId":"4cd5-bfb8-0eb1d7c46d58","conditionalAccessStatus":"notApplied","isInteractive":true,"riskDetail":"hidden","riskLevelAggregated":"hidden","riskLevelDuringSignIn":"hidden","riskState":"none","riskEventTypes":[],"riskEventTypes_v2":[],"resourceDisplayName":"Office 365 Search Service","resourceId":"66a88757-258c-4c72-893c-3e8bed4d6899","status":{"errorCode":50074,"failureReason":"Strong Authentication is required.","additionalDetails":"User needs to perform multi-factor authentication. There could be multiple things requiring multi-factor, e.g. Conditional Access policies, per-user enforcement, requested by client, among others."},"deviceDetail":{"deviceId":"","displayName":"","operatingSystem":"Windows","browser":"Edge 18.19045","isCompliant":false,"isManaged":false,"trustType":""},"location":{"city":"","state":"","countryOrRegion":"","geoCoordinates":{"altitude":null,"latitude":null,"longitude":null}},"appliedConditionalAccessPolicies":[],"resource":"auditLogs","relationship":"signIns"}}'
timestamp: '2024 Jun 13 16:49:44'
**Phase 2: Completed decoding.
name: 'ms-graph-log'
additionalDetails: '""'
altitude: 'null'
appDisplayName: '"77.105"'
appId: '"Microsoft Teams"'
appliedConditionalAccessPolicies: '"auditLogs"'
browser: 'false'
city: '""'
clientAppUsed: '"4cd5-bfb8-0eb1d7c46d58"'
conditionalAccessStatus: 'true'
correlationId: '"notApplied"'
countryOrRegion: 'null'
createdDateTime: '"8-b87b-a881a1f45655"'
deviceId: '""'
displayName: '"Windows"'
errorCode: '"Strong Authentication is required'
failureReason: '"User needs to perform multi-factor authentication. There could be multiple things requiring multi-factor, e.g. Conditional Access policies, per-user enforcement, requested by client, among others."'
id: '"2024-06-13T14:44:42Z"'
integration: '"-a05d-3a28a59c1900"'
ipAddress: '""'
isCompliant: 'false'
isInteractive: '"hidden"'
isManaged: '""'
latitude: 'null'
longitude: '[]'
operatingSystem: '"Edge 18.19045"'
resource: '"signIns"'
resourceDisplayName: '"66a88757-258c-4c72-893c-3e8bed4d6899"'
resourceId: '50074'
riskDetail: '"hidden"'
riskEventTypes: '[]'
riskEventTypes_v2: '"Office 365 Search Service"'
riskLevelAggregated: '"hidden"'
riskLevelDuringSignIn: '"none"'
riskState: '[]'
state: '""'
trustType: '""'
userDisplayName: '"a881a1f45655"'
userId: '"ab1b-5451cc387264"'
userPrincipalName: '"867d82b5a1f45655"'
**Phase 3: Completed filtering (rules).
id: '100102'
level: '13'
description: 'ms-graph test.'
groups: '["MS-Graph"]'
firedtimes: '3'
mail: 'true'
**Alert to be generated.
My rule is triggered but nothing in alerts.log/json :/
Thank you for you help