Hub rules-anthropic

rules-anthropic

v5 public Verified

Anthropic

Strict safety and best-practice governance for AI agents working with Anthropic models and APIs. These rules block destructive operations and enforce modern security standards.

@sigmashakeinc 2 pulls 10 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-anthropic →
Severity
7 error 3 warn 0 info
demo.cast
Strict safety and best-practice governance for AI agents working with Anthropic models and APIs. These rules block destructive operations and enforce modern security standards.

Rules index

10 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

anthropic

anthropic-command-injection-os-system error block

AI-generated code uses `os.system` which is prone to command injection vulnerabilities if any part of the command string originates from untrusted input. This allows attackers to execute arbitrary shell commands. Use `subprocess.run` with `shell=False` and pass arguments as a list to prevent injection.

Rule source requires an active Pro or Enterprise subscription.
anthropic-hardcoded-api-key error block

AI-generated code appears to hardcode an API key (e.g., 'sk-...') directly in the source. Hardcoding secrets is a severe security risk, leading to credential compromise. Store API keys securely using environment variables, a dedicated secret management service (e.g., AWS Secrets Manager, HashiCorp Vault), or a secure configuration file, and load them at runtime.

Rule source requires an active Pro or Enterprise subscription.
anthropic-hardcoded-api-key-js error block

RISK: hardcoded Anthropic API key (sk-ant-...) in TypeScript/JavaScript source. Any repository clone, npm publish, or bundle exposes the key. FIX: load via process.env.ANTHROPIC_API_KEY at runtime; never commit the literal key value. Rotate the key immediately at console.anthropic.com if already committed.

Rule source requires an active Pro or Enterprise subscription.
anthropic-insecure-deserialization-pickle error block

AI-generated code uses `pickle.loads` which is highly vulnerable to arbitrary code execution if deserializing untrusted data. This is a critical security risk. Replace `pickle` with safer serialization formats like JSON or YAML, and ensure all input is validated against a strict schema. For complex objects, consider custom serialization or secure alternatives.

Rule source requires an active Pro or Enterprise subscription.
anthropic-insecure-randomness-for-security warning log

AI-generated code uses the `random` module for security-sensitive operations like generating tokens, passwords, or salts. The `random` module is not cryptographically secure. For security-critical randomness, use the `secrets` module (e.g., `secrets.token_hex()`, `secrets.randbelow()`) which provides cryptographically strong random numbers.

Rule source requires an active Pro or Enterprise subscription.
anthropic-path-traversal-os-path-join-unvalidated error block

AI-generated code uses `os.path.join` with a variable that might contain untrusted user input, potentially leading to path traversal vulnerabilities (e.g., `../../etc/passwd`). Always sanitize user-provided path components by removing '..' or absolute path indicators, and validate that the final path resolves within an allowed base directory using `os.path.abspath` and `os.path.commonprefix`.

Rule source requires an active Pro or Enterprise subscription.
anthropic-prompt-injection-fstring warning log

RISK: f-string interpolation directly into the 'user' role message content can allow prompt injection — if the interpolated variable contains adversarial text like 'Ignore previous instructions', the model may follow those instructions. FIX: treat all external input as untrusted; wrap user-supplied content in a delimited block (e.g., <user_input>...</user_input>) and instruct the model in the system prompt to treat delimited content as data, not instructions.

Rule source requires an active Pro or Enterprise subscription.
anthropic-streaming-output-exec error block

RISK: executing streaming LLM output via exec()/eval() before the full response is received makes prompt-injection-to-RCE trivial — a partial token stream can satisfy the regex that triggers execution. FIX: never exec/eval LLM output. Buffer the complete response, validate it against an explicit allowlist or schema, then dispatch to a safe handler.

Rule source requires an active Pro or Enterprise subscription.
anthropic-unsafe-eval-exec error block

AI-generated code uses `eval()` or `exec()`. These functions are extremely dangerous when processing untrusted input, as they allow arbitrary code execution. This is a fundamental security anti-pattern. Refactor the code to avoid dynamic execution of untrusted strings; use safer alternatives like AST parsing, explicit function calls, or a sandboxed environment if absolutely necessary.

Rule source requires an active Pro or Enterprise subscription.
anthropic-weak-hashing-algorithm warning log

AI-generated code uses weak hashing algorithms like MD5 or SHA1 for security purposes. These algorithms are cryptographically broken and vulnerable to collision attacks. For password hashing, use `hashlib.sha256` or `hashlib.sha512` with a robust key derivation function like `pbkdf2_hmac` and a unique salt. For data integrity, use stronger algorithms like SHA256 or SHA3.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v5
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
37626ffa6b9b4d8cfbaeb78ae0354ca26f92ee3f67ba83015331086da6ec9d2b
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-anthropic/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-anthropic. The published version only bumps when a maintainer resyncs.

No commit history available.