mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 11:49:28 +00:00
Rebuild the quick-scan detection engine and ground-truth benchmarks to hit >=90% recall / <10% false positives for C/C++, Python, JavaScript, and Java. Engine (findings.py, preprocess.py): - Scope each PatternRule by language (fixes cross-language false positives such as the Python eval/exec rule firing on JS .exec()). - Add JavaScript/TypeScript rules (command exec, eval/Function, reflected XSS, SQLi, path traversal, SSRF, weak hash, deserialization); execFile/spawn-argv excluded as safe alternatives. - Add Java rules (Runtime exec, SQL string concatenation, weak hash, readObject) and a Groovy server-side template rule (yieldUnescaped of a bound variable). - Broaden C/C++ and Python coverage; precision guards for format strings and parameterised vs concatenated SQL; #-comment skipping; CWE in rationale. - Register .java/.groovy/.tpl source extensions. Benchmarks: - Add realistic corpora modeled on Damn Vulnerable C/C++, PyGoat/DVPWA, and NodeGoat, plus the real kiview/damn-vulnerable-spring-boot-app vendored verbatim (MIT, attribution in LICENSE/NOTICE.md). Each manifest carries complete, independently-labeled ground truth including genuinely hard-to-detect vulns (integer overflow, second-order SQLi, prototype pollution) so recall is measured honestly, plus safe-API files for precision. - Fix pre-existing smoke-manifest ground-truth errors (Python/JS line offsets, missing C/C++ strcpy entry, Java SQLi line). benchmark.py: - Fix sink matching to normalise the expected sink consistently so sinks with underscores (e.g. render_template_string) can match. Tests: - Add tests/test_detection_benchmarks.py enforcing the >=90% recall / <10% FP goal per language and overall. Measured: C/C++ 93.3%, Python 93.3%, JavaScript 92.3%, Java 100%; overall 93.6% recall, 0.0% false-positive rate. Co-Authored-By: Claude Opus 4.8 <[email protected]>
119 lines
2.5 KiB
TOML
119 lines
2.5 KiB
TOML
name = "cpp-damn-vulnerable"
|
|
language = "c_cpp"
|
|
frameworks = ["native"]
|
|
setup = []
|
|
modes = ["quick", "standard"]
|
|
known_noise = []
|
|
baselines = []
|
|
|
|
[source]
|
|
type = "local"
|
|
path = "../fixtures/cpp-damn-vulnerable"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 8
|
|
rule_id = "c-unsafe-copy"
|
|
sink = "strcpy"
|
|
evidence = "strcpy copies attacker input into a fixed buffer"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 13
|
|
rule_id = "c-unsafe-copy"
|
|
sink = "strcat"
|
|
evidence = "strcat appends attacker input without bounds"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 18
|
|
rule_id = "c-unsafe-copy"
|
|
sink = "gets"
|
|
evidence = "gets reads input without any bounds checking"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 23
|
|
rule_id = "c-unsafe-copy"
|
|
sink = "sprintf"
|
|
evidence = "sprintf formats attacker input into a fixed buffer"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 27
|
|
rule_id = "c-unsafe-memory-copy"
|
|
sink = "memcpy"
|
|
evidence = "memcpy copies an attacker-controlled length"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 32
|
|
rule_id = "c-unsafe-scanf"
|
|
sink = "scanf"
|
|
evidence = "scanf reads unbounded input into a fixed buffer"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-190"
|
|
class = "integer overflow"
|
|
path = "src/buffer.cpp"
|
|
line = 37
|
|
sink = "malloc"
|
|
evidence = "malloc size len multiplied by count can overflow"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-120"
|
|
class = "buffer overflow"
|
|
path = "src/command.cpp"
|
|
line = 8
|
|
rule_id = "c-unsafe-copy"
|
|
sink = "strcpy"
|
|
evidence = "strcpy copies the command argument into a fixed buffer"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-78"
|
|
class = "command injection"
|
|
path = "src/command.cpp"
|
|
line = 9
|
|
rule_id = "c-shell-exec"
|
|
sink = "system"
|
|
evidence = "system executes an attacker-controlled command"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-78"
|
|
class = "command injection"
|
|
path = "src/command.cpp"
|
|
line = 13
|
|
rule_id = "c-shell-exec"
|
|
sink = "popen"
|
|
evidence = "popen executes an attacker-controlled command"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-78"
|
|
class = "command injection"
|
|
path = "src/command.cpp"
|
|
line = 18
|
|
rule_id = "c-exec-family"
|
|
sink = "execlp"
|
|
evidence = "execlp executes an attacker-controlled argument"
|
|
|
|
[[expected]]
|
|
cwe = "CWE-134"
|
|
class = "format string"
|
|
path = "src/command.cpp"
|
|
line = 22
|
|
rule_id = "c-unsafe-format"
|
|
sink = "printf"
|
|
evidence = "printf uses an attacker-controlled format string"
|