AI coding agents write insecure code. Not maliciously - they just optimize for "works" over "safe." This skill fixes that.
Ask Claude, Codex, or any AI to query a database. You'll probably get something like:
// AI-generated code - looks fine, isn't
String query = "SELECT * FROM users WHERE email = '" + email + "'";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query); // SQL injection waiting to happenThe AI didn't know better. It generated statistically likely Java code. Unfortunately, statistically likely often means copied from tutorials circa 2010.
This skill teaches the AI to catch these patterns and fix them before they hit your codebase.
11 modules covering OWASP Top 10 Web and API vulnerabilities:
| Module | What it prevents |
|---|---|
| injection.md | SQL injection, command injection, JPQL/HQL injection, LDAP injection |
| deserialization.md | ObjectInputStream attacks, XXE, unsafe YAML |
| xss-output.md | Cross-site scripting, missing template escaping in JSP/Thymeleaf |
| auth-access.md | Broken access control, BOLA, session issues, JWT misuse |
| crypto-secrets.md | Weak hashing, hardcoded secrets, bad randomness |
| input-validation.md | Missing Bean Validation, file upload attacks, mass assignment |
| file-operations.md | Path traversal, insecure temp file creation |
| spring-security.md | CSRF bypass, permissive CORS, exposed actuators |
| jakarta-ee.md | Servlet security, EJB patterns, JAX-RS issues |
| dependencies.md | Supply chain attacks, vulnerable Log4j, typosquatting |
| java-runtime.md | Reflection dangers, ReDoS, ScriptEngine abuse |
- Never string concatenation in SQL. Use
PreparedStatementor JPA named parameters. - Never
ObjectInputStream.readObject()on untrusted data. Use JSON. - Never
Runtime.exec()with user input. UseProcessBuilderwith argument list. - Never
java.util.Randomfor security. UseSecureRandom. - Never MD5/SHA1 for passwords. Use BCrypt or Argon2.
- Never
th:utextin Thymeleaf. Useth:text.
Each module has BAD and GOOD examples so you can see exactly what to avoid.
| Platform | Status |
|---|---|
| Claude Code | Works |
| OpenAI Codex | Works |
| Google Antigravity | Works |
| Warp | Works |
| VS Code Copilot | Works |
This skill follows the Agent Skills open standard. If your AI tool supports skills, this works.
Clone to your skills directory:
git clone https://github.com/subhashdasyam/security-antipatterns-java ~/.claude/skills/security-antipatterns-javaOr for a specific project, clone to .claude/skills/ in the repo.
mkdir -p ~/.codex/skills
ln -s $(pwd) ~/.codex/skills/security-antipatterns-javamkdir -p ~/.antigravity/skills
ln -s $(pwd) ~/.antigravity/skills/security-antipatterns-javaCopy to ~/.warp/skills/ or configure the skill path in Warp settings.
Copy the skill folder to .github/skills/ in your project.
Copy or symlink this folder to wherever your AI tool looks for skills. The format is standard - it should just work.
The skill kicks in when you're generating:
- Spring Boot controllers or services
- JPA/Hibernate entity operations
- JDBC queries
- Jakarta EE servlets or JAX-RS endpoints
- File handling code
- Authentication or session logic
- Anything deserializing external data
- Java 17 (primary target - most widely used LTS)
- Java 11 (secondary - still common in enterprise)
- Java 21 (latest LTS - modern features)
Patterns work across all three. Version-specific features (sealed classes, records, virtual threads) are noted where relevant.
MIT