From aa8e23faa561aed48eeba20022110bc350823cef Mon Sep 17 00:00:00 2001 From: Noel Date: Thu, 14 May 2026 17:33:54 +0200 Subject: [PATCH] =?UTF-8?q?corpus:=20batch=205=20=E2=80=94=20Java=20SSRF?= =?UTF-8?q?=20+=20Rust=20transmute=20+=20C=20system=20(toward=20#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - java-ssrf-resttemplate: RestTemplate.getForObject + WebClient.uri with user input - rust-mem-transmute: std::mem::transmute / mem::transmute calls - c-system-non-constant: system(varname), system(string + n), system(varname) Each: recall 1.0, precision 1.0, 0 decoy FPs. Co-Authored-By: Claude Opus 4.7 (1M context) --- bench/tasks/c-system-non-constant/answer.yaml | 27 +++++++++++++++++++ .../tasks/c-system-non-constant/source/exec.c | 16 +++++++++++ bench/tasks/c-system-non-constant/task.toml | 9 +++++++ .../tasks/java-ssrf-resttemplate/answer.yaml | 20 ++++++++++++++ .../source/ProxyService.java | 23 ++++++++++++++++ .../java-ssrf-resttemplate/source/pom.xml | 7 +++++ bench/tasks/java-ssrf-resttemplate/task.toml | 9 +++++++ bench/tasks/rust-mem-transmute/answer.yaml | 20 ++++++++++++++ .../rust-mem-transmute/source/Cargo.toml | 4 +++ .../rust-mem-transmute/source/src/lib.rs | 13 +++++++++ bench/tasks/rust-mem-transmute/task.toml | 9 +++++++ 11 files changed, 157 insertions(+) create mode 100644 bench/tasks/c-system-non-constant/answer.yaml create mode 100644 bench/tasks/c-system-non-constant/source/exec.c create mode 100644 bench/tasks/c-system-non-constant/task.toml create mode 100644 bench/tasks/java-ssrf-resttemplate/answer.yaml create mode 100644 bench/tasks/java-ssrf-resttemplate/source/ProxyService.java create mode 100644 bench/tasks/java-ssrf-resttemplate/source/pom.xml create mode 100644 bench/tasks/java-ssrf-resttemplate/task.toml create mode 100644 bench/tasks/rust-mem-transmute/answer.yaml create mode 100644 bench/tasks/rust-mem-transmute/source/Cargo.toml create mode 100644 bench/tasks/rust-mem-transmute/source/src/lib.rs create mode 100644 bench/tasks/rust-mem-transmute/task.toml diff --git a/bench/tasks/c-system-non-constant/answer.yaml b/bench/tasks/c-system-non-constant/answer.yaml new file mode 100644 index 0000000..30ffcf7 --- /dev/null +++ b/bench/tasks/c-system-non-constant/answer.yaml @@ -0,0 +1,27 @@ +issues: + - id: c-system-var-001 + file: exec.c + severity: HIGH + cwe: CWE-78 + vulnSlugs: [c-system-non-constant, command-injection] + location: { startLine: 4, endLine: 4, tolerance: 2 } + scanner: { mustEmitCandidate: true } + - id: c-system-concat-001 + file: exec.c + severity: HIGH + cwe: CWE-78 + vulnSlugs: [c-system-non-constant, command-injection] + location: { startLine: 9, endLine: 9, tolerance: 2 } + scanner: { mustEmitCandidate: true } + - id: c-system-var-002 + file: exec.c + severity: HIGH + cwe: CWE-78 + vulnSlugs: [c-system-non-constant, command-injection] + location: { startLine: 11, endLine: 11, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: c-system-literal-decoy + file: exec.c + line: 15 + forbiddenSlugs: [c-system-non-constant] diff --git a/bench/tasks/c-system-non-constant/source/exec.c b/bench/tasks/c-system-non-constant/source/exec.c new file mode 100644 index 0000000..40aba69 --- /dev/null +++ b/bench/tasks/c-system-non-constant/source/exec.c @@ -0,0 +1,16 @@ +#include + +int run_vulnerable_var(const char *cmd) { + return system(cmd); +} + +int run_vulnerable_concat(const char *path) { + char buf[256]; + int n = system("rm -- " + 0); + (void)buf; (void)path; (void)n; + return system(path); +} + +int run_safe(void) { + return system("ls -la /tmp"); +} diff --git a/bench/tasks/c-system-non-constant/task.toml b/bench/tasks/c-system-non-constant/task.toml new file mode 100644 index 0000000..52cf579 --- /dev/null +++ b/bench/tasks/c-system-non-constant/task.toml @@ -0,0 +1,9 @@ +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "C system() / popen() with non-literal argument — command injection." + +[labels] +change_rule = "freeze" diff --git a/bench/tasks/java-ssrf-resttemplate/answer.yaml b/bench/tasks/java-ssrf-resttemplate/answer.yaml new file mode 100644 index 0000000..a8edfae --- /dev/null +++ b/bench/tasks/java-ssrf-resttemplate/answer.yaml @@ -0,0 +1,20 @@ +issues: + - id: java-ssrf-resttemplate-001 + file: ProxyService.java + severity: HIGH + cwe: CWE-918 + vulnSlugs: [java-ssrf-resttemplate, ssrf] + location: { startLine: 9, endLine: 9, tolerance: 2 } + scanner: { mustEmitCandidate: true } + - id: java-ssrf-webclient-001 + file: ProxyService.java + severity: HIGH + cwe: CWE-918 + vulnSlugs: [java-ssrf-resttemplate, ssrf] + location: { startLine: 13, endLine: 13, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: java-non-http-decoy + file: ProxyService.java + line: 20 + forbiddenSlugs: [java-ssrf-resttemplate] diff --git a/bench/tasks/java-ssrf-resttemplate/source/ProxyService.java b/bench/tasks/java-ssrf-resttemplate/source/ProxyService.java new file mode 100644 index 0000000..0f24375 --- /dev/null +++ b/bench/tasks/java-ssrf-resttemplate/source/ProxyService.java @@ -0,0 +1,23 @@ +package com.example.proxy; + +import org.springframework.web.client.RestTemplate; +import org.springframework.web.reactive.function.client.WebClient; + +public class ProxyService { + + public String fetchVulnerable(String url) { + return new RestTemplate().getForObject(url, String.class); + } + + public String fetchWebClientVulnerable(String url) { + return WebClient.create().get().uri(url).retrieve().bodyToMono(String.class).block(); + } + + public String fetchHealthSafe() { + return "internal:status:ok"; + } + + public String renderName(String name) { + return "Hello, " + name; + } +} diff --git a/bench/tasks/java-ssrf-resttemplate/source/pom.xml b/bench/tasks/java-ssrf-resttemplate/source/pom.xml new file mode 100644 index 0000000..72eb6da --- /dev/null +++ b/bench/tasks/java-ssrf-resttemplate/source/pom.xml @@ -0,0 +1,7 @@ + + + 4.0.0 + com.example + ssrf-fixture + 0.0.1 + diff --git a/bench/tasks/java-ssrf-resttemplate/task.toml b/bench/tasks/java-ssrf-resttemplate/task.toml new file mode 100644 index 0000000..d879213 --- /dev/null +++ b/bench/tasks/java-ssrf-resttemplate/task.toml @@ -0,0 +1,9 @@ +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "Java RestTemplate / WebClient making outbound HTTP to a URL built from input (SSRF)." + +[labels] +change_rule = "freeze" diff --git a/bench/tasks/rust-mem-transmute/answer.yaml b/bench/tasks/rust-mem-transmute/answer.yaml new file mode 100644 index 0000000..26d36fa --- /dev/null +++ b/bench/tasks/rust-mem-transmute/answer.yaml @@ -0,0 +1,20 @@ +issues: + - id: rust-mem-transmute-001 + file: src/lib.rs + severity: MEDIUM + cwe: CWE-704 + vulnSlugs: [rust-mem-transmute] + location: { startLine: 4, endLine: 4, tolerance: 2 } + scanner: { mustEmitCandidate: true } + - id: rust-mem-transmute-002 + file: src/lib.rs + severity: MEDIUM + cwe: CWE-704 + vulnSlugs: [rust-mem-transmute] + location: { startLine: 8, endLine: 8, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: rust-from-bits-safe-decoy + file: src/lib.rs + line: 12 + forbiddenSlugs: [rust-mem-transmute] diff --git a/bench/tasks/rust-mem-transmute/source/Cargo.toml b/bench/tasks/rust-mem-transmute/source/Cargo.toml new file mode 100644 index 0000000..b05aa9a --- /dev/null +++ b/bench/tasks/rust-mem-transmute/source/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "fixture" +version = "0.0.1" +edition = "2021" diff --git a/bench/tasks/rust-mem-transmute/source/src/lib.rs b/bench/tasks/rust-mem-transmute/source/src/lib.rs new file mode 100644 index 0000000..6ed6e1f --- /dev/null +++ b/bench/tasks/rust-mem-transmute/source/src/lib.rs @@ -0,0 +1,13 @@ +use std::mem; + +pub fn reinterpret_bits_vulnerable(x: u64) -> f64 { + unsafe { mem::transmute(x) } +} + +pub fn reinterpret_std_vulnerable(x: i32) -> u32 { + unsafe { std::mem::transmute(x) } +} + +pub fn convert_safe(x: u64) -> f64 { + f64::from_bits(x) +} diff --git a/bench/tasks/rust-mem-transmute/task.toml b/bench/tasks/rust-mem-transmute/task.toml new file mode 100644 index 0000000..6dd91c2 --- /dev/null +++ b/bench/tasks/rust-mem-transmute/task.toml @@ -0,0 +1,9 @@ +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "Rust mem::transmute call — manual unsoundness review warranted." + +[labels] +change_rule = "freeze"