Open-source guardrail
Running decoded or unpacked text as a command
AgentTrail Guard asks you about this by default: you decide before the call runs. Where an agent cannot ask, the call is refused instead.
- Default action
- Ask
- Severity
- High severity
- Library version
- 0.2.16 · Nov 26, 2026
Mapped to the OWASP Top 10s
An id names a risk this guardrail addresses where it becomes a command or a file read or write, never the whole risk.
What it does
What it catches, and what it misses
Written into the rule itself, next to what it matches, so you can judge it before you trust it.
Holds a command that decodes or unpacks text and runs it, because no other guardrail can see what the encoded text does. Decoders: base64/base32/basenc with a decode flag (-d, -D, -di, -id, --decode), openssl … -d, xxd -r, uudecode, the decompressors (gunzip, zcat, bzcat, xzcat, zstdcat, gzip -d, --decompress, --uncompress, …), a ROT13 tr, and Perl, Ruby, Python, Node or PHP one-liners that decode base64. A decoder's arguments and the stages after it are read up to 999 characters. Caught when the result is piped (| or |&, through any number of pipes, a line break after a pipe included) into a shell or interpreter that reads its program from stdin (no script argument, or -, -s, --, or a stdin path: /dev/stdin, /dev/fd/0, /proc/self/fd/0; . and source only with a stdin path and no wrapper, since they are builtins), after a wrapper by name or path (sudo, doas, env, /usr/bin/env, nice, time, timeout, command, exec, stdbuf, nohup) and up to six of its arguments on the same line and in the same command, with any blanks, and up to the end of the segment (a separator, a line break, # or a redirect); handed to sh -c with any flags before it (bash --norc -c, sh -c --), eval, source <(…), a process substitution, a here-string (<<< "$(…)") or command position as $(…) (at the start, or after a separator, a line break, {, !, then, do or else); or piped to xargs into a shell. Also: a Python, Node, Perl or Ruby one-liner that decodes and execs or evals, PowerShell -EncodedCommand (any prefix, any dash), FromBase64String with iex or [scriptblock]::Create, and certutil -decode followed by running a script in the same command. Not held: decoding to a file or into a reader (base64 -d f > out.bin, | jq, | shasum, | grep), into an interpreter that runs a script or a program given with -c or -e (| python3 -m json.tool, | python3 parse.py, | python3 -c '…json.load(sys.stdin)', | perl -ne '…'), a plain tr or rev, encoding, and printing the decoded text. Held, not blocked: unpacking a script and running it is occasionally legitimate, and a person can see the command. Known misses: decoded text written to a file and run by a later command, a decoder nested four $( deep ($(a $(b $(c $(base64 -d f))))), decoding inside a script, rev or a non-rotation tr (a bracketed ROT13 tr '[a-z]' '[n-za-m]' too), other encodings and unpackers (unzip -p, tar -xO, lzcat, lz4 -d, brotli -d, pigz -d, 7z -so, gpg -d, printf %b, echo -e), a decoder or shell word quoted or escaped (| "sh", | \sh, | b''ash) or held in a variable (| $SHELL), other shells and runners (ash, mksh, fish, csh, busybox sh, setsid, ionice, unbuffer, builtin, chroot, script, parallel, tee >(sh)), a wrapper with more than six arguments, a shell flag that takes a value (bash -o posix), a backslash-newline before a redirect after the shell, a stdin path other than fd 0 (/dev/fd/3) or followed by an argument, a positional argument after -- (bash -s -- arg), a Python, Node or PHP one-liner with ; inside its quotes, a $(…) after a wrapper (sudo $(…)) or held in a variable, a here-document that holds $(…) without a shell before it, PowerShell's decode and iex on separate lines, and anything a variable holds. Known over-matches: any other /dev/ or /proc/ path after the shell (| sh /dev/null), and a long flag that starts like --d (base64 --add-padding). This is one cheap shape; isolation at the operating-system level is the answer to encoded payloads in general. A quoted MENTION is not a use: a search, a git commit -m message, an echo or a curl --data body that only names this command is left alone.
Examples
Tested on every build
The rule must match every command on the left and none on the right, or the library does not build. Catching the real thing is easy; staying quiet on the near-miss is the hard part.
Catches (92)
- echo cm0gLXJmIC8K | base64 -d | sh
- echo cm0gLXJmIC8K | base64 --decode | bash
- echo cm0gLXJmIC8K | base64 -D | sh
- base64 -d f |& bash
- base64 -id f | sh
- openssl enc -base64 -d -in x | bash
- xxd -r -p x.hex | bash
- zcat x.gz | /bin/bash
- gzip -dc x.gz | sh
- echo x | tr a-zA-Z n-za-mN-ZA-M | sh
- echo x | base64 -d | gunzip | sh
- echo x | base64 -d | python3 -
- echo x | base64 -d | node
- base64 -d f | env bash
- base64 -d f | env -i X=1 bash -s
- base64 -d f | sudo -E bash -
- echo x | base64 -d | nice bash
- echo x | base64 -d | nice -n 10 bash
- echo x | base64 -d | timeout 5 sh
- echo x | base64 -d | command sh
- echo x | base64 -d | doas sh
- echo x | base64 -d | exec bash
- echo x | base64 -d | stdbuf -oL bash
- echo x | base64 -d | sudo -u root sh
- echo x | base64 -d | doas -u root sh
- echo x | base64 -d | nohup bash
- echo x | base64 -d | sudo -E env -i nice -n 5 bash
- base64 -d f | sh echo done
- base64 -d f | sh echo done
- base64 -d f | sh # run it
- base64 -d f | sh 2>&1
- base64 -d f | sh </dev/null
- base64 -d f | bash > out.log
- base64 -d f | sh
- base64 -d f | sh
- base64 -d x | sh
- base64 -d f | sh
- base64 -d /tmp/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | sh
- base64 -d f | grep -v xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | sh
- base64 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -w0 -d f | sh
- xxd -p -c 256 -c 256 -c 256 -c 256 -c 256 -c 256 -c 256 -c 256 -c 256 -c 256 -r f | sh
- echo x | base64 -d | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | sh
- base64 -d f | sh /dev/stdin
- base64 -d f | bash /dev/fd/0
- base64 -d f | bash /proc/self/fd/0
- base64 -d f | python3 /dev/stdin
- base64 -d f | . /dev/stdin
- base64 -d f | source /dev/stdin
- base64 -d f | /usr/bin/env sh
- base64 -d f | /usr/bin/sudo sh
- base64 -d f | time sh
- bash -c "base64 -d f | sh"
- sh -c 'zcat x.gz | bash -s'
- cat f | base64 -di | sh
- cat f | base64 --d | sh
- cat f | base32 -d | sh
- cat f | gzip --decompress -c | sh
- cat f | gzip --uncompress | sh
- cat f | xz --decompress | sh
- cat f | zstd --decompress | sh
- cat f | bzip2 --decompress | sh
- sh -c "$(echo x | base64 -d)"
- bash -lc "$(base64 -d f)"
- sh -c "`echo x | base64 -d`"
- bash <(echo x | base64 -d)
- eval "$(echo x | base64 -d)"
- bash <<< "$(echo x | base64 -d)"
- base64 -d f | xargs bash -c
- base64 -d f | bash -c "$(cat)"
- bash --norc -c "$(base64 -d f)"
- bash -e -c "$(base64 -d f)"
- sh -c -- "$(base64 -d f)"
- eval -- "$(base64 -d f)"
- echo hi $(base64 -d f)
- if :; then $(base64 -d f); fi
- { $(base64 -d f); }
- ! $(base64 -d f)
- sh <<< "$(xxd -r -p f)"
- sh <<< "$(zcat x.gz)"
- bash <<EOF $(base64 -d f) EOF
- perl -MMIME::Base64 -e 'print decode_base64($x)' | sh
- node -e "process.stdout.write(Buffer.from(x,'base64'))" | sh
- python3 -c "exec(__import__('base64').b64decode('eA=='))"
- python3 -c "import base64,os;os.system(base64.b64decode('eA=='))"
- node -e "eval(Buffer.from('eA==','base64').toString())"
- PowerShellpowershell -enc ZQBjAGgAbwA=
- PowerShellpwsh -EncodedCommand ZQBjAGgAbwA=
- PowerShellpwsh –EncodedCommand ZQBjAGgAbwA=
- PowerShellpowershell.exe -e ZQBjAGgAbwA=
- PowerShell[scriptblock]::Create([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('eA==')))
- certutil -decode a.b64 a.bat & a.bat
- MCP{"command":"echo x | base64 -d | sh"}
Stays quiet on (42)
- git commit -m "docs: explain echo x | base64 -d | sh"
- grep -rn "echo x | base64 -d | sh" docs/
- echo "never run echo x | base64 -d | sh"
- curl --data "we ran echo x | base64 -d | sh" https://api.example.com/comments
- echo x | base64 -d > out.bin
- base64 -d <<< eA== | jq .
- base64 -d secret.b64 | shasum -a 256
- cat /dev/urandom | head -c 16 | base64
- gunzip -c logs.gz | grep ERROR
- echo $JWT | base64 -d | python3 -m json.tool
- zcat x.gz | python3 parse.py
- zcat x.gz | nice python3 parse.py
- base64 -d f | sh ./run.sh
- base64 -d f | bash /tmp/x.sh
- base64 -d f | grep -c sh
- base64 -w0 f | sh
- base64 -d <<< "$P" | python3 -c 'import json,sys; print(json.load(sys.stdin))'
- echo $JWT | cut -d. -f2 | base64 -d | python3 -c "import sys,json;print(json.load(sys.stdin))"
- base64 -d f | node -e 'process.stdin.pipe(process.stdout)'
- zcat x.gz | perl -ne 'print if /ERR/'
- zcat x.gz | ruby -e 'puts STDIN.read.size'
- base64 -d f | sh -c 'cat > out.bin'
- zcat dump.gz | sudo tar -x -C .
- gunzip -c x.tgz | nice tar x -C .
- zcat a.gz | env > e.txt; git add .
- zcat a.gz | sudo tee out.txt; git add .
- zcat a.gz | nice -n 19 python3 analyze.py .
- gunzip -c a.gz | time wc -l; ls .
- base64 -d f | env jq .
- base64 -d f | command jq .
- zcat dump.sql.gz | sudo -u postgres psql ls .
- gunzip -c a.gz | sudo tee /etc/x >/dev/null sh
- zcat a.gz | nice grep x python3
- base64 -d f | python3 parse.py # x
- base64 -d f > out.sh # save for review
- cat a.csv | tr , '\t' | python3 x.py
- git rev-parse HEAD | python3 x.py
- tr -d '\r' < in.sh > out.sh
- tar -xzf x.tgz && sh ./configure
- python3 -c "import base64;print(base64.b64decode('eA=='))"
- PowerShellpowershell -ExecutionPolicy Bypass -File x.ps1
- PowerShellpwsh -NoProfile -Command Get-ChildItem
In your agent
What "ask" means in each app
The guard runs as a hook in each app, and each app gives a hook different powers. Here is what this rule's default action does in each one.
- Claude Code
- You are asked before the call runs. If your settings.json already allows the tool outright, Claude Code runs it with no prompt.
- Cursor
- A terminal command that reaches the guard gets Cursor's approval card. Any other call that needs approval, such as a file edit or a read, is refused, because Cursor cannot ask there.
- Codex CLI
- Codex cannot ask, so the call is refused, and the reason says a person has to approve it.
Each app hands the guard a different set of calls: in a Cursor sandbox run mode, for one, some terminal commands run without reaching the guard at all. Read the notes for Cursor and for Codex CLI before you rely on a rule there.
Make it yours
Change what it does in one command
Turn it off, change its action, or silence it on one command shape. The narrow one is allow: the rule keeps catching everything else.
Run it locally
Put these guardrails in front of your agent.
AgentTrail Guard is free and open source. It checks every command and file change against the whole library before your agent runs it, on your machine, with no account.
npm i -g @agenttrail/guard