agentleFS
mondoohqmondoohq/secure-stack/skills/secure-coding/SKILL.md

secure-coding

Skill2 starsChanged 34 days agoApache-2.0View on GitHub

Review code for security vulnerabilities and provide secure coding guidance across Go, Python, JavaScript, Java, Ruby, C#, and Swift, aligned to OWASP Top 10:2025 (application) and aware of the OWASP Top 10 for LLM & GenAI 2025. Triggers on code review, security questions, and vulnerability prevention.

20 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 16 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the xgrep guard hook blocks a prompt or tool call, it names the rule and where it matched (never the value).

    line 86
  2. Distinctive:

    Never work around it: Don't rephrase, split, encode or move the command into a script to get past the guard, and don't edit, disable or …

    line 89
  3. Very specific:

    The allowlist is the user's call: Only the user adds rule ids to .xgrep/guard-allow.txt.

    line 95
  4. Distinctive:

    When reviewing code, check for these in order:

    line 100

“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Secure Coding

Proactively avoid generating vulnerable code. When writing, reviewing, or modifying code, check against the pattern tables in this skill to use safe alternatives instead of dangerous patterns.

When to Use

  • Reviewing code for security issues
  • Writing new code that handles user input, secrets, HTTP requests, file I/O, or crypto
  • Answering "is this safe?" or "how do I securely..." questions
  • Generating code that touches authentication, authorization, or data validation

When NOT to Use

  • Authoring detection rules (use the author-detections skill)
  • Triaging existing SAST scan findings (use the triage-findings skill)
  • Non-security code questions (algorithms, performance, etc.)

Detecting Intent

Code review: User shares code or asks to review a file/PR for security issues. Secure alternative: User asks how to do something safely ("how do I compare secrets in Go?"). Proactive: User is writing code that touches a security-sensitive area.

Quick Reference -- Most Critical Patterns

Never Do This

PatternWhySafe Alternative
secret == expectedTiming attackConstant-time compare (see patterns.md)
"SELECT * FROM t WHERE id=" + inputSQL injectionParameterized queries
eval(user_input)Code executionjson.loads(), ast.literal_eval()
requests.get(user_url)SSRFURL allowlist validation
open(user_filename)Path traversalos.path.basename() + join
pickle.load(data) / yaml.load(data)Deserialization RCEjson.loads() / yaml.safe_load()
jwt.decode(token, secret) (no algorithms)JWT alg confusionjwt.decode(token, secret, algorithms=["HS256"])
InsecureSkipVerify: trueMitM attackRemove or set false
Math.random() for tokensPredictablecrypto.randomBytes()
tls.Config{MinVersion: tls.VersionTLS10}Deprecated TLSMinVersion: tls.VersionTLS12

References

  • Full per-language pattern tables: references/patterns.md
  • Real CVE code examples: references/cve-examples.md

OWASP Top 10:2025 alignment

This skill is the write-it-securely-first layer for the application categories of OWASP Top 10:2025. The patterns above map to:

Pattern classOWASP Top 10:2025
SQLi, command/code injection, SSRF, path traversal, XSS, unsafe deserialization-as-injectionA05:2025 Injection
Timing-unsafe compare, weak/deprecated crypto, Math.random for tokens, TLS < 1.2, JWT alg confusion, InsecureSkipVerifyA04:2025 Cryptographic Failures
pickle/yaml.load RCE, untrusted-data sinks, dependency/update integrityA08:2025 Software or Data Integrity Failures
Secrets/PII in log output, error/stack-trace exposureA09:2025 Security Logging & Alerting Failures (and LLM02, below)
Missing/bypassable authorization, hardcoded credentialsA01 / A07:2025 (code side; config side is cnspec)

A06:2025 Insecure Design is a design/threat-modeling concern no static check can decide — this skill reduces it proactively, but it stays a review-and-design item.

OWASP Top 10 for LLM & GenAI 2025 (when the code is an LLM/GenAI app)

Two categories are code-level and belong here:

  • LLM02 Sensitive Information Disclosure — never put secrets or PII in prompts, model inputs, logs, or error text; the "no secrets in log output" check applies to prompts too.
  • LLM05 Improper Output Handling — treat an LLM's output as untrusted input. Never pass it into eval/exec, a shell, SQL, a file path, or raw HTML/markup without the same validation you would apply to user input.

The full engine coverage (what xgrep and cnspec detect, with honest Strong/Partial/N/A levels) is in docs/owasp.md; once code is written, the secure-pipeline skill scans, gates, and fixes it before it ships.

If xgrep guard Blocks an Action

When the xgrep guard hook blocks a prompt or tool call, it names the rule and where it matched (never the value). Treat that as a security finding, not an obstacle:

  • Never work around it. Don't rephrase, split, encode or move the command into a script to get past the guard, and don't edit, disable or uninstall the hook.
  • Explain and ask. Tell the user which rule fired, why it is risky, and offer a safe alternative (download, inspect, then run; read a secret from the environment).
  • Treat a flagged secret as exposed. Recommend rotating it and remove it from the content instead of retrying.
  • The allowlist is the user's call. Only the user adds rule ids to .xgrep/guard-allow.txt.

Review Checklist

When reviewing code, check for these in order:

Security Review:
- [ ] Secret comparison uses constant-time function
- [ ] SQL queries use parameterized placeholders
- [ ] No eval/exec/compile on untrusted input
- [ ] HTTP requests validate URLs against allowlist
- [ ] File paths validated against base directory
- [ ] Deserialization uses safe loaders with type restrictions
- [ ] JWT decoding specifies allowed algorithms
- [ ] TLS >= 1.2, certificate validation enabled
- [ ] Crypto RNG used for security values (not math/rand)
- [ ] No secrets in log output
- [ ] CORS restricted to specific origins
- [ ] HTTP response headers don't include unsanitized user input
- [ ] File creation uses atomic mode setting (no chmod race)
- [ ] XSS: output encoded for context (HTML, JS, URL)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.