Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

rules: supply-chain installs and credential token reads

Claudecfb09527b9d4
diff --git a/docs/detections/index.mdx b/docs/detections/index.mdx
index a0bda76c..a07907eb 100644
--- a/docs/detections/index.mdx
+++ b/docs/detections/index.mdx
@@ -51,13 +51,13 @@ beacon scan --fail-on high
Detections focus on risky agent behavior that is hard to understand from one raw log line alone:
-- **Credential access:** reads of `.env`, SSH keys, cloud credentials, browser session stores, shell history, process tables, Kubernetes kubeconfigs and service-account tokens, GPG private keyrings, or password-manager vaults (KeePass, 1Password, Bitwarden, LastPass, pass).
+- **Credential access:** reads of `.env`, SSH keys, cloud credentials, browser session stores, shell history, process tables, Kubernetes kubeconfigs and service-account tokens, GPG private keyrings, password-manager vaults (KeePass, 1Password, Bitwarden, LastPass, pass), OS keychain secret reads (`security find-generic-password -w`, `secret-tool lookup`), or a signed-in CLI printing a live token (`gcloud auth print-access-token`, `gh auth token`, `aws configure export-credentials`, `az account get-access-token`).
- **Context exfiltration:** network commands, paste and transfer services, DNS tunneling, Git bundles, outbound MCP calls, secret-bearing request bodies, SSH reverse-tunnel or SOCKS-proxy invocations, or archive-then-upload pipelines.
-- **Risky commands:** destructive shell operations, persistence installation (crontab, systemd timers, kernel modules), shell escapes, privileged container runs, curl-to-shell patterns, sudoers edits, root-equivalent changes, or history-rewriting git operations (filter-branch, filter-repo, rebase -i, force-push to protected branches).
+- **Risky commands:** destructive shell operations, persistence installation (crontab, systemd timers, kernel modules), shell escapes, privileged container runs, curl-to-shell patterns, packages installed from a URL, git ref or non-default index (`pip install git+https://…`, `--extra-index-url`, `npm i https://…tgz`), sudoers edits, root-equivalent changes, or history-rewriting git operations (filter-branch, filter-repo, rebase -i, force-push to protected branches).
- **Sensitive edits:** changes to CI pipelines, dependency manifests, shell startup files, authorization code, autostart units, agent instruction files, SSH authorized_keys or sshd_config, /etc/hosts or hosts.allow/deny, container or IaC files (Dockerfile, Terraform, Kubernetes manifests, Helm values), or other control surfaces.
- **Prompt injection:** instructions that try to override roles, ignore prior instructions, exfiltrate context, hide with invisible characters, or decode and execute hidden payloads.
- **Approval and policy abuse:** denied actions that still execute, high-risk approvals without a reason, attempts to spawn around runtime permission controls (agent CLIs launched with permission-elevating env vars, sandbox-escape primitives like nsenter / unshare / chroot / pivot_root), or re-invocations of denied commands through a renamed binary or temp-path shim.
-- **Agent runtime control:** spawns of known agent CLIs (Claude Code, Codex, Cursor Agent, Aider, Goose, OpenCode, Gemini) that arrive with permission-elevating env vars or attempt to hand off credentials or context to a second agent.
+- **Agent runtime control:** spawns of known agent CLIs (Claude Code, Codex, Cursor Agent, Aider, Goose, OpenCode, Gemini) that arrive with permission-elevating env vars or attempt to hand off credentials or context to a second agent, and MCP servers, plugins, marketplaces or extensions installed by command (`claude mcp add`, `codex mcp add`, `claude plugin install`, `gemini extensions install`).
- **Resource consumption:** unusually expensive single calls when token and cost telemetry are available, fork-bomb patterns (`:(){ :|:& };:`, `while true; do ... & done`), or disk-fill primitives (dd of /dev/zero to large targets, fallocate, yes-piped-to-file).
Because rules run over the shared Beacon event model, the same rule vocabulary can apply across supported harnesses when those harnesses emit the required fields.
@@ -70,15 +70,15 @@ Beacon ships with a small built-in baseline so `beacon scan` works before any ru
| Category | Example behaviors |
| --- | --- |
-| `credential-access` | Credential-file reads, browser session store reads, shell history scans, SSH agent enumeration, Kubernetes kubeconfig reads, GPG secret-key exports, password-manager vault reads |
+| `credential-access` | Credential-file reads, browser session store reads, shell history scans, SSH agent enumeration, Kubernetes kubeconfig reads, GPG secret-key exports, password-manager vault reads, OS keychain secret reads, cloud CLI token export |
| `context-exfiltration` | Secret read then egress, credentials in curl data, upload to paste or transfer sites, SSH tunnel egress, archive-then-upload pipelines |
-| `risky-command` | Curl piped to shell, recursive root delete, sudoers tampering, persistence installation, crontab modification, kernel-module load |
+| `risky-command` | Curl piped to shell, recursive root delete, sudoers tampering, persistence installation, crontab modification, kernel-module load, package install from an untrusted source |
| `sensitive-edit` | CI pipeline edits, dependency manifest edits, shell login file edits, agent control surface edits, SSH authorized_keys edits, /etc/hosts edits, container / IaC file edits |
| `prompt-injection` | Role override jailbreaks, hidden payloads, markdown-image exfiltration, instruction override markers, injected instructions in files, web pages, or MCP results the agent reads |
| `external-access` | Cloud metadata endpoint access, link-local target fetches, external MCP tool calls |
| `approval-abuse` | Permission-bypass execution or high-risk approvals without reviewer context, denied-command re-invocation through renamed binaries |
| `source-control` | Git hook installation, remote tampering, Git config execution injection, history rewriting (filter-branch / filter-repo / rebase -i), force-push to protected branches |
-| `agent-control` | Agent CLIs spawned with permission-elevating env vars, sandbox-escape primitives, inter-agent credential handoff |
+| `agent-control` | Agent CLIs spawned with permission-elevating env vars, sandbox-escape primitives, inter-agent credential handoff, MCP servers / plugins / extensions installed by command |
Rules only evaluate events that exist in the runtime log. For example, an MCP detection needs MCP-like activity to be emitted by a supported harness, and a prompt-injection rule needs retained prompt or content fields to be present under the endpoint's local data-retention settings.
diff --git a/rules/agent-control/agent-extension-installed-by-command.rule.yaml b/rules/agent-control/agent-extension-installed-by-command.rule.yaml
new file mode 100644
index 00000000..5faf1fb9
--- /dev/null
+++ b/rules/agent-control/agent-extension-installed-by-command.rule.yaml
@@ -0,0 +1,127 @@
+id: agent-extension-installed-by-command
+version: 1
+title: Agent extension (MCP server, plugin, marketplace) installed by command
+description: >
+ A command registers new code that an agent runtime will load on every later
+ session: an MCP server (claude/codex/gemini/qwen/opencode/kiro-cli/amp mcp add,
+ add-json, add-from-claude-desktop; code --add-mcp), a plugin or plugin marketplace
+ (claude plugin install, claude plugin marketplace add), or an extension (gemini
+ extensions install or link, code --install-extension). An agent that installs its
+ own extensions has widened what every future session can do, and a malicious skill
+ or injected instruction needs exactly this one step to persist.
+ agent-control-surface-modified catches the same outcome when the config file is
+ written directly; this rule catches the runtime's own installer doing it.
+severity: medium
+status: stable
+posture: detect
+taxonomy:
+ beacon_category: agent-control
+ owasp_llm: LLM03
+ mitre_atlas: AML.T0011
+
+match: >
+ e.event.action == "command.executed" && (
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?((npx|bunx|pnpm\\s+dlx)\\s+(-y\\s+)?)?([^\\s;&|]*/)?(claude(-code)?|codex|gemini(-cli)?|qwen(-code)?|opencode(-ai)?|kiro-cli|amp|cursor-agent|copilot)\\s+(mcp\\s+(add|add-json|add-from-claude-desktop|install)\\b|plugins?\\s+(install|add|i)\\b|plugins?\\s+marketplace\\s+add\\b|extensions?\\s+(install|link)\\b)") ||
+ e.command.command.matches("(?i)\\bcode(-insiders)?\\s+([^;&|\\n]*\\s)?--(add-mcp|install-extension)\\b")
+ )
+
+emit:
+ reason: "Agent extension installed by command (MCP server, plugin, marketplace or extension) \u2014 loads new code into every future session"
+
+tests:
+ - name: claude_mcp_add_stdio
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude mcp add helper -- npx -y helper-mcp" }
+ session: { id: s1 }
+ - name: claude_mcp_add_json_user_scope
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude mcp add-json -s user drop '{\"type\":\"http\",\"url\":\"https://mcp.example.test\"}'" }
+ session: { id: s1 }
+ - name: codex_mcp_add
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "codex mcp add docs -- uvx docs-mcp" }
+ session: { id: s1 }
+ - name: gemini_mcp_add
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gemini mcp add -s user files npx files-mcp" }
+ session: { id: s1 }
+ - name: claude_plugin_install
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude plugin install deploy@acme-tools" }
+ session: { id: s1 }
+ - name: claude_plugin_marketplace_add
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude plugin marketplace add someone/agent-plugins" }
+ session: { id: s1 }
+ - name: gemini_extension_install
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gemini extensions install https://github.com/someone/gemini-ext" }
+ session: { id: s1 }
+ - name: npx_wrapped_claude
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npx -y @anthropic-ai/claude-code mcp add x -- node /tmp/x.js" }
+ session: { id: s1 }
+ - name: chained_after_cd
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "cd /tmp && opencode mcp add x" }
+ session: { id: s1 }
+ - name: vscode_add_mcp
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "code --add-mcp '{\"name\":\"x\",\"command\":\"npx\",\"args\":[\"x-mcp\"]}'" }
+ session: { id: s1 }
+ - name: claude_mcp_list
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude mcp list" }
+ session: { id: s1 }
+ - name: claude_mcp_remove
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude mcp remove helper" }
+ session: { id: s1 }
+ - name: gemini_extensions_list
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gemini extensions list" }
+ session: { id: s1 }
+ - name: claude_plugin_marketplace_list
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "claude plugin marketplace list" }
+ session: { id: s1 }
+ - name: mentioned_in_echo
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "echo 'run claude mcp add to register it'" }
+ session: { id: s1 }
+ - name: vscode_open_file
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "code src/main.go" }
+ session: { id: s1 }
diff --git a/rules/credential-access/cloud-cli-token-export.rule.yaml b/rules/credential-access/cloud-cli-token-export.rule.yaml
new file mode 100644
index 00000000..ab2dd981
--- /dev/null
+++ b/rules/credential-access/cloud-cli-token-export.rule.yaml
@@ -0,0 +1,126 @@
+id: cloud-cli-token-export
+version: 1
+title: Cloud or forge CLI prints a live access token
+description: >
+ A command asks a signed-in CLI to print a usable bearer credential: gcloud auth
+ print-access-token or print-identity-token (also application-default), gh auth
+ token, aws configure export-credentials, az account get-access-token, vault print
+ token, heroku auth:token, doctl auth token, or kubectl create token. These never
+ touch a credential file, so credential-file-read cannot see them, but the output
+ is the same secret: a token the agent now holds in context and can send anywhere.
+ Legitimate uses exist (piping into docker login, a one-off API call), so review
+ what the token was used for in the same session.
+severity: medium
+status: stable
+posture: detect
+taxonomy:
+ beacon_category: credential-access
+ owasp_llm: LLM02
+ mitre_atlas: AML.T0024
+
+match: >
+ e.event.action == "command.executed" && (
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(gcloud\\s+auth\\s+(application-default\\s+)?print-(access|identity)-token\\b|gh\\s+auth\\s+token\\b|aws\\s+configure\\s+export-credentials\\b|az\\s+account\\s+get-access-token\\b|vault\\s+print\\s+token\\b|heroku\\s+auth:token\\b|doctl\\s+auth\\s+token\\b|kubectl\\s+create\\s+token\\b)") ||
+ e.command.command.matches("(?i)(\\bauth\\s+(application-default\\s+)?print-(access|identity)-token\\b|\\baccount\\s+get-access-token\\b|\\bconfigure\\s+export-credentials\\b|\\$\\(\\s*(gh\\s+auth\\s+token|vault\\s+print\\s+token|heroku\\s+auth:token|doctl\\s+auth\\s+token)\\b|\\[REDACTED\\]\\s+(auth\\s+token|print\\s+token|auth:token)\\b)")
+ )
+
+emit:
+ reason: "Signed-in CLI printed a live access token (gcloud/gh/aws/az/vault/heroku/doctl/kubectl) \u2014 a credential now in the agent's context"
+
+tests:
+ - name: gcloud_access_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gcloud auth print-access-token" }
+ session: { id: s1 }
+ - name: gcloud_adc_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gcloud auth application-default print-access-token" }
+ session: { id: s1 }
+ - name: gh_auth_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gh auth token" }
+ session: { id: s1 }
+ - name: aws_export_credentials
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "aws configure export-credentials --format env" }
+ session: { id: s1 }
+ - name: az_access_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "az account get-access-token --resource https://management.azure.com" }
+ session: { id: s1 }
+ - name: token_in_header_substitution
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "curl -H \"Authorization: Bearer $(gcloud auth print-access-token)\" https://storage.googleapis.com/storage/v1/b" }
+ session: { id: s1 }
+ - name: gh_token_piped
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gh auth token | docker login ghcr.io -u me --password-stdin" }
+ session: { id: s1 }
+ - name: gh_token_assigned
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "GH_TOKEN=$(gh auth token) ./scripts/release.sh" }
+ session: { id: s1 }
+ - name: gh_token_in_header
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "curl -H \"Authorization: token $(gh auth token)\" https://api.github.com/user" }
+ session: { id: s1 }
+ - name: vault_print_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "vault print token" }
+ session: { id: s1 }
+ - name: kubectl_create_token
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "kubectl create token default -n kube-system" }
+ session: { id: s1 }
+ - name: gcloud_auth_list
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gcloud auth list" }
+ session: { id: s1 }
+ - name: gh_auth_status
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gh auth status" }
+ session: { id: s1 }
+ - name: aws_whoami
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "aws sts get-caller-identity" }
+ session: { id: s1 }
+ - name: az_account_show
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "az account show" }
+ session: { id: s1 }
+ - name: grep_mentions_command
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "grep -rn 'print-access-token' docs/" }
+ session: { id: s1 }
diff --git a/rules/credential-access/os-keychain-secret-read.rule.yaml b/rules/credential-access/os-keychain-secret-read.rule.yaml
new file mode 100644
index 00000000..8f4466d8
--- /dev/null
+++ b/rules/credential-access/os-keychain-secret-read.rule.yaml
@@ -0,0 +1,103 @@
+id: os-keychain-secret-read
+version: 1
+title: Secret read from the OS keychain or secret service
+description: >
+ A command reads a stored secret out of the operating system's credential store:
+ macOS security find-generic-password or find-internet-password with -w or -g
+ (which print the password, not just the item's attributes) or dump-keychain -d;
+ Linux secret-tool lookup or search, or kwallet-query -r; Windows vaultcmd
+ /listcreds, PowerShell Get-StoredCredential, Get-Secret -AsPlainText, or the WinRT
+ PasswordVault. The keychain holds browser, Wi-Fi, VPN, Git and cloud CLI
+ credentials, so an agent reading one has stepped outside its project's secrets.
+ Commands that only list or describe items (find-identity, find-certificate,
+ find-generic-password without -w/-g, secret-tool store, cmdkey /list) do not fire.
+severity: high
+status: stable
+posture: detect
+taxonomy:
+ beacon_category: credential-access
+ owasp_llm: LLM02
+ mitre_atlas: AML.T0024
+
+match: >
+ e.event.action == "command.executed" && (
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(secret-tool\\s+(lookup|search)\\b|kwallet-query\\s+([^;&|\\n]*\\s)?(-r|--read-password)\\b|vaultcmd(\\.exe)?\\s+/listcreds\\b)") ||
+ e.command.command.matches("(?i)\\b(find-(generic|internet)-password\\b([^;&|\\n]*\\s)?-[a-z]*[wg][a-z]*\\b|dump-keychain\\b([^;&|\\n]*\\s)?-[a-z]*d[a-z]*\\b|get-storedcredential|get-secret\\s+([^;&|\\n]*\\s)?-asplaintext|\\[windows\\.security\\.credentials\\.passwordvault\\])")
+ )
+
+emit:
+ reason: "Secret read from the OS keychain or secret service (security -w, secret-tool lookup, kwallet-query, Windows Credential Manager)"
+
+tests:
+ - name: macos_generic_password_w
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-generic-password -s 'GitHub' -w" }
+ session: { id: s1 }
+ - name: macos_internet_password_g
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-internet-password -s github.com -g" }
+ session: { id: s1 }
+ - name: macos_dump_keychain_decrypt
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security dump-keychain -d ~/Library/Keychains/login.keychain-db" }
+ session: { id: s1 }
+ - name: macos_chained
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "TOKEN=$(security find-generic-password -a me -s npm -w) && echo ok" }
+ session: { id: s1 }
+ - name: linux_secret_tool_lookup
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "secret-tool lookup service github" }
+ session: { id: s1 }
+ - name: linux_kwallet_read
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "kwallet-query -r github kdewallet" }
+ session: { id: s1 }
+ - name: windows_vaultcmd
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "vaultcmd /listcreds:\"Windows Credentials\" /all" }
+ session: { id: s1 }
+ - name: powershell_get_secret_plaintext
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "Get-Secret -Name GitHubToken -AsPlainText" }
+ session: { id: s1 }
+ - name: macos_find_identity
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-identity -v -p codesigning" }
+ session: { id: s1 }
+ - name: macos_find_generic_attributes_only
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-generic-password -s 'GitHub'" }
+ session: { id: s1 }
+ - name: linux_secret_tool_store
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "secret-tool store --label=x service x" }
+ session: { id: s1 }
+ - name: windows_cmdkey_list
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "cmdkey /list" }
+ session: { id: s1 }
diff --git a/rules/risky-command/package-install-from-untrusted-source.rule.yaml b/rules/risky-command/package-install-from-untrusted-source.rule.yaml
new file mode 100644
index 00000000..ba12e50b
--- /dev/null
+++ b/rules/risky-command/package-install-from-untrusted-source.rule.yaml
@@ -0,0 +1,180 @@
+id: package-install-from-untrusted-source
+version: 1
+title: Package installed from a URL, git ref or non-default index
+description: >
+ A package manager installs code from somewhere other than its default public
+ registry: pip/pipx/uv/poetry from a git+ or https URL, a non-default --index-url,
+ or with --extra-index-url or --trusted-host (the dependency-confusion shape);
+ npm/pnpm/yarn/bun from a tarball URL, git URL or github: shorthand, or with a
+ non-default --registry; cargo install --git; gem install --source. Install scripts
+ run with the agent's permissions, and these sources skip the registry's name
+ ownership, so an injected instruction that names one is a direct supply-chain path
+ onto the machine. A private index the organization runs will also fire; that is
+ reviewable, not noise.
+severity: medium
+status: stable
+posture: detect
+taxonomy:
+ beacon_category: risky-command
+ owasp_llm: LLM03
+ mitre_atlas: AML.T0011
+
+match: >
+ e.event.action == "command.executed" && (
+ (
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b") && (
+ e.command.command.matches("(?i)\\s['\\\"]?(git\\+|[\\w.\\[\\],-]+\\s*@\\s*(git\\+)?(https?|ssh|git|file)://|(https?|ssh|git)://[^\\s'\\\"]*\\.(whl|tar\\.gz|tgz|tar\\.bz2|zip|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
+ e.command.command.matches("(?i)\\s(--extra-index-url|--trusted-host)(\\s|=)") ||
+ (e.command.command.matches("(?i)\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https://pypi\\.org/simple/?['\\\"]?(\\s|$)"))
+ )
+ ) || (
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(npm\\s+(install|i|add|ci)|pnpm\\s+(add|install|i)|yarn\\s+(global\\s+)?add|bun\\s+(add|install|i))\\b") && (
+ e.command.command.matches("(?i)\\s['\\\"]?(@?[\\w./-]+@)?(git\\+|github:|gitlab:|bitbucket:|gist:|git://|ssh://|https?://[^\\s'\\\"]*\\.(tgz|tar\\.gz|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
+ (e.command.command.matches("(?i)\\s--registry(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)\\s--registry(\\s+|=)['\\\"]?https://registry\\.(npmjs\\.org|yarnpkg\\.com)/?['\\\"]?(\\s|$)"))
+ )
+ ) ||
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cargo\\s+install\\s+([^;&|\\n]*\\s)?--git\\b|gem\\s+install\\s+([^;&|\\n]*\\s)?(--source|--clear-sources)\\b)")
+ )
+
+emit:
+ reason: "Package installed from a URL, git ref or non-default index/registry \u2014 install-time code from outside the default registry"
+
+tests:
+ - name: pip_git_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install git+https://github.com/someone/helper.git" }
+ session: { id: s1 }
+ - name: pip_name_at_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install 'helper @ https://files.example.test/helper-1.0.tar.gz'" }
+ session: { id: s1 }
+ - name: pip_custom_index
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip3 install --index-url https://pypi.example.test/simple requests" }
+ session: { id: s1 }
+ - name: pip_extra_index_dependency_confusion
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "python3 -m pip install --extra-index-url https://pkgs.example.test/simple internal-utils" }
+ session: { id: s1 }
+ - name: pip_trusted_host
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install --trusted-host pkgs.example.test -i http://pkgs.example.test/simple x" }
+ session: { id: s1 }
+ - name: uv_pip_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "uv pip install https://example.test/wheels/x-1.0-py3-none-any.whl" }
+ session: { id: s1 }
+ - name: npm_tarball_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm i https://example.test/pkg/helper-1.0.0.tgz" }
+ session: { id: s1 }
+ - name: npm_github_shorthand
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm install github:someone/helper" }
+ session: { id: s1 }
+ - name: pnpm_git_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pnpm add git+ssh://[email protected]/someone/helper.git" }
+ session: { id: s1 }
+ - name: yarn_custom_registry
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "yarn add helper --registry https://npm.example.test" }
+ session: { id: s1 }
+ - name: cargo_git
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "cargo install --git https://github.com/someone/tool" }
+ session: { id: s1 }
+ - name: gem_source
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gem install helper --source https://gems.example.test" }
+ session: { id: s1 }
+ - name: pip_from_pypi
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install requests==2.32.3" }
+ session: { id: s1 }
+ - name: pip_requirements
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install -r requirements.txt" }
+ session: { id: s1 }
+ - name: pip_editable_local
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install -e ." }
+ session: { id: s1 }
+ - name: pip_default_index_explicit
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install -i https://pypi.org/simple requests" }
+ session: { id: s1 }
+ - name: npm_registry_package
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm install express@4" }
+ session: { id: s1 }
+ - name: npm_scoped_package
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm i @types/node --save-dev" }
+ session: { id: s1 }
+ - name: npm_default_registry_explicit
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm install lodash --registry=https://registry.npmjs.org/" }
+ session: { id: s1 }
+ - name: npm_default_registry_space
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm install lodash --registry https://registry.npmjs.org" }
+ session: { id: s1 }
+ - name: pip_find_links_local_wheelhouse
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install --no-index -f ./wheels app" }
+ session: { id: s1 }
+ - name: cargo_crates_io
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "cargo install ripgrep" }
+ session: { id: s1 }
+ - name: git_clone_not_install
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "git clone https://github.com/someone/helper.git" }
+ session: { id: s1 }