Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crowdstrike: add userinfo enrichment support and map fields to ECS #8742

Merged
merged 3 commits into from Dec 19, 2023

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Dec 18, 2023

Proposed commit message

See title.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • [ ]

How to test this PR locally

Make the following change:

diff --git a/packages/crowdstrike/data_stream/fdr/_dev/deploy/tf/env.yml b/packages/crowdstrike/data_stream/fdr/_dev/deploy/tf/env.yml
index b795fcdeb..6e1f17f7a 100644
--- a/packages/crowdstrike/data_stream/fdr/_dev/deploy/tf/env.yml
+++ b/packages/crowdstrike/data_stream/fdr/_dev/deploy/tf/env.yml
@@ -7,3 +7,4 @@ services:
       - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
       - AWS_PROFILE=${AWS_PROFILE}
       - AWS_REGION=${AWS_REGION:-us-east-1}
+      - TF_VAR_eventbridge_role_arn=arn:aws:iam::144492464627:role/eb-scheduler-role-20231101165501426500000001

Then:

$ export AWS_DEFAULT_PROFILE=elastic-siem
$ aws-mfa --profile=elastic-siem
$ eval $(grep ^aws ~/.aws/credentials | gsed -r 's/^(aws[^ ]+) = (.*)$/export \U\1\E=\2/g')

(gsed is GNU sed so if on macos you will need to install that, is on linux s/gsed/sed/ in the command above)

Then test with elastic-package as normal.

Related issues

Screenshots

@@ -2,4 +2,4 @@
{"AgentLoadFlags":"0","AgentLocalTime":"1697054061","AgentTimeOffset":"12274.197","AgentVersion":"7.01.13921.0","BiosManufacturer":"Iris","BiosVersion":"vG17V.210105623/u64","ChassisType":"Other","City":"Hamilton","ComputerName":"MIVWIN21","ConfigBuild":"1007.3.0017312.1","ConfigIDBuild":"13921","Continent":"Europe","Country":"Iceland","FalconGroupingTags":"'FalconGroupingTags/Iceland'","FirstSeen":"1576097732.0","HostHiddenStatus":"Visible","MachineDomain":"iceland.bigbiz.local","OU":"Infrastructure for CM;Citrix BM","PointerSize":"8","ProductType":"3.0","SensorGroupingTags":"none","ServicePackMajor":"0","SiteName":"Mosfellsbær","SystemManufacturer":"Iris","SystemProductName":"IrOS","Time":"1697992773.787","Timezone":"Europe/Iceland","Version":"Windows Server 2022","aid":"ffffffff3c0846978560dbc0048d6555","aip":"42.7.15.32","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win"}
{"AgentLoadFlags":"0","AgentLocalTime":"1697069182","AgentTimeOffset":"-2275.344","AgentVersion":"7.01.13922.0","BiosManufacturer":"American Megatrends","BiosVersion":"FW29-234098","ChassisType":"Space-Saving","City":"Mumbai","ComputerName":"FEVWSA1-029","ConfigBuild":"1007.3.0017312.1","ConfigIDBuild":"13922","Continent":"Asia","Country":"India","FalconGroupingTags":"'FalconGroupingTags/India'","FirstSeen":"1592645590.0","HostHiddenStatus":"Visible","MachineDomain":"groot.org","OU":"PROD;Win10 Workstations;India;Offices","PointerSize":"8","ProductType":"1.0","SensorGroupingTags":"none","ServicePackMajor":"0","SiteName":"IO","SystemManufacturer":"Dell","SystemProductName":"Dell Note","Time":"1697992701.85","Timezone":"India/Mumbai","Version":"Windows 10","aid":"ffffffffc59c473aa7fcbbe7438082cb","aip":"42.7.16.195","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win"}
{"AgentLoadFlags":"1","AgentLocalTime":"1697735519","AgentTimeOffset":"15963.231","AgentVersion":"6.56.17010.0","BiosManufacturer":"Iris","BiosVersion":"vG17V.210105623/u64","ChassisType":"Other","City":"Chicago","ComputerName":"FEVWSN1-009","ConfigBuild":"1007.3.0017010.1","ConfigIDBuild":"17010","Continent":"North America","Country":"America","FalconGroupingTags":"none","FirstSeen":"1641998107.0","HostHiddenStatus":"Visible","MachineDomain":"groot.org","OU":"UAT;CAA;VDI;Global;Offices","PointerSize":"8","ProductType":"1.0","SensorGroupingTags":"none","ServicePackMajor":"0","SiteName":"BCL","SystemManufacturer":"Iris","SystemProductName":"IrOS","Time":"1697992762.221","Timezone":"America/Chicago","Version":"Windows ME","aid":"ffffffffac4148947ed68497e89f3308","aip":"16.15.12.10","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win"}
{"AgentLoadFlags":"1","AgentLocalTime":"1697775225","AgentTimeOffset":"15889.017","AgentVersion":"7.01.13922.0","BiosManufacturer":"Iris","BiosVersion":"vG17V.21040423/z64","ChassisType":"Other","City":"Chicago","ComputerName":"FEVWSN1-234","ConfigBuild":"1007.3.0017312.1","ConfigIDBuild":"13922","Continent":"North America","Country":"United States of America","FalconGroupingTags":"'FalconGroupingTags/AMERICA'","FirstSeen":"1628678052.0","HostHiddenStatus":"Visible","MachineDomain":"groot.org","OU":"Servers;America;Offices","PointerSize":"8","ProductType":"3.0","SensorGroupingTags":"none","ServicePackMajor":"0","SiteName":"BCL","SystemManufacturer":"Iris","SystemProductName":"IrOS","Time":"1697992719.22","Timezone":"America/Chicago","Version":"Windows Server 2021","aid":"ffffffff8be84591864008eb2e484920","aip":"16.15.12.10","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aid changed to hit an event that has both host and user metadata keys.

@@ -116,7 +116,7 @@
{"AuthenticationId":"999","ConfigBuild":"1007.3.0011603.1","ConfigStateHash":"3338885535","ContextTimeStamp":"1604855185.108","EffectiveTransmissionClass":"3","Entitlements":"15","ImageFileName":"\\Device\\HarddiskVolume1\\Windows\\System32\\gpsvc.dll","InterfaceGuid":"367ABB81-9844-35F1-AD32-98F038001003","InterfaceVersion":"131072","RpcClientProcessId":"219053851298","RpcClientThreadId":"22047924482692","RpcNestingLevel":"0","RpcOpNum":"19","ServiceDisplayName":"gpsvc","TargetProcessId":"224116976578","TargetThreadId":"22920092479704","TokenType":"1","UserName":"user7","aid":"ffffffff59514ea68b4693ddfb9b6643","aip":"67.43.156.13","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win","event_simpleName":"HostedServiceStarted","id":"ffffffff-1111-11eb-860c-0606af112d55","name":"HostedServiceStartedV2","timestamp":"1604855184068"}
{"ConfigBuild":"1007.3.0011603.1","ConfigStateHash":"3338885535","ContextTimeStamp":"1604855299.018","EffectiveTransmissionClass":"3","Entitlements":"15","ServiceDisplayName":"wuauserv","TargetProcessId":"661455186053","TargetThreadId":"24238019995551","aid":"ffffffff2b5a4bf5afc6682595faa016","aip":"67.43.156.13","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win","event_simpleName":"HostedServiceStopped","id":"ffffffff-1111-11eb-9b11-0602a5689467","name":"HostedServiceStoppedV1","timestamp":"1604855302512"}
{"AuthenticationId":"3443175","ConfigBuild":"1007.3.0011603.1","ConfigStateHash":"3338885535","ContextProcessId":"1091372257857","ContextThreadId":"36855848099771","ContextTimeStamp":"1604855227.625","DiskParentDeviceInstanceId":"PCI\\VEN_1179\u0026DEV_0113\u0026SUBSYS_00011179\u0026REV_01\\4\u00263ad42678\u00260\u002600E0","EffectiveTransmissionClass":"3","Entitlements":"15","FileEcpBitmask":"0","FileIdentifier":"f5ce07c6af67ec4ebe0846ff200bfc2f54f7020000002100","FileObject":"18446603341701082336","IrpFlags":"1028","IsOnNetwork":"0","IsOnRemovableDisk":"0","MajorFunction":"18","MinorFunction":"0","OperationFlags":"0","Size":"288041","TargetFileName":"\\Device\\HarddiskVolume3\\Users\\user12\\AppData\\Local\\Packages\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\TempState\\Downloads\\ex.pdf.8e41hf8.partial","TokenType":"1","aid":"ffffffff32cb4abc50bc133b31a69946","aip":"67.43.156.14","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win","event_simpleName":"PdfFileWritten","id":"ffffffff-1111-11eb-baea-02dccfbb7779","name":"PdfFileWrittenV11","timestamp":"1604855264313"}
{"AuthenticationId":"3783389","CommandLine":"\"C:\\WINDOWS\\system32\\backgroundTaskHost.exe\" -ServerName:App.AppXnme9zjyebb2xnyygh6q9ev6p5d234br2.mca","ConfigBuild":"1007.3.0012309.1","ConfigStateHash":"3998263252","EffectiveTransmissionClass":"3","Entitlements":"15","ImageFileName":"\\Device\\HarddiskVolume3\\Windows\\System32\\backgroundTaskHost.exe","ImageSubsystem":"2","IntegrityLevel":"4096","MD5HashData":"50d5fd1290d94d46acca0585311e74d5","ParentAuthenticationId":"3783389","ParentBaseFileName":"svchost.exe","ParentProcessId":"2439558094566","ProcessCreateFlags":"525332","ProcessEndTime":"","ProcessParameterFlags":"16385","ProcessStartTime":"1604855181.648","ProcessSxsFlags":"1600","RawProcessId":"22272","RpcClientProcessId":"2439558094566","SHA1HashData":"0000000000000000000000000000000000000000","SHA256HashData":"b8e176fe76a1454a00c4af0f8bf8870650d9c33d3e333239a59445c5b35c9a37","SessionId":"1","SourceProcessId":"2439558094566","SourceThreadId":"77538684027214","Tags":"41, 12094627905582, 12094627906234","TargetProcessId":"2450046082233","TokenType":"2","UserSid":"S-1-12-1-3697283754-1083485977-2164330645-2516515886","WindowFlags":"128","aid":"ffffffff655344736aca58d17fb570f0","aip":"67.43.156.14","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win","event_simpleName":"ProcessRollup2","id":"ffffffff-1111-11eb-8462-02ade3b2f949","name":"ProcessRollup2V18","timestamp":"1604855182022"}
{"AuthenticationId":"3783389","CommandLine":"\"C:\\WINDOWS\\system32\\backgroundTaskHost.exe\" -ServerName:App.AppXnme9zjyebb2xnyygh6q9ev6p5d234br2.mca","ConfigBuild":"1007.3.0012309.1","ConfigStateHash":"3998263252","EffectiveTransmissionClass":"3","Entitlements":"15","ImageFileName":"\\Device\\HarddiskVolume3\\Windows\\System32\\backgroundTaskHost.exe","ImageSubsystem":"2","IntegrityLevel":"4096","MD5HashData":"50d5fd1290d94d46acca0585311e74d5","ParentAuthenticationId":"3783389","ParentBaseFileName":"svchost.exe","ParentProcessId":"2439558094566","ProcessCreateFlags":"525332","ProcessEndTime":"","ProcessParameterFlags":"16385","ProcessStartTime":"1604855181.648","ProcessSxsFlags":"1600","RawProcessId":"22272","RpcClientProcessId":"2439558094566","SHA1HashData":"0000000000000000000000000000000000000000","SHA256HashData":"b8e176fe76a1454a00c4af0f8bf8870650d9c33d3e333239a59445c5b35c9a37","SessionId":"1","SourceProcessId":"2439558094566","SourceThreadId":"77538684027214","Tags":"41, 12094627905582, 12094627906234","TargetProcessId":"2450046082233","TokenType":"2","UserSid":"S-1-12-1-3697283754-1083485977-2164330645-2516515886","WindowFlags":"128","aid":"ffffffff655344736aca58d17fb570f0","aip":"67.43.156.14","cid":"ffffffff30a3407dae27d0503611022d","event_platform":"Win","event_simpleName":"ProcessRollup2","id":"ffffffff-1111-11eb-8462-02ade3b2f949","name":"ProcessRollup2V18","timestamp":"1601546312519"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp changed to bring it to the front of the queue and become the sample event.

preserve_original_event: true
keep_metadata: true
assert:
hit_count: 131
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

125 events, 5 aidmaster records and 1 userinfo record.

@elasticmachine
Copy link

elasticmachine commented Dec 18, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-12-19T11:21:12.300+0000

  • Duration: 25 min 2 sec

Test stats 🧪

Test Results
Failed 0
Passed 35
Skipped 0
Total 35

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

elasticmachine commented Dec 18, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (2/2) 💚
Files 100.0% (15/15) 💚
Classes 100.0% (15/15) 💚
Methods 95.918% (94/98) 👎 -4.082
Lines 87.718% (3628/4136) 👎 -10.346
Conditionals 100.0% (0/0) 💚

@elasticmachine
Copy link

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@efd6 efd6 marked this pull request as ready for review December 18, 2023 10:33
@efd6 efd6 requested a review from a team as a code owner December 18, 2023 10:33
@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

- append:
field: related.user
value: "{{{crowdstrike.info.user.User}}}"
ignore_failure: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can ignore_failure be removed from this processor, since you already have a conditional null check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Was following the pattern of the appends above.

},
"user": {
"AccountType": "Domain User",
"LastLoggedOnHost": "COMPUTER1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also a good candidate for related.hosts? Not sure, just checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. Will do that.

@efd6 efd6 requested a review from kcreddy December 19, 2023 11:21
Copy link
Contributor

@kcreddy kcreddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

@efd6 efd6 merged commit 7762d45 into elastic:main Dec 19, 2023
4 checks passed
@elasticmachine
Copy link

Package crowdstrike - 1.28.0 containing this change is available at https://epr.elastic.co/search?package=crowdstrike

1 similar comment
@elasticmachine
Copy link

Package crowdstrike - 1.28.0 containing this change is available at https://epr.elastic.co/search?package=crowdstrike

v1v added a commit that referenced this pull request Dec 21, 2023
* upstream/main: (117 commits)
  [TI MISP] Add IOC expiration support (#8639)
  Add CSPM Rules 6.2, 6.3 and 6.4 (#8778)
  [Infoblox NIOS] Update timestamp parsing logic (#8767)
  [Rapid7 InsightVM] Split vulnerability categories into array (#8768)
  [Exchange Online Message Trace] Add Additional Look-back Time & Fix Cursor Value (#8717)
  [Buildkite] Update bucket settings (#8765)
  Remove Jenkins .ci folder (#8766)
  First part of removal of Jenkins jobs (#8763)
  misp: parse URIs for URI type threats (#8760)
  [amazon_security_lake] Added support for all the OCSF Classes (#8579)
  [Buildkite] Update settings for integrations pipeline (#8758)
  [TI ThreatQ] Add IOC expiration support (#8691)
  [ti_opencti] Support OpenCTI 5.12 by removing filters parameter (#8744)
  [Cribl] Updating setup guidance for Cribl field (#8746)
  crowdstrike: add userinfo enrichment support and map fields to ECS (#8742)
  [etcd] Enable TSDB for metrics datastream (#8649)
  Bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#8749)
  auditd: relax field_split pattern and handle AVC header (#8748)
  Update cloud packages codeowner (#8672)
  [O11Y] [AWS Billing] Convert "Total Estimated Charges" visualization to new metric (#8509)
  ...
@mbudge
Copy link

mbudge commented Jan 5, 2024

After upgrading 2 days ago, many ProcessRollup2 events are missing the username within the last 24 hours. It looks like the user enrichment isn't working as expected.

Here's some metrics which show how the user enrichment is working over the last 24 hours.

event.action:ProcessRollup2 and user.id: S-1-5-21* and not user.name:* = 1,678,329 hits

event.action:ProcessRollup2 and user.id: S-1-5-21* and user.name:* = 292,066 hits

Here's some other events which could improve the enrichment process. Crowdstrike previously told us to use the UserIdentity event for username enrichment.

UserIdentity
UserLogon
UserLogoff
UserInformationEtw

UserIdentity
Description
Platforms: Linux, Forensics
Platforms: Windows, macOS
The UserIdentity event is generated when a user logs in to a host. It conveys important security-related characteristics associated with a user to the CrowdStrike cloud, such as the user name. It’s normally generated once per security principal, and is thus not on its own a sign of a suspicious activity.

UserLogon
Description
Platforms: Linux, Windows, macOS
This event is generated when a user logs on to a host.

UserLogoff
Description
Platforms: Linux, ChromeOS
Platforms: Windows, macOS
This event is generated when a user logs off from a host.

UserInformationEtw
Description
Platforms: Windows
An event that indicates the password of a user was changed or set and other user information taken from UserLogonEtw.

@mbudge
Copy link

mbudge commented Feb 8, 2024

Just a reminder this doesn't work.

We have 20 million logs in the last 24 hours with where crowdstrike.AuthenticationId:*

17 million logs have no user.name which means enrichment isn't working for the majority.

Another view is ProcessRollup2

crowdstrike.AuthenticationId:* and not user.name:* = 14,092,401 hits where enrichment isn't working

crowdstrike.AuthenticationId:* and user.name:* = 1,178,348 hits

Crowdstrike told us to use the UserIdentity event for enrichment.

@tsqrd
Copy link

tsqrd commented Feb 9, 2024

To add on to @mbudge, that UserInfo dataset only exists if you have Falcon Discover. Additionally the current implementation only "works" for Windows. Seems like it would be feasible to build the cache based on UserLogon event types, which include the Host/AID-->SID/UID-->UserName mapping required for the enrichment to work properly.

@Rockso
Copy link

Rockso commented Feb 23, 2024

@mbudge @tsqrd I took a try at at improving the user enrichment by modifying the elastic-agent processor that comes in the fdr config to utilize UserIdentity and UserLogon events. I opted to build the userinfo (useridentity_Win/useridentity_Lin) caches with the aid_SID/UID (windows/Linux) with the reported username and then match it up to the aid_SID/UID to other events if those two values exist, but not overwriting events that match but already have a UserName field. Feel free to tweak as necessary. So far it's been working for me using the default ingest pipelines.

fdr.enrich.processor.txt

@mbudge
Copy link

mbudge commented Mar 1, 2024

@mbudge @tsqrd I took a try at at improving the user enrichment by modifying the elastic-agent processor that comes in the fdr config to utilize UserIdentity and UserLogon events. I opted to build the userinfo (useridentity_Win/useridentity_Lin) caches with the aid_SID/UID (windows/Linux) with the reported username and then match it up to the aid_SID/UID to other events if those two values exist, but not overwriting events that match but already have a UserName field. Feel free to tweak as necessary. So far it's been working for me using the default ingest pipelines.

fdr.enrich.processor.txt

I'm testing the processor now. Another improvement for UserIdentity event caching could be crowdstrike.info.host.MachineDomain as well as host.name, where MachineDomain != "none". Obvs this would cache the user.name the first time it's seen on the domain.

@Rockso
Copy link

Rockso commented Mar 8, 2024

I did consider adding the domain name information but didn't think it was overly useful in my use cases as you can differentiate a local user from a domain user based on the SID length. But yes it would be useful for others.

Also, I'm noticing that when UserID/UserName mapping is not in the cache the enrichment script doesn't add the hostname field. I Need to build some logic around that.... Or reorder it.... Still investigating but I did notice this issue come up with missing host.name enrichment for certain conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crowdstrike FDR user enrichment
6 participants