Windows PowerShell Script Block Browser Cache Access

 Original Source: [splunk source]
Name:Windows PowerShell Script Block Browser Cache Access
id:6962e59a-907f-41fe-8688-9174bce89d31
version:1
date:None
author:Raven Tait, Splunk
status:production
type:Anomaly
Description:This analytic detects PowerShell Script Block Logging events that enumerate or read browser cache directories. PowerShell inspecting Firefox, Chrome, Edge, Brave, or Chromium cache files can indicate cache smuggling, where web content disguised as an image is extracted and staged for execution. The analytic looks for browser cache paths together with file enumeration or read operations, rather than relying on cache markers or a specific payload name.
Data_source:
  • -Powershell Script Block Logging 4104
search:`powershell`
EventCode=4104
ScriptBlockText IN (
"*Copy-Item *",
"*gci *",
"*Get-ChildItem *",
"*Get-Content *",
"*ReadAllBytes*",
"*ReadAllText*",
"*ReadBytes*",
"*Select-String*",
"*WriteAllBytes*"
)

ScriptBlockText IN (
"*Cache_Data*",
"*cache2*entries*"
)

| eval script_block=lower(ScriptBlockText)

| eval cache_family=case(
like(script_block, "%mozilla%firefox%profiles%") AND like(script_block, "%cache2%entries%"), "Firefox",
like(script_block, "%google%chrome%user data%") AND like(script_block, "%cache_data%"), "Chrome",
like(script_block, "%microsoft%edge%user data%") AND like(script_block, "%cache_data%"), "Edge",
like(script_block, "%bravesoftware%brave-browser%user data%") AND like(script_block, "%cache_data%"), "Brave",
like(script_block, "%user data%") AND like(script_block, "%cache_data%"), "Chromium"
)

| where isnotnull(cache_family)

| eval dest=coalesce(dest, Computer, dvc, host)
| eval user=coalesce(user, UserID, User)

| stats count min(_time) as firstTime
max(_time) as lastTime
values(cache_family) as cache_family
values(ScriptBlockText) as ScriptBlockText
values(Path) as Path values(Guid) as Guid

by dest user ScriptBlockId ProcessID signature signature_id

| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `windows_powershell_script_block_browser_cache_access_filter`


how_to_implement:To successfully implement this analytic, you will need to enable PowerShell Script Block Logging on some or all endpoints. Setup instructions can be found here, https://help.splunk.com/en/security-offerings/splunk-user-behavior-analytics/get-data-in/5.4.1/add-other-data-to-splunk-uba/configure-powershell-logging-to-see-powershell-anomalies-in-splunk-uba.
known_false_positives:Administrators or support scripts may inspect browser caches for troubleshooting, cleanup, or forensic analysis. Review the script content, user, host, and any subsequent file creation or script execution before disposition.
References:
  -https://attack.mitre.org/techniques/T1059/001/
  -https://attack.mitre.org/techniques/T1105/
  -https://attack.mitre.org/techniques/T1027/006/
  -https://sensepost.com/blog/2023/browsers-cache-smuggling/
  -https://x.com/MsftSecIntel/status/2106197481960706155
drilldown_searches:
 name:'View the detection results for - "$dest$" and "$user$"'
 search:'%original_detection_search% | search dest = "$dest$" user = "$user$"'
 earliest_offset:'$info_min_time$'
 latest_offset:'$info_max_time$'
 name:'View risk events for the last 7 days for - "$dest$" and "$user$"'
 search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$", "$user$") | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`'
 earliest_offset:'7d'
 latest_offset:'0'
analytic_story:['Browser Cache Smuggling', 'Malicious PowerShell']

asset_type:Endpoint

mitre_attack_id:['T1059.001', 'T1105', 'T1027.006']

product:['Splunk Enterprise', 'Splunk Enterprise Security', 'Splunk Cloud']

category:endpoint

security_domain:endpoint

tags:

tests:
 name:'True Positive Test'
 attack_data:
  data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1059.001/powershell_browser_cache_access/windows-powershell.log
  source: XmlWinEventLog:Microsoft-Windows-PowerShell/Operational
  sourcetype: XmlWinEventLog
 test_type:'unit'
manual_test:None