Multiple Credential Access by VS Code or Cursor IDE Descendant
Description
Detects a process descended from Visual Studio Code or Cursor opening at least two distinct sensitive files, such as browser credential stores, cloud tokens, or SSH and package-manager secrets. Malicious IDE extensions use the editor process tree to harvest more than one credential store in a single session.
Query · esql
FROM logs-endpoint.events.process-*, logs-endpoint.events.file-*
METADATA _id, _index, _version
// Normalize sensitive filenames for case-insensitive matching.
| EVAL sensitive_name = TO_LOWER(file.name)
// Identify processes launched by VS Code or Cursor.
| EVAL is_editor_spawn =
event.dataset == "endpoint.events.process"
AND process.parent.name IN (
"Code",
"Code.exe",
"Code Helper",
"Code Helper (Plugin)",
"code",
"Cursor",
"Cursor.exe",
"Cursor Helper",
"Cursor Helper (Plugin)",
"cursor"
)
// Identify sensitive file-open events.
| EVAL is_sensitive_read =
event.dataset == "endpoint.events.file"
AND MV_CONTAINS(event.action, "open")
AND sensitive_name IN (
"logins.json", "login data", "local state",
"signons.sqlite", "cookies", "cookies.sqlite",
"cookies.binarycookies", "token",
"credentials.db", "credentials", "credentials.toml",
"access_tokens.db", "accesstokens.json",
"azureprofile.json", "rdcman.settings",
"keepass.config.xml", ".npmrc", "auth.json", ".vault-token",
"application_default_credentials.json"
)
// Retain editor-associated process events and sensitive file opens.
| WHERE host.id IS NOT NULL
AND (is_editor_spawn OR is_sensitive_read)
// Capture editor parent entity IDs as ancestry anchors.
| EVAL editor_anchor_id = CASE(
is_editor_spawn, process.parent.entity_id, NULL
)
// Share editor ancestor IDs within each host.
| INLINE STATS
editor_anchor_ids = VALUES(editor_anchor_id)
BY host.id
// Retain sensitive file opens with valid process identity and ancestry.
| WHERE is_sensitive_read
AND process.Ext.ancestry IS NOT NULL
AND process.entity_id IS NOT NULL
// Match file-opening processes to VS Code or Cursor ancestors.
| EVAL editor_ancestor_ids = MV_INTERSECTION(
editor_anchor_ids, process.Ext.ancestry
)
| WHERE editor_ancestor_ids IS NOT NULL
// Require at least 2 distinct sensitive filenames per process.
| INLINE STATS
unique_sensitive_files = COUNT_DISTINCT(sensitive_name),
Esql.file_names = VALUES(sensitive_name)
BY host.id, process.entity_id
| WHERE unique_sensitive_files >= 2
// Preserve event-level investigation context.
| KEEP
@timestamp,
host.id, host.name, host.os.type,
user.name,
event.action, event.outcome,
file.name, Esql.file_names, file.path,
unique_sensitive_files,
process.entity_id, process.name, process.executable,
editor_ancestor_ids,
_id, _index, _version
Investigation fields
Pivot points the source recommends for triage.
host.namehost.os.typeuser.nameprocess.nameprocess.executablefile.namefile.pathEsql.file_names
Implementation guide
This rule is designed for data generated by Elastic Defend, which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
Setup instructions: https://ela.st/install-elastic-defend
Analyst notes
Investigating Multiple Credential Access by VS Code or Cursor IDE Descendant
A process whose ancestry includes Visual Studio Code or Cursor opened at least two different sensitive files. The files
include browser stores (logins.json, Login Data, Cookies), cloud and token files, and SSH or package-manager
secrets. One such file can be normal for a language server or CLI. Two or more in the same process is credential
harvesting behavior associated with a malicious extension or a prompt-injected agent.
Possible investigation steps
- Review
Esql.file_namesandfile.pathfor which stores were opened and whether the paths sit under a browser profile,.aws,.ssh,.azure, or an npm/vault config directory. - Review
process.executable,process.command_line, andprocess.parent.command_lineforextensionHostor a path under.vscode/extensionsor.cursor/extensions. - Identify the extension id from that path and compare it with the installed extension.
- On the same host and user, look for a preceding VSIX install, a suspicious shell spawned by
Code.exeorCursor, and outbound connections from the same process.
False positive analysis
- Developer tools launched by the IDE can read
known_hostsand.npmrc, or bothcredentialsandcredentials.toml, during normal git, npm, or cloud CLI use. Confirm the process path and the two file names before excluding. - Scope exceptions to a known process executable, extension path, host, or user. Do not broadly exclude
Code.exeorCursor.
Response and remediation
- If the access is unapproved, stop the process, uninstall the extension, and disconnect the host from networks that hold the exposed accounts.
- Rotate the credentials in the opened files, including browser passwords, cloud tokens, SSH keys, and npm or vault tokens.
- Hunt
Esql.file_namesand the process executable on other hosts.