tonyandrewmeyer/cantrip/security-review
Claude Code and agent skill by tonyandrewmeyer/cantrip
- community
Checking that the SKILL.md file is still in the repository.
Charm-specific security review to run before a BUILD task finishes
Install
npx vskill@latest install tonyandrewmeyer/cantrip/security-reviewSKILL.md
The same SKILL.md was published earlier as tonyandrewmeyer/cantrip/security-review.
Security Review
Run this review on every charm you write before finishing a BUILD task. The goal is to catch the common charm-specific security issues — not a full OWASP audit. Report findings inline in the subagent output; apply HIGH-confidence fixes yourself, surface HIGH-confidence findings for the user, and silently fix MEDIUM ones when the fix is obvious.
How to use
- List every Python file you wrote or modified in this task.
- For each file, walk the checks below. Most files only need 30 seconds.
- If you find an issue, fix it or record it in the output with file:line,
severity, evidence, and the fix you applied.
- Only declare the task complete once HIGH-confidence issues are resolved.
Confidence gating
- HIGH — shell concatenation with user input, secrets written to debug
logs, credentials in config.yaml rather than Juju secrets. Fix before finishing.
- MEDIUM — unbounded
subprocess.runwithout timeout, missing
str.format validation, broad except Exception. Fix silently if the change is a one-liner; otherwise note it.
- LOW — stylistic concerns, hypothetical attacker models. Do not report.
If you cannot reach HIGH confidence on a finding, drop it. Noisy reports teach the user to ignore you.
Checks
1. Shell injection in subprocess calls
Charms shell out to juju-* binaries, pebble, openssl, workload processes, and helpers. Every call is a potential injection site if any argument comes from a relation bag, config, action param, or environment.
- Bad:
subprocess.run(f"pebble exec -- run-migration {user_input}", shell=True) - Good:
subprocess.run(["pebble", "exec", "--", "run-migration", user_input], check=True)
Checklist:
- [ ] No
shell=Trueanywhere unless the command is entirely literal. - [ ] Every
subprocess.runuses a list of arguments, not a string. - [ ] No
os.system,os.popen, orcommands.getoutput. - [ ]
shlex.split()is not a sanitiser — it just tokenises. Don't rely on it.
2. Path traversal in file operations
Many charms accept config values that become file paths (log dirs, cert paths, plugin paths). Treat any path derived from config, relation data, or action params as attacker-controlled.
- Reject absolute paths unless the charm explicitly owns that location.
- Reject
..components. - Use
pathlib.Path(base).resolve()and verify the result is still inside
the intended base with Path.is_relative_to().
3. Secrets handled via Juju secrets, not config
Any sensitive value (password, token, API key, TLS key) must go through Juju secrets — never a plain config option.
- [ ]
charmcraft.yamlconfig options do not containpassword,token,
key, secret, or similar.
- [ ] Secrets are obtained via
self.model.get_secret(...)or passed
through a relation as a secret URI.
- [ ] Secret content is never written to
logger.info/debug, exceptions,
or status messages. Use IDs or the phrase "[redacted]".
4. Relation data trust boundary
Relation data is remote-controlled from the perspective of the charm. Validate before use; never feed straight into the filesystem, shell, or template engines.
- [ ] Numeric fields are parsed with
int()/float()inside a
try/except.
- [ ] String fields that become file paths, URLs, or commands are
validated against an allowlist or regex.
- [ ] Databag size is bounded. Don't copy a 10 MB blob into your local
state because the peer sent it.
5. SSRF in HTTP calls
If the charm fetches URLs that come from config, relation data, or a workload response, treat them as attacker-controlled.
- Validate scheme is
http/https. - Reject private/internal addresses (
127.0.0.1,169.254.169.254,
::1, fc00::/7, RFC1918) unless the charm explicitly talks to them.
- Always set a connect timeout and a read timeout.
6. Broad exception handling
except Exception: hides security-relevant failures. Especially dangerous in secret-rotation, TLS-renewal, and auth paths, where swallowing an error can leave the charm running on stale credentials.
- Catch specific exceptions. If the fallback is truly "give up and go to
BlockedStatus", that's fine — but log the exception type and message.
- Never
except:(bare).
7. Deserialisation
- Use
yaml.safe_load, neveryaml.load. - Use
json.loadswith a size limit for relation data. - Never
pickle.loaduntrusted data. Juju has no mechanism that
legitimately needs pickled payloads in 2026.
8. Logging hygiene
- Secrets and tokens are never logged (see §3).
- Relation-data dumps in logs should be keys only, not full values.
- Debug logs must not contain PII even from test fixtures.
9. Template injection (rare, but check)
If the charm writes workload configs by string-formatting user input into templates (nginx.conf, haproxy.cfg, pg_hba.conf), use a template engine with autoescaping or validate the input against a strict regex. Never f"""{cfg}"""-format a multi-line config.
10. TLS and certificate handling
- [ ]
verify=False/ssl.CERT_NONEnever appear. - [ ] Certificate files written with
chmod 0o400/0o600, not world-readable. - [ ] Certs rotated on the
certificate-availableevent, not on a timer.
Output format
When you report findings, use this structure so the user can skim them:
If there are zero HIGH findings and you fixed zero MEDIUM silently, print:
When to skip
Skip this skill for:
- Trivial edits (renaming, docstring-only changes).
- RESEARCH or DEBUG tasks (apply on BUILD only).
- Generated scaffolding (charmcraft init output before you edit it).
Otherwise, always run it. A missed security bug that reaches Charmhub is much more expensive than 30 seconds of your time.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsrc/cantrip/skills/security-review/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tonyandrewmeyer/cantrip/security-review)