- from: shell
test: '(?:^|\s)curl\s+.*\|\s*(?:sudo\s+)?(bash|sh|zsh|fish|source\s)'
description: "Piping remote content directly to shell executes arbitrary code without inspection."
id: shell:curl_pipe_to_shell
severity: High
alternative: "curl -o script.sh <url> && cat script.sh"
alternative_info: "Download it and read it. Run it (`bash script.sh`) in a separate command once you have reviewed it."
- from: shell
test: '(?:^|\s)wget\s+.*-\S*O\s*-\s.*\|\s*(?:sudo\s+)?(bash|sh|zsh|fish)'
description: "Piping downloaded content to shell executes arbitrary code without inspection."
id: shell:wget_pipe_to_shell
severity: High
alternative: "wget -O script.sh <url> && cat script.sh"
alternative_info: "Download it and read it. Run it (`bash script.sh`) in a separate command once you have reviewed it."
- from: shell
test: '(?:^|\s)eval\s+"?\$\(curl'
description: "Evaluating remote content executes arbitrary code without inspection."
id: shell:eval_curl
severity: High
alternative: "curl -o script.sh <url> && cat script.sh"
alternative_info: "Download it and read it. Source it (`source script.sh`) in a separate command once you have reviewed it."
- from: shell
test: '(?:^|\s)(?:curl|wget)\s+.*\|\s*(?:sudo\s+)?(python[\d.]*|perl|ruby|node|nodejs|bun|deno|php|lua)\b'
description: "Piping remote content to an interpreter executes arbitrary code without inspection."
id: shell:curl_pipe_to_interpreter
severity: High
filters:
- type: NotMatches
value: '^(?:curl|wget)\s+[^|;&<>`()]*\|\s*python[\d.]*\s+(?:-m\s+json\.tool|-mjson\.tool)(?:\s+(?:--sort-keys|--tab|--compact|--no-ensure-ascii|--json-lines|--no-indent|--indent(?:=|\s+)\d+|-))*\s*$'
alternative: "curl -o script.py <url> && cat script.py"
alternative_info: "Download it and read it. Run it (`python script.py`) in a separate command once you have reviewed it."
- from: shell
test: '(?:^|\s)(?:(?:base64|base32)\s+(?:\S+\s+)*?(?:-d|--decode|-D)|xxd\s+(?:\S+\s+)*?-r|rev|(?:gzip|bzip2|xz|zstd)\s+(?:\S+\s+)*?-d|gunzip|zcat|openssl\s+(?:enc|base64)\s+(?:\S+\s+)*?-d)(?:\s.*)?\|\s*(?:sudo\s+(?:-\S+\s+)*)?(?:ba|z|da|k|fi)?sh(?:\s|$)'
description: "This decodes hidden text and runs it as shell commands, so you cannot see what it does."
id: shell:decode_pipe_to_shell
severity: High
alternative: "base64 -d <<< '<data>'"
alternative_info: "Decode and read the text first; run it only after reviewing it."
- from: shell
test: '^shellfirm-transformed-code\s'
description: "This runs (eval) text that is decoded or transformed first, so you cannot see the commands it runs."
id: shell:eval_transformed_text
severity: High
alternative: "echo \"$(<transform>)\""
alternative_info: "Print the decoded text and read it before running it."
- from: shell
test: '(?:^|\s)(?:(?:ba|z|da|k)?sh|source|\.|python[\d.]*|perl|ruby|node|php)\s+(?:-\S+\s+)*<\s*\(\s*(?:curl|wget)\b'
description: "This runs a downloaded script directly (process substitution) without inspection."
id: shell:process_substitution_remote
severity: High
alternative: "curl -o script.sh <url> && cat script.sh"
alternative_info: "Download it and read it. Run it (`bash script.sh`) in a separate command once you have reviewed it."
- from: shell
test: '^shellfirm-nesting-limit\s'
description: "The command is nested too deeply (eval / $( ) / bash -c inside each other) or is too large or malformed to be analyzed safely."
id: shell:nesting_too_deep
severity: High
- from: shell
test: '(?:^|\s)(?:(?:ba|z|da|k|mk|fi|c|tc)?sh|nu|elvish|xonsh|pwsh|powershell)\s+(?:-\S+\s+)*?-[a-zA-Z]*c\s+["'']?(?:\$\(|`)\s*(?:sudo\s+)?(?:curl|wget|fetch|aria2c|http|https|xh)\b'
description: "This downloads a script and runs it as shell code without inspection (`sh -c \"$(curl …)\"` is the same as `curl … | sh`)."
id: shell:shell_c_remote_script
severity: High
alternative: "curl -o script.sh <url> && cat script.sh"
alternative_info: "Download it and read it. Run it (`bash script.sh`) in a separate command once you have reviewed it."
- from: shell
test: '^shellfirm-unknown-shell-payload\s'
description: "This runs shell code that shellfirm cannot see before it runs (input lines executed as commands, as in `xargs -I{} sh -c '{}'`), so it cannot be checked."
id: shell:unknown_shell_payload
severity: High
- from: shell
test: '^shellfirm-function-depth-limit\s'
description: "This calls a shell function too large or too deeply nested for the shell hook to read ahead, so part of what it runs was not checked."
id: shell:function_depth_limit
severity: Medium
- from: shell
test: '(?i)(?:^|\s|\()(?:irm|iwr|Invoke-RestMethod|Invoke-WebRequest|curl|wget)\b[^;\n]*\|\s*(?:(?:iex|Invoke-Expression)\b|(?:pwsh|powershell)(?:\.exe)?\s+-(?:\s|$))|(?:^|\s)(?:iex|Invoke-Expression)\s*\$?\(?\s*\(?\s*(?:irm|iwr|Invoke-RestMethod|Invoke-WebRequest|New-Object\s+(?:System\.)?Net\.WebClient|\[(?:System\.)?Net\.WebClient\])\b|\.Download(?:String|Data)\s*\(|\[scriptblock\]::Create\s*\('
description: "This downloads a PowerShell script and runs it (Invoke-Expression) without inspection."
id: shell:powershell_download_exec
severity: High
alternative: "Invoke-WebRequest <url> -OutFile script.ps1; Get-Content script.ps1"
alternative_info: "Download it and read it. Run it (`./script.ps1`) in a separate command once you have reviewed it."
- from: shell
test: '(?i)(?:^|\s)(?:certutil(?:\.exe)?\s+(?:[-/]\S+\s+)*?[-/](?:urlcache|verifyctl)\b|bitsadmin(?:\.exe)?\s+(?:\S+\s+)*?/transfer\b|mshta(?:\.exe)?\s+(?:https?|javascript|vbscript):|regsvr32(?:\.exe)?\s+(?:/\S+\s+)*?/i:https?:)'
description: "This uses a Windows built-in tool (certutil, bitsadmin, mshta or regsvr32) to download and run code from a URL, bypassing normal download controls."
id: shell:lolbin_download_exec
severity: High
alternative: "Invoke-WebRequest <url> -OutFile file; Get-FileHash file"
alternative_info: "Download it to a file and inspect it before running."
- from: shell
test: '(?i)(?:^|\s)(?:pwsh|powershell)(?:\.exe)?\s+(?:\S+\s+)*?[-/]e(?:c|n(?:c(?:o(?:d(?:e(?:d(?:c(?:o(?:m(?:m(?:a(?:n(?:d)?)?)?)?)?)?)?)?)?)?)?)?)?[:\s=]+[A-Za-z0-9+/=]{8,}(?:\s|$)'
description: "This runs a PowerShell command hidden in base64 (-EncodedCommand), so you cannot see what it does."
id: shell:powershell_encoded_command
severity: High