Skip to content

Commit 7629671

Browse files
committed
feat(stuff): more tests
1 parent f5291dc commit 7629671

118 files changed

Lines changed: 10649 additions & 348 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ baco scan --config myproject.toml
3535

3636
- [Architecture](docs/architecture.md) - PhaseGraph pipeline
3737
- [Configuration](docs/configuration.md) - Settings, LLM config, prompts
38-
- [Research Integration](docs/research-integration.md) - Design decisions
38+
- [Research Integration](docs/research-integration.md) - Design decisions based on 30 academic papers plus triage patterns inspired by [Claude-BugHunter](https://github.com/elementalsouls/Claude-BugHunter)
3939

4040
Codecov: [![Codecov](https://codecov.io/gh/CodeAtCode/baco-scanner/branch/master/graph/badge.svg)](https://app.codecov.io/gh/CodeAtCode/baco-scanner/tree/master)

‎docs/research-integration.md‎

Lines changed: 151 additions & 132 deletions
Large diffs are not rendered by default.

‎prompts/hunt/auth.md‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Authentication/Authorization Vulnerability Hunt Guide
2+
3+
## Dangerous API Patterns by Language
4+
5+
### C/C++
6+
- **Password Storage**: `MD5(password)`, `SHA1(password)` without salt
7+
- **Session Management**: Hardcoded session keys, predictable session IDs
8+
- **Access Control**: Missing permission checks before file operations
9+
- **Buffer Overflows in Auth**: `strcpy` in password comparison buffers
10+
11+
### Python
12+
- **Password Hashing**: `hashlib.md5(password)`, `hashlib.sha1(password)`
13+
- **Session Tokens**: `secrets.token_hex()` without proper entropy, hardcoded secrets
14+
- **Auth Bypass**: `if user == 'admin':` without proper validation
15+
- **JWT**: `jwt.decode(token, verify=False)`, weak JWT algorithms (none, HS256 with weak secret)
16+
17+
### Java
18+
- **Password Hashing**: `MessageDigest.getInstance("MD5")`, `SHA-1`
19+
- **Session**: `session.setAttribute()` without timeout, predictable session IDs
20+
- **Authorization**: `request.isUserInRole()` not called, missing `@PreAuthorize`
21+
- **Hardcoded Secrets**: `String apiKey = "abc123";`, `private static final String SECRET = "..."`
22+
23+
### Go
24+
- **Password Hashing**: `sha256.Sum256(password)` without bcrypt/argon2
25+
- **JWT**: `Parse(token, func(...) { return nil })` skipping signature verification
26+
- **Session**: Hardcoded session secrets, missing CSRF tokens
27+
- **Auth Middleware**: Empty middleware functions, missing permission checks
28+
29+
### JavaScript/Node.js
30+
- **Password Hashing**: `crypto.createHash('md5').update(password)`
31+
- **JWT**: `jwt.verify(token, secret, { algorithms: ['none'] })`
32+
- **Session**: `express-session` without `secure: true`, `httpOnly: true`
33+
- **Auth Logic**: `if (req.query.admin === 'true')`, missing role checks
34+
35+
## Known False-Positive Signatures
36+
37+
### Safe Patterns (DO NOT REPORT)
38+
- **Proper Password Hashing**: `bcrypt.hash(password, saltRounds)`, `argon2.hash(password)`
39+
- **JWT Verification**: `jwt.verify(token, secret, { algorithms: ['RS256'] })` with proper validation
40+
- **Session Security**: `secure: true, httpOnly: true, sameSite: 'strict'`
41+
- **Role-Based Access**: `@RequiresRoles("ADMIN")`, `if (user.role === 'admin' && user.verified)`
42+
- **OAuth/OIDC**: Proper implementation using established libraries (passport.js, oauth2-server)
43+
44+
## Bypass Detection Patterns
45+
46+
### Authentication Bypass
47+
- **Parameter Pollution**: `?admin=true&admin=false`
48+
- **Type Juggling**: `if (userId == "1")` in PHP/JS
49+
- **HTTP Parameter Pollution**: Duplicate parameters to confuse logic
50+
- **Null Byte Injection**: `admin.txt%00.jpg` to bypass extensions
51+
- **Race Conditions**: Concurrent requests to bypass rate limiting
52+
53+
### Authorization Bypass
54+
- **IDOR**: `GET /api/users/1` → `GET /api/users/2` without ownership check
55+
- **Privilege Escalation**: Modifying role claims in JWT, URL parameter tampering
56+
- **Missing Middleware**: Protected routes without auth middleware
57+
- **CORS Misconfiguration**: `Access-Control-Allow-Origin: *` on auth endpoints
58+
59+
## Chain Opportunities
60+
61+
### Auth Vulnerabilities Enable
62+
- **Data Breach**: Unauthorized access to sensitive data
63+
- **Privilege Escalation**: Admin access leads to RCE or full system compromise
64+
- **Account Takeover**: Session fixation, weak password policies
65+
- **Business Logic Abuse**: Bypass payment, free access to premium features
66+
- **Lateral Movement**: Compromised credentials used for internal network access
67+
68+
### Priority Indicators
69+
- **Critical**: Admin authentication bypass, password reset flaws, MFA bypass
70+
- **High**: IDOR on sensitive data, JWT validation flaws, session fixation
71+
- **Medium**: Weak password policies, missing rate limiting, verbose error messages
72+
- **Low**: Missing security headers, informational disclosure in error pages

‎prompts/hunt/crypto.md‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Cryptographic Weakness Vulnerability Hunt Guide
2+
3+
## Dangerous API Patterns by Language
4+
5+
### C/C++
6+
- **Random Number Generation**: `rand()`, `srand(time(NULL))` for security purposes
7+
- **Hash Functions**: `MD5()`, `SHA1()` for password hashing, integrity verification
8+
- **Encryption**: `EVP_CIPHER_CTX_init()` with DES, RC4, CBC mode without HMAC
9+
- **Key Management**: Hardcoded encryption keys, keys in source code
10+
- **Memory**: Storing plaintext keys in memory, insufficient key clearing
11+
12+
### Python
13+
- **Random**: `random.random()`, `random.randint()` for tokens/secrets
14+
- **Hash**: `hashlib.md5()`, `hashlib.sha1()` for passwords
15+
- **Encryption**: `Crypto.Cipher.DES`, `Crypto.Cipher.ARC4`
16+
- **Key Derivation**: `hashlib.md5(password)` instead of `bcrypt`/`argon2`
17+
- **Hardcoded Keys**: `SECRET_KEY = "abc123"`, `API_KEY = "..."`
18+
19+
### Java
20+
- **Random**: `java.util.Random` for security tokens
21+
- **Hash**: `MessageDigest.getInstance("MD5")`, `SHA-1`
22+
- **Encryption**: `Cipher.getInstance("DES/ECB/PKCS5Padding")`, `RC4`
23+
- **KeyStore**: Hardcoded keystore passwords, weak key storage
24+
- **SSL**: `TrustAllManager`, `hostnameVerifier = (a, b) -> true`
25+
26+
### Go
27+
- **Random**: `math/rand` instead of `crypto/rand`
28+
- **Hash**: `crypto/md5`, `crypto/sha1` for security purposes
29+
- **Encryption**: `cipher.NewRC4()`, ECB mode usage
30+
- **Key Derivation**: `md5.Sum(password)` instead of `bcrypt`
31+
- **TLS**: `tls.Config{InsecureSkipVerify: true}`
32+
33+
### JavaScript/Node.js
34+
- **Random**: `Math.random()` for tokens/secrets
35+
- **Hash**: `crypto.createHash('md5')`, `createHash('sha1')`
36+
- **Encryption**: `crypto.createCipher('des-ecb', key)`
37+
- **JWT**: Weak algorithms, missing signature verification
38+
- **Hardcoded Secrets**: `process.env.SECRET = "abc123"` in code
39+
40+
## Known False-Positive Signatures
41+
42+
### Safe Patterns (DO NOT REPORT)
43+
- **Cryptographically Secure RNG**: `secrets.token_hex()`, `crypto.getRandomValues()`, `crypto/rand`
44+
- **Modern Hashing**: `bcrypt`, `argon2`, `scrypt`, `PBKDF2` for passwords
45+
- **Strong Encryption**: `AES-GCM`, `AES-256-CBC` with HMAC, `ChaCha20-Poly1305`
46+
- **Key Derivation**: `bcrypt.gensalt()`, `argon2.hash()`, `pbkdf2_derive()`
47+
- **Proper TLS**: Valid certificate verification, strong cipher suites
48+
49+
## Bypass Detection Patterns
50+
51+
### Weak Crypto Exploitation
52+
- **Hash Collisions**: MD5 collision attacks for certificate forgery
53+
- **Rainbow Tables**: Unsalted hashes vulnerable to precomputation
54+
- **Timing Attacks**: Non-constant-time string comparison for tokens
55+
- **Padding Oracle**: CBC padding oracle attacks
56+
- **Key Recovery**: Brute-force weak keys, default credentials
57+
58+
### Implementation Flaws
59+
- **ECB Mode**: Patterns visible in encrypted data
60+
- **IV Reuse**: Same IV used multiple times with same key
61+
- **Short Keys**: Keys shorter than 128 bits
62+
- **Predictable Nonces**: Nonce reuse in stream ciphers
63+
64+
## Chain Opportunities
65+
66+
### Crypto Vulnerabilities Enable
67+
- **Credential Theft**: Cracking weak password hashes
68+
- **Session Hijacking**: Predicting session tokens from weak RNG
69+
- **Data Decryption**: Breaking weak encryption schemes
70+
- **Certificate Forgery**: MD5 collision for fake certificates
71+
- **Authentication Bypass**: Timing attacks on token comparison
72+
73+
### Priority Indicators
74+
- **Critical**: Hardcoded encryption keys, weak RNG for tokens/passwords
75+
- **High**: MD5/SHA1 for passwords, ECB mode encryption, InsecureSkipVerify
76+
- **Medium**: Missing rate limiting on auth, weak password policies
77+
- **Low**: Outdated TLS versions (1.0/1.1), missing HSTS headers

‎prompts/hunt/deserialization.md‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Insecure Deserialization/Configuration Vulnerability Hunt Guide
2+
3+
## Dangerous API Patterns by Language
4+
5+
### C/C++
6+
- **Serialization**: `memcpy()` from network/buffer without validation
7+
- **Struct Parsing**: `read(fd, &struct, sizeof(struct))` from untrusted source
8+
- **Pickles**: Custom binary format parsing without schema validation
9+
- **Memory**: Deserializing into fixed-size buffers
10+
11+
### Python
12+
- **Pickle**: `pickle.loads(user_input)`, `pickle.load(file)`
13+
- **YAML**: `yaml.load(user_input)` without `SafeLoader`
14+
- **Marshal**: `marshal.loads(user_input)`
15+
- **Shelve**: `shelve.open()` with untrusted data
16+
- **JSON**: `json.loads()` with custom `object_hook` executing code
17+
18+
### Java
19+
- **Serialization**: `ObjectInputStream.readObject()` from untrusted source
20+
- **XStream**: `xstream.fromXML(user_input)` without type allowlist
21+
- **Jackson**: `ObjectMapper.readValue()` with polymorphic types enabled
22+
- **YAML**: `new Yaml().load(user_input)` without safe constructor
23+
- **JSON**: `JSONObject.parse(user_input)` with gadget classes
24+
25+
### Go
26+
- **Gob**: `gob.NewDecoder(reader).Decode(&struct)` with untrusted data
27+
- **JSON**: `json.Unmarshal()` with `interface{}` leading to type confusion
28+
- **Marshal**: Custom marshaling without validation
29+
- **Protobuf**: `proto.Unmarshal()` with unexpected fields
30+
31+
### JavaScript/Node.js
32+
- **JSON**: `JSON.parse(user_input)` with `__proto__` pollution
33+
- **Serialize-JS**: `serialize-javascript` without strict mode
34+
- **YAML**: `yaml.parse(user_input)` without safe options
35+
- **MessagePack**: `msgpack.decode(user_input)` without schema validation
36+
37+
## Known False-Positive Signatures
38+
39+
### Safe Patterns (DO NOT REPORT)
40+
- **Safe Loaders**: `yaml.safe_load()`, `yaml.load(..., SafeLoader)`
41+
- **Type Allowlists**: `XStream.allowTypesByWildcard(["com.example.safe.*"])`
42+
- **Schema Validation**: JSON Schema validation before parsing
43+
- **Immutable Types**: Deserializing only to immutable data structures
44+
- **JSON Only**: Using JSON instead of binary serialization formats
45+
46+
## Bypass Detection Patterns
47+
48+
### Deserialization Attacks
49+
- **Gadget Chains**: Known exploit chains (Apache Commons, Java Serialization)
50+
- **Type Confusion**: Casting to unexpected types after deserialization
51+
- **Prototype Pollution**: `{"__proto__": {"admin": true}}`
52+
- **Polymorphic Abuse**: Deserializing to unexpected subclasses
53+
- **Metadata Manipulation**: Modifying version/length fields
54+
55+
### Configuration Issues
56+
- **Hardcoded Secrets**: `SECRET_KEY = "abc123"` in config files
57+
- **Debug Mode**: `DEBUG = True` in production
58+
- **Weak CORS**: `Access-Control-Allow-Origin: *` on sensitive endpoints
59+
- **Excessive Permissions**: `chmod 777`, running as root
60+
- **Insecure Defaults**: SSL verification disabled, weak ciphers
61+
62+
## Chain Opportunities
63+
64+
### Deserialization Enables
65+
- **Remote Code Execution**: Gadget chains leading to `Runtime.exec()`
66+
- **Authentication Bypass**: Deserializing admin session objects
67+
- **Privilege Escalation**: Modifying serialized permission objects
68+
- **Data Tampering**: Altering serialized business logic state
69+
- **Information Disclosure**: Deserializing sensitive configuration
70+
71+
### Config Vulnerabilities Enable
72+
- **Credential Theft**: Hardcoded API keys, database passwords
73+
- **Reconnaissance**: Debug endpoints exposing internal state
74+
- **Bypass**: CORS allowing cross-origin attacks
75+
- **DoS**: Unbounded resource allocation from config
76+
- **Lateral Movement**: Internal network settings exposed
77+
78+
### Priority Indicators
79+
- **Critical**: `pickle.loads()`, `readObject()` from HTTP input, RCE gadget chains
80+
- **High**: YAML unsafe load, hardcoded secrets in repo, debug mode in production
81+
- **Medium**: Prototype pollution potential, weak configuration defaults
82+
- **Low**: Info disclosure in config, missing security headers

‎prompts/hunt/injection.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Injection Vulnerability Hunt Guide
2+
3+
## Dangerous API Patterns by Language
4+
5+
### C/C++
6+
- **Command Injection**: `system()`, `popen()`, `exec*()`, `spawn*()` with user input
7+
- **SQL**: Direct string concatenation into SQL queries (rare in C, more common in embedded)
8+
- **Format String**: `printf(user_input)`, `sprintf(buf, user_controlled_format)`
9+
- **LDAP**: Custom implementations using string building for LDAP filters
10+
11+
### Python
12+
- **SQL**: `"SELECT * FROM users WHERE id=" + user_id`, `cursor.execute(f"SELECT * FROM {table}")`
13+
- **Command**: `os.system("ping " + ip)`, `subprocess.call("ls " + path, shell=True)`
14+
- **SSTI**: `render_template_string(user_input)`, `format(user_input)`
15+
- **Code Execution**: `eval(user_input)`, `exec(user_input)`, `compile()`
16+
17+
### Java
18+
- **SQL**: `Statement.executeQuery("SELECT * FROM users WHERE id=" + id)`
19+
- **Command**: `Runtime.getRuntime().exec("ping " + host)`, `ProcessBuilder` with user input
20+
- **LDAP**: `context.search(filter)` with unsanitized filter strings
21+
- **XXE**: `DocumentBuilder.parse()` with external entity resolution enabled
22+
23+
### Go
24+
- **SQL**: `db.Query("SELECT * FROM users WHERE id=" + id)`, `fmt.Sprintf(query, user_input)`
25+
- **Command**: `exec.Command("sh", "-c", "ping "+host)`
26+
- **Template Injection**: `template.HTML(user_input)`, `tmpl.ExecuteTemplate()` with user templates
27+
28+
### JavaScript/Node.js
29+
- **SQL**: `query("SELECT * FROM users WHERE id=" + id)`
30+
- **NoSQL**: `find({$where: "this.name == " + user_input})`
31+
- **Command**: `exec("ping " + host)`, `spawn("sh", ["-c", cmd])`
32+
- **Prototype Pollution**: `Object.assign(target, user_input)`
33+
34+
## Known False-Positive Signatures
35+
36+
### Safe Patterns (DO NOT REPORT)
37+
- **Parameterized Queries**: `cursor.execute("SELECT * FROM users WHERE id=?", (user_id,))`
38+
- **Prepared Statements**: `PreparedStatement stmt = conn.prepareStatement("SELECT * FROM users WHERE id=?")`
39+
- **ORM Methods**: `User.objects.get(id=user_id)`, `db.users.find({id: userId})`
40+
- **Escaping Functions**: `mysql_real_escape_string()`, `pg_escape_literal()`
41+
- **Whitelist Validation**: Input validated against known-good patterns before use
42+
43+
## Bypass Detection Patterns
44+
45+
### Encoding Tricks
46+
- URL encoding: `%27` for `'`, `%22` for `"`
47+
- Double encoding: `%2527` → `%27` → `'`
48+
- Unicode encoding: `\u0027` for `'`
49+
- Hex encoding: `0x27` for `'`
50+
51+
### Comment Injection
52+
- SQL comments: `--`, `#`, `/* */`
53+
- Null bytes: `%00`, `\0` in path traversal
54+
- Line breaks: `%0a`, `%0d` to bypass filters
55+
56+
### Concatenation Attacks
57+
- String concatenation to evade filters: `' OR '1'='1`
58+
- Type confusion: `1 OR 1=1` in numeric context
59+
60+
## Chain Opportunities
61+
62+
### Injection Enables
63+
- **Authentication Bypass**: SQLi can bypass login forms
64+
- **Command Execution**: SQLi with `xp_cmdshell` (SQL Server) or `INTO OUTFILE` (MySQL)
65+
- **XSS**: Stored XSS via database injection
66+
- **Path Traversal**: Command injection can read arbitrary files
67+
- **SSRF**: Command injection can make internal network requests
68+
69+
### Priority Indicators
70+
- **Critical**: Database credentials in connection strings, admin panel access
71+
- **High**: User input directly in system commands, authentication queries
72+
- **Medium**: Read-only database queries, non-critical command output
73+
- **Low**: Logged-only user input, debug endpoints

0 commit comments

Comments
 (0)