Skip to content
Back to skills

Code Security

ASecurity

Security guidelines for writing secure code. Use when writing code, reviewing code for vulnerabilities, or asking about secure coding practices like "check for SQL injection" or "review security".

  • 290 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 7, 2026
devopsjavascriptrustgojavac++shellsqldockerkubernetesaws

Works with

  • api

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add semgrep/skills --skill code-security --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Security?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Security
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/semgrep-code-security/badge)](https://www.skillsdirectory.com/skills/semgrep-code-security)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-security
description: Security guidelines for writing secure code. Use when writing code, reviewing code for vulnerabilities, or asking about secure coding practices like "check for SQL injection" or "review security".
---

# Code Security Guidelines

Comprehensive security rules for writing secure code across multiple languages and frameworks. Covers OWASP Top 10 vulnerabilities, infrastructure security, and coding best practices.

## How It Works

1. When you write or review code, reference these security guidelines
2. Each rule includes incorrect (vulnerable) and correct (secure) code examples
3. Rules are organized by vulnerability category and impact level

## Categories

### Critical Impact
- **SQL Injection** - Use parameterized queries, never concatenate user input
- **Command Injection** - Avoid shell commands with user input, use safe APIs
- **XSS** - Escape output, use framework protections
- **XXE** - Disable external entities in XML parsers
- **Path Traversal** - Validate and sanitize file paths
- **Insecure Deserialization** - Never deserialize untrusted data
- **Code Injection** - Never eval() user input
- **Hardcoded Secrets** - Use environment variables or secret managers
- **Memory Safety** - Prevent buffer overflows, use-after-free (C/C++)

### High Impact
- **Insecure Crypto** - Use SHA-256+, AES-256, avoid MD5/SHA1/DES
- **Insecure Transport** - Use HTTPS, verify certificates
- **SSRF** - Validate URLs, use allowlists
- **JWT Issues** - Always verify signatures
- **CSRF** - Use CSRF tokens on state-changing requests
- **Prototype Pollution** - Validate object keys in JavaScript

### Infrastructure
- **Terraform AWS/Azure/GCP** - Encryption, least privilege, no public access
- **Kubernetes** - No privileged containers, run as non-root
- **Docker** - Don't run as root, pin image versions
- **GitHub Actions** - Avoid script injection, pin action versions

## Usage

Reference the rules in `rules/` directory for detailed examples:

- `rules/sql-injection.md` - SQL injection prevention
- `rules/xss.md` - Cross-site scripting prevention
- `rules/command-injection.md` - Command injection prevention
- `rules/_sections.md` - Full index of all 28 rule categories

## Quick Reference

| Vulnerability | Key Prevention |
|--------------|----------------|
| SQL Injection | Parameterized queries |
| XSS | Output encoding |
| Command Injection | Avoid shell, use APIs |
| Path Traversal | Validate paths |
| SSRF | URL allowlists |
| Secrets | Environment variables |
| Crypto | SHA-256, AES-256 |

Files in this skill

  • README.md2.7 KB
  • SKILL.md2.5 KB
  • rules/_sections.md6.9 KB
  • rules/_template.md635 B
  • rules/authentication-jwt.md2.9 KB
  • rules/best-practice.md3.1 KB
  • rules/code-injection.md3.7 KB
  • rules/command-injection.md3.4 KB
  • rules/correctness.md3.2 KB
  • rules/csrf.md3.8 KB
  • rules/docker.md2.7 KB
  • rules/github-actions.md5.3 KB
  • rules/insecure-crypto.md4.1 KB
  • rules/insecure-deserialization.md6.7 KB
  • rules/insecure-transport.md5.3 KB
  • rules/kubernetes.md4.4 KB
  • rules/maintainability.md1.8 KB
  • rules/memory-safety.md3.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.