Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 58 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/patterns/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ impl PatternEntry {

/// Dialect-agnostic SQL injection patterns applicable to any relational database.
pub const GENERAL: &[PatternEntry] = &[
// UNION-based exfiltrationcolumn-count probing to read arbitrary rows.
// UNION-based injectionappends attacker-controlled SELECT to combine results
PatternEntry::new(
r"(?i)\bunion\b(?:\s+(?:all|distinct))?\s+select\b",
r"(?i)\bunion\b\s+select\b",
&[CWE::CWE89],
&[CWE::CWE200],
&[66],
Expand Down Expand Up @@ -260,9 +260,8 @@ pub const GENERAL: &[PatternEntry] = &[
&[CWE::CWE208, CWE::CWE400],
&[7],
),
// CASE-based blind injection — conditional branching leaks data through query behaviour.
PatternEntry::new(
r"(?i)\bcase\s+when\s+.+?\s+then\b",
r"(?i)\bcase\s+when\s+\(?\s*select\b",
&[CWE::CWE89],
&[CWE::CWE208],
&[7],
Expand Down
2 changes: 2 additions & 0 deletions tests/test_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ static SHOULD_PASS: &[&str] = &[
"SELECT * FROM users WHERE id = 1",
"SELECT id, name FROM users WHERE status = 'active'",
"SELECT COUNT(*) FROM orders WHERE created_at > '2024-01-01'",
"SELECT COUNT(*) AS total FROM cve_feed UNION ALL SELECT COUNT(*) AS total FROM oid_feed",
"SELECT SUM(CASE WHEN feed = 'enterprise' THEN 1 ELSE 0 END) AS c FROM oid_feed WHERE feed IS NOT NULL UNION ALL SELECT SUM(CASE WHEN feed = 'enterprise' THEN 1 ELSE 0 END) AS c FROM cve_feed WHERE feed IS NOT NULL",
];

#[test]
Expand Down
Loading
Loading