cairnlock

Rule reference

Nineteen static detection rules across two exclusive profiles. Every rule ships with a bad fixture that must trigger and a good fixture that must not.

Profiles. core (default) covers agent context files with agent-specific rules. extended swaps in generic rules and widens discovery to source files (.py, .js, .ts) and dependency files (requirements*, package.json, pyproject.toml, setup.py, setup.cfg). One profile runs per scan.

IDProfileScopeSeverityDetects
HUC001coreall context fileshigh/medium/lowInvisible and bidirectional Unicode control characters (Trojan Source class)
PIN001coreJSON descriptions, SKILL.md frontmatterhighPrompt-injection phrases in tool and skill descriptions
REM001coreSKILL.md, files under skills/high/mediumPipe-to-shell downloads, base64 payloads, remote fetches
MCP001coreMCP JSON configshighAuto-approve or permission-skipping flags
MCP002coreMCP JSON configsmediumFilesystem server mounted at a filesystem root
MCP003coreMCP JSON configsmediumShell or infrastructure command as the server
MCP004coreMCP JSON configshighSensitive environment variables passed to a server
UNP001coreMCP JSON configsmediumPackage-runner package without a version pin
TOO001coretool definitions, JSON configshigh/mediumTool and function calling injection risks
SEC001extendedall scanned fileshigh/mediumEmbedded credentials with Shannon entropy validation
SHC001extendedsource fileshigh/mediumShell command execution patterns
NET001extendedsource fileshigh/mediumData exfiltration patterns
FSY001extendedsource fileshigh/mediumPath traversal, sensitive file access, unsafe archive extraction
ENV001extendedsource fileshigh/mediumCredential access through environment variables
PRI001extendedsource fileshigh/mediumPrivilege escalation and process injection
OBF001extendedsource files, non-skillhigh/medium/lowEncoding and obfuscation
SUP001extendeddependency files, non-skillhigh/medium/lowSupply chain risks
CFG001extendedstructured config files, non-markdownhigh/mediumTemplate and configuration injection
CRY001extendedsource fileshigh/medium/lowCryptographic weaknesses

HUC001 — hidden Unicode

Zero-width characters and bidirectional controls can make rendered text differ from what a parser or an agent reads. Bidirectional controls score high because they enable Trojan Source style tricks. A UTF-8 BOM at byte zero is not flagged.

PIN001 — prompt injection

Matches injection phrases such as "ignore previous instructions" or "reveal the system prompt" inside tool and skill description fields only. Scoping to descriptions keeps the false-positive rate manageable.

REM001 — remote downloads in skills

Covers curl or wget piped into a shell or interpreter, PowerShell Invoke-Expression chains, base64 decode into a shell, certutil downloads, long base64 literals, and remote git or pip sources inside skill files.

MCP001 — auto-approve flags

Flags autoApprove: true and permission-skipping flags such as --dangerously-skip-permissions, --yolo, and --no-auth in MCP server definitions.

MCP002 — filesystem root mounts

A filesystem server given /, ~, or a drive root can read anything the process can. Repo-relative mounts are fine.

MCP003 — infrastructure commands as servers

Flags shell and infrastructure commands (bash, sh, powershell, curl, wget, docker, podman, kubectl, helm) used as the MCP server executable, regardless of arguments. Package runners belong to UNP001, so one issue yields one finding.

MCP004 — sensitive env vars

Flags server definitions that receive environment variables with credential-like prefixes: cloud keys, database URLs, tokens, certificates.

UNP001 — unpinned packages

Package runners (npx, uvx, bunx, pnpm, yarn, pipx) execute whatever the registry serves today. A pin such as pkg@1.2.3 or pkg==1.2.3 satisfies the rule; @latest does not. Subcommands like dlx are skipped so the package name is the one reported.

TOO001 — tool calling

Tools named shell, exec, or similar; descriptions that advertise arbitrary execution; autonomous agent frameworks; disabled strict mode.

SEC001 — embedded credentials

Provider formats (OpenAI, GitHub, Slack, AWS, Google, Bearer) score high. Generic assignments require a Shannon entropy above 3.5 so placeholders such as "changeme" do not fire.

SHC001 — shell command execution

String-form eval, exec, and compile, os.system, subprocess calls with shell metacharacters or string formatting, and deprecated command modules. An earlier pattern tried to match f-strings passed to commands and matched every f-string call instead; it was removed.

NET001 — exfiltration channels

Cloud metadata addresses, pastebin and webhook endpoints, tunneling services, raw sockets, DNS resolution, HTTP calls carrying data payloads, and long encoded fragments in URL paths.

FSY001 — filesystem access

Traversal sequences, writes and deletes, SSH keys and certificates, env and secrets files, and archive extraction with zip-slip risk. Filename matches use word boundaries, so claude_desktop_config.json is not flagged as config.json.

ENV001 — credential access

Iteration, serialization, printing, or logging of the whole environment, direct reads of cloud and database variables, and shell expansions of long uppercase variables.

PRI001 — escalation and injection

Docker and Kubernetes privileged modes, host namespace sharing, docker socket access, LD_PRELOAD, ptrace attach, Windows registry run keys, scheduled tasks, and encoded PowerShell.

OBF001 — obfuscation

Base64 round trips combined with compression, PowerShell encoded commands, XOR ciphers, long encoded literals, and Cyrillic, Greek, or fullwidth homoglyphs. Skill files are excluded; REM001 covers them.

SUP001 — supply chain

Unpinned installs, wildcard versions, git-sourced dependencies, custom package indexes, and install-time scripts in package definitions. For requirements files it reads line by line and flags bare package names.

CFG001 — config and template injection

Template delimiters, unsafe YAML python tags, dunder references in config, and connection strings with inline credentials. Runs on structured config files only, not markdown, where template prose would false-positive. Credential assignments belong to SEC001.

CRY001 — cryptography

MD5 and SHA1, DES and RC4, AES-ECB, RSA keys at 1024 bits or below, the random module for security purposes, disabled certificate verification, and hardcoded keys or IVs under crypto-specific names.