@ia-ccun/code-agent-cli 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: owasp
|
|
3
|
+
description: |
|
|
4
|
+
OWASP security guidelines and Top 10 vulnerabilities
|
|
5
|
+
|
|
6
|
+
USE WHEN: user mentions "OWASP", "security audit", "vulnerability scan", asks about "injection", "XSS", "CSRF", "access control", "authentication security"
|
|
7
|
+
|
|
8
|
+
DO NOT USE FOR: OWASP Top 10:2025 specific - use `owasp-top-10` instead
|
|
9
|
+
allowed-tools: Read, Grep, Glob
|
|
10
|
+
---
|
|
11
|
+
# OWASP Security - Quick Reference
|
|
12
|
+
|
|
13
|
+
## When to Use This Skill
|
|
14
|
+
- Identify common vulnerabilities
|
|
15
|
+
- Implement security controls
|
|
16
|
+
- Code review for security issues
|
|
17
|
+
|
|
18
|
+
## When NOT to Use This Skill
|
|
19
|
+
- **OWASP Top 10:2025** - Use `owasp-top-10` skill for latest 2025 standards
|
|
20
|
+
- **Secrets management** - Use `secrets-management` skill for credentials handling
|
|
21
|
+
- **Supply chain security** - Use `supply-chain` skill for dependency issues
|
|
22
|
+
- **JWT/OAuth security** - Use authentication skills for protocol-specific issues
|
|
23
|
+
|
|
24
|
+
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `owasp` for comprehensive documentation.
|
|
25
|
+
|
|
26
|
+
## OWASP Top 10 (2021)
|
|
27
|
+
|
|
28
|
+
### A01: Broken Access Control
|
|
29
|
+
```java
|
|
30
|
+
// BAD - Direct object reference
|
|
31
|
+
@GetMapping("/users/{id}")
|
|
32
|
+
public User getUser(@PathVariable Long id) {
|
|
33
|
+
return userRepository.findById(id);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// GOOD - Check authorization
|
|
37
|
+
@GetMapping("/users/{id}")
|
|
38
|
+
public User getUser(@PathVariable Long id, Authentication auth) {
|
|
39
|
+
User user = userRepository.findById(id);
|
|
40
|
+
if (!user.getId().equals(auth.getPrincipal().getId())) {
|
|
41
|
+
throw new AccessDeniedException("Not authorized");
|
|
42
|
+
}
|
|
43
|
+
return user;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### A02: Cryptographic Failures
|
|
48
|
+
```java
|
|
49
|
+
// BAD - Weak hashing
|
|
50
|
+
String hash = DigestUtils.md5Hex(password);
|
|
51
|
+
|
|
52
|
+
// GOOD - Strong hashing with salt
|
|
53
|
+
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
|
54
|
+
String hash = encoder.encode(password);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### A03: Injection
|
|
58
|
+
```java
|
|
59
|
+
// BAD - SQL Injection
|
|
60
|
+
String query = "SELECT * FROM users WHERE name = '" + name + "'";
|
|
61
|
+
|
|
62
|
+
// GOOD - Parameterized query
|
|
63
|
+
@Query("SELECT u FROM User u WHERE u.name = :name")
|
|
64
|
+
User findByName(@Param("name") String name);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### A04: Insecure Design
|
|
68
|
+
- Threat modeling during design phase
|
|
69
|
+
- Security requirements in user stories
|
|
70
|
+
- Defense in depth architecture
|
|
71
|
+
|
|
72
|
+
### A05: Security Misconfiguration
|
|
73
|
+
```yaml
|
|
74
|
+
# Spring Security - disable defaults carefully
|
|
75
|
+
spring:
|
|
76
|
+
security:
|
|
77
|
+
headers:
|
|
78
|
+
content-security-policy: "default-src 'self'"
|
|
79
|
+
x-frame-options: DENY
|
|
80
|
+
x-content-type-options: nosniff
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### A06: Vulnerable Components
|
|
84
|
+
```bash
|
|
85
|
+
# Check for vulnerabilities
|
|
86
|
+
npm audit
|
|
87
|
+
mvn dependency-check:check
|
|
88
|
+
pip-audit
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### A07: Auth Failures
|
|
92
|
+
```java
|
|
93
|
+
// Implement rate limiting
|
|
94
|
+
@RateLimiter(name = "login", fallbackMethod = "loginFallback")
|
|
95
|
+
public AuthResponse login(LoginRequest request) {
|
|
96
|
+
// ...
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Account lockout
|
|
100
|
+
if (failedAttempts >= 5) {
|
|
101
|
+
lockAccount(user);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### A08: Software Integrity
|
|
106
|
+
- Verify signatures of dependencies
|
|
107
|
+
- Use lock files (package-lock.json, pom.xml)
|
|
108
|
+
- CI/CD pipeline security
|
|
109
|
+
|
|
110
|
+
### A09: Logging Failures
|
|
111
|
+
```java
|
|
112
|
+
// Log security events
|
|
113
|
+
log.info("Login attempt", Map.of(
|
|
114
|
+
"user", username,
|
|
115
|
+
"ip", request.getRemoteAddr(),
|
|
116
|
+
"success", authenticated
|
|
117
|
+
));
|
|
118
|
+
|
|
119
|
+
// DON'T log sensitive data
|
|
120
|
+
log.info("Password: {}", password); // NEVER!
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### A10: SSRF
|
|
124
|
+
```java
|
|
125
|
+
// Validate URLs
|
|
126
|
+
private boolean isAllowedUrl(String url) {
|
|
127
|
+
URL parsed = new URL(url);
|
|
128
|
+
return allowedHosts.contains(parsed.getHost());
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Security Headers
|
|
133
|
+
|
|
134
|
+
```java
|
|
135
|
+
@Configuration
|
|
136
|
+
public class SecurityConfig {
|
|
137
|
+
@Bean
|
|
138
|
+
public SecurityFilterChain filterChain(HttpSecurity http) {
|
|
139
|
+
return http
|
|
140
|
+
.headers(headers -> headers
|
|
141
|
+
.contentSecurityPolicy(csp -> csp.policyDirectives("default-src 'self'"))
|
|
142
|
+
.frameOptions(frame -> frame.deny())
|
|
143
|
+
.xssProtection(xss -> xss.disable())
|
|
144
|
+
)
|
|
145
|
+
.build();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Anti-Patterns
|
|
151
|
+
|
|
152
|
+
| Anti-Pattern | Why It's Bad | Correct Approach |
|
|
153
|
+
|--------------|--------------|------------------|
|
|
154
|
+
| Direct object references without auth | IDOR vulnerability (A01) | Always verify ownership before access |
|
|
155
|
+
| Using MD5/SHA1 for passwords | Easily cracked | Use bcrypt/argon2 with salt |
|
|
156
|
+
| String concatenation in SQL | SQL injection | Use parameterized queries/ORMs |
|
|
157
|
+
| Exposing stack traces in prod | Information disclosure | Generic error messages only |
|
|
158
|
+
| No rate limiting on login | Brute force attacks | Implement rate limiting + account lockout |
|
|
159
|
+
| Storing secrets in code | Credential exposure | Use environment variables/vaults |
|
|
160
|
+
|
|
161
|
+
## Quick Troubleshooting
|
|
162
|
+
|
|
163
|
+
| Issue | Likely Cause | Solution |
|
|
164
|
+
|-------|--------------|----------|
|
|
165
|
+
| 403 Forbidden on valid request | CORS misconfiguration | Check allowed origins in CORS config |
|
|
166
|
+
| Session not persisting | SameSite cookie issue | Set `SameSite=Lax` or `None` with HTTPS |
|
|
167
|
+
| JWT token rejected | Clock skew or expired | Add clock skew tolerance (5min) |
|
|
168
|
+
| File upload fails | CSP blocking | Add upload domain to CSP directives |
|
|
169
|
+
| API returns 401 unexpectedly | Missing/invalid Authorization header | Check Bearer token format |
|