Detection rules › Elastic

Sensitive File Access - Cloud Credentials

Time window
5m
Sequence by
process.entity_id
Source
github.com/elastic/protections-artifacts

Identifies an unusual process accessing common cloud providers credential files. Adversaries may search local file systems and remote file shares for files containing insecurely stored credentials.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies an unusual process accessing common cloud providers credential files. Adversaries may search local file
systems and remote file shares for files containing insecurely stored credentials.
"""
id = "39f60a36-8c5a-4703-8576-ad3e8c800a0f"
license = "Elastic License v2"
name = "Sensitive File Access - Cloud Credentials"
os_list = ["windows"]
reference = ["https://github.com/GhostPack/Seatbelt"]
version = "1.0.35"

query = '''
sequence by process.entity_id with maxspan=5m
   [process where event.action == "start" and
    user.id like ("S-1-5-21*", "S-1-12-*") and process.executable != null and 
    not (process.code_signature.subject_name : ("Johannes Schindelin", "Anaconda, Inc.") and process.code_signature.status == "trusted") and
    not (process.code_signature.subject_name : "Python Software Foundation" and
         process.executable : "?:\\Users\\*\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\bundledpython\\python.exe") and
    not process.executable :
          (
            /* third party programs common install path - requires local admin */
            "?:\\Program Files\\*",
            "?:\\Program Files (x86)\\*",

            /*
              dllhost.exe (IFileOperation like view/changing security permission of a file/folder).
              explorer.exe for directory and file discovery.
              SearchProtocolHost.exe is for file searches and indexing.
             */
            "?:\\Windows\\explorer.exe",
            "?:\\Windows\\System32\\dllhost.exe",
            "?:\\Windows\\System32\\SearchProtocolHost.exe",

            /* Windows Defender */
            "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*\\MsMpEng.exe",
            "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*\\MpCopyAccelerator.exe") and
    process.hash.sha256 != "0a8876ede7d2b65a5a0443831b2b4757d3519396a22bd55c20102bc67e6d16b3"]
   [file where event.type == "access" and
    /* non system accounts */
    user.id like ("S-1-5-21*", "S-1-12-*") and

    /* AWS/Google/Azure/Git cloud credential files */
    file.path : ("?:\\users\\*\\AppData\\*\\gcloud\\credentials.db",
                 "?:\\users\\*\\AppData\\*\\gcloud\\legacy_credentials",
                 "?:\\users\\*\\AppData\\*\\gcloud\\access_tokens.db",
                 "?:\\users\\*\\.azure\\accessTokens.json",
                 "?:\\users\\*\\.azure\\azureProfile.json",
                 "?:\\users\\*\\.azure\\msal_token_cache.json",
                 "?:\\users\\*\\.azure\\msal_token_cache.bin",
                 "?:\\users\\*\\.azure\\msal_http_cache.bin",
                 "?:\\users\\*\\.aws\\credentials",
                 "?:\\Users\\*\\.config\\git\\credentials")]
'''

min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1552"
name = "Unsecured Credentials"
reference = "https://attack.mitre.org/techniques/T1552/"
[[threat.technique.subtechnique]]
id = "T1552.001"
name = "Credentials In Files"
reference = "https://attack.mitre.org/techniques/T1552/001/"



[threat.tactic]
id = "TA0006"
name = "Credential Access"
reference = "https://attack.mitre.org/tactics/TA0006/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 5m, correlated by process.entity_id.

Stage 1: process

[process where event.action == "start" and
    user.id like ("S-1-5-21*", "S-1-12-*") and process.executable != null and
    not (process.code_signature.subject_name : ("Johannes Schindelin", "Anaconda, Inc.") and process.code_signature.status == "trusted") and
    not (process.code_signature.subject_name : "Python Software Foundation" and
         process.executable : "?:\\Users\\*\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\bundledpython\\python.exe") and
    not process.executable :
          (
            "?:\\Program Files\\*",
            "?:\\Program Files (x86)\\*",
            /*
              dllhost.exe (IFileOperation like view/changing security permission of a file/folder).
              explorer.exe for directory and file discovery.
              SearchProtocolHost.exe is for file searches and indexing.
             */
            "?:\\Windows\\explorer.exe",
            "?:\\Windows\\System32\\dllhost.exe",
            "?:\\Windows\\System32\\SearchProtocolHost.exe",
            "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*\\MsMpEng.exe",
            "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*\\MpCopyAccelerator.exe") and
    process.hash.sha256 != "0a8876ede7d2b65a5a0443831b2b4757d3519396a22bd55c20102bc67e6d16b3"]

Stage 2: file

[file where event.type == "access" and
    user.id like ("S-1-5-21*", "S-1-12-*") and
    file.path : ("?:\\users\\*\\AppData\\*\\gcloud\\credentials.db",
                 "?:\\users\\*\\AppData\\*\\gcloud\\legacy_credentials",
                 "?:\\users\\*\\AppData\\*\\gcloud\\access_tokens.db",
                 "?:\\users\\*\\.azure\\accessTokens.json",
                 "?:\\users\\*\\.azure\\azureProfile.json",
                 "?:\\users\\*\\.azure\\msal_token_cache.json",
                 "?:\\users\\*\\.azure\\msal_token_cache.bin",
                 "?:\\users\\*\\.azure\\msal_http_cache.bin",
                 "?:\\users\\*\\.aws\\credentials",
                 "?:\\Users\\*\\.config\\git\\credentials")]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.code_signature.statuseqtrustedexcludes:process.code_signature.status field:"process.code_signature.status" value:"trusted"
process.code_signature.subject_nameeqJohannes Schindelin, Anaconda, Inc.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Johannes Schindelin" field:"process.code_signature.subject_name" value:"Anaconda, Inc."
process.code_signature.subject_nameeqPython Software Foundationexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Python Software Foundation"
process.executablewildcard?:\Users\*\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exeexcludes:process.executable field:"process.executable" value:"?:\Users\*\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe"
process.executablewildcard?:\Program Files\*, ?:\Program Files (x86)\*, ?:\Windows\explorer.exe, ?:\Windows\System32\dllhost.exe, ?:\Windows\System32\SearchProtocolHost.exe, ?:\ProgramData\Microsoft\Windows Defender\Platform\*\MsMpEng.exe, ?:\ProgramData\Microsoft\Windows Defender\Platform\*\MpCopyAccelerator.exeexcludes:process.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
event.typeeq
  • access corpus 10 (elastic 10)
field:"event.type" kind:eq value:"access"
file.pathwildcard
  • ?:\Users\*\.config\git\credentials
  • ?:\users\*\.aws\credentials
  • ?:\users\*\.azure\accessTokens.json
  • ?:\users\*\.azure\azureProfile.json
  • ?:\users\*\.azure\msal_http_cache.bin
  • ?:\users\*\.azure\msal_token_cache.bin
  • ?:\users\*\.azure\msal_token_cache.json
  • ?:\users\*\AppData\*\gcloud\access_tokens.db
  • ?:\users\*\AppData\*\gcloud\credentials.db
  • ?:\users\*\AppData\*\gcloud\legacy_credentials
field:"TargetFilename" kind:wildcard
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.hash.sha256ne
  • 0a8876ede7d2b65a5a0443831b2b4757d3519396a22bd55c20102bc67e6d16b3
field:"Hashes" kind:ne value:"0a8876ede7d2b65a5a0443831b2b4757d3519396a22bd55c20102bc67e6d16b3"
user.idwildcard
  • S-1-12-* corpus 46 (elastic 46)
  • S-1-5-21* corpus 47 (elastic 47)
field:"user.id" kind:wildcard