From 7dda75a0f310fd5a3da34b7130c8705e92bfc2b1 Mon Sep 17 00:00:00 2001 From: Noel Date: Thu, 14 May 2026 17:09:59 +0200 Subject: [PATCH] corpus: rust-axum-no-auth + java-xxe + swift-keychain (toward #84) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Third batch of under-covered-language bench tasks. Bench 15 → 18 tasks. Three more matcher slugs exercised across the Phase-2/3 languages. ## rust-axum-no-auth Exercises `rust-axum-no-auth-extractor` — state-changing axum POST route without an auth extractor in the handler signature. The matcher is noise_tier=noisy because handler-auth analysis is context-dependent; the bench task pins the regex hook. `matcher_exclude = ["axum-handler", "auth-bypass"]` — the unrelated `axum-handler` and `auth-bypass` matchers fire on literally every axum route + a router file shape; they're noise on this slug-under-test. ## java-xxe Exercises `java-xxe` (and the bundled language-agnostic `xxe-xml-parser` sibling) — `DocumentBuilderFactory.newInstance()` without external-entity hardening. Single-method fixture; decoy is a non-XML method on the same class. ## swift-keychain-no-access Exercises `swift-keychain-no-access-control` — `SecItemAdd` without `kSecAttrAccessControl`, leaving the keychain item readable without auth prompt. Single-function fixture; decoy is a token-formatting helper that doesn't touch the keychain. ## Scoring Each task standalone: **recall 1.0**, **precision 1.0**, **0 decoy FPs**. Whole-bench: task_count 15 → 18 (+3) recall 0.9706 → 0.9730 (better) precision 1.0 → 1.0 (unchanged) decoy FP 0 0 ## Toward #84 18 of 30 target tasks. Halfway-plus. Now covering: - Java (3 fixtures, 7 slugs) - Rust (2 fixtures, 3 slugs) - C (1 fixture, 2 slugs) - Kotlin (1 fixture, 2 slugs) - Swift (2 fixtures, 2 slugs) - Ruby (1 fixture, 1 slug) - TS / Python / Go (the pre-existing corpus) Remaining under-covered: PHP and C# both at zero (would need matcher PRs first), more JVM Spring shapes, the WKWebView / intent-implicit Kotlin Android slugs, more Swift secure-trust flavors. Co-Authored-By: Claude Opus 4.7 (1M context) --- bench/tasks/java-xxe/answer.yaml | 13 ++++++++++++ bench/tasks/java-xxe/source/XmlService.java | 19 ++++++++++++++++++ bench/tasks/java-xxe/source/pom.xml | 7 +++++++ bench/tasks/java-xxe/task.toml | 9 +++++++++ bench/tasks/rust-axum-no-auth/answer.yaml | 13 ++++++++++++ .../tasks/rust-axum-no-auth/source/Cargo.toml | 7 +++++++ .../rust-axum-no-auth/source/src/main.rs | 20 +++++++++++++++++++ bench/tasks/rust-axum-no-auth/task.toml | 11 ++++++++++ .../swift-keychain-no-access/answer.yaml | 13 ++++++++++++ .../source/Keychain.swift | 16 +++++++++++++++ .../tasks/swift-keychain-no-access/task.toml | 9 +++++++++ 11 files changed, 137 insertions(+) create mode 100644 bench/tasks/java-xxe/answer.yaml create mode 100644 bench/tasks/java-xxe/source/XmlService.java create mode 100644 bench/tasks/java-xxe/source/pom.xml create mode 100644 bench/tasks/java-xxe/task.toml create mode 100644 bench/tasks/rust-axum-no-auth/answer.yaml create mode 100644 bench/tasks/rust-axum-no-auth/source/Cargo.toml create mode 100644 bench/tasks/rust-axum-no-auth/source/src/main.rs create mode 100644 bench/tasks/rust-axum-no-auth/task.toml create mode 100644 bench/tasks/swift-keychain-no-access/answer.yaml create mode 100644 bench/tasks/swift-keychain-no-access/source/Keychain.swift create mode 100644 bench/tasks/swift-keychain-no-access/task.toml diff --git a/bench/tasks/java-xxe/answer.yaml b/bench/tasks/java-xxe/answer.yaml new file mode 100644 index 0000000..f7093a4 --- /dev/null +++ b/bench/tasks/java-xxe/answer.yaml @@ -0,0 +1,13 @@ +issues: + - id: java-xxe-001 + file: XmlService.java + severity: HIGH + cwe: CWE-611 + vulnSlugs: [java-xxe, xxe, xxe-xml-parser] + location: { startLine: 11, endLine: 11, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: java-non-xml-greet-decoy + file: XmlService.java + line: 17 + forbiddenSlugs: [java-xxe] diff --git a/bench/tasks/java-xxe/source/XmlService.java b/bench/tasks/java-xxe/source/XmlService.java new file mode 100644 index 0000000..f05bd6a --- /dev/null +++ b/bench/tasks/java-xxe/source/XmlService.java @@ -0,0 +1,19 @@ +package com.example.xml; + +import java.io.InputStream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.Document; + +public class XmlService { + + public Document parseVulnerable(InputStream in) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + return db.parse(in); + } + + public String greet(String name) { + return "Hello, " + name; + } +} diff --git a/bench/tasks/java-xxe/source/pom.xml b/bench/tasks/java-xxe/source/pom.xml new file mode 100644 index 0000000..a8493b4 --- /dev/null +++ b/bench/tasks/java-xxe/source/pom.xml @@ -0,0 +1,7 @@ + + + 4.0.0 + com.example + xml-fixture + 0.0.1 + diff --git a/bench/tasks/java-xxe/task.toml b/bench/tasks/java-xxe/task.toml new file mode 100644 index 0000000..23dffd6 --- /dev/null +++ b/bench/tasks/java-xxe/task.toml @@ -0,0 +1,9 @@ +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "Under-covered Phase-2 language fixture. Java XXE: DocumentBuilderFactory.newInstance without external-entity hardening." + +[labels] +change_rule = "freeze" diff --git a/bench/tasks/rust-axum-no-auth/answer.yaml b/bench/tasks/rust-axum-no-auth/answer.yaml new file mode 100644 index 0000000..f97ce0d --- /dev/null +++ b/bench/tasks/rust-axum-no-auth/answer.yaml @@ -0,0 +1,13 @@ +issues: + - id: rust-axum-no-auth-001 + file: src/main.rs + severity: MEDIUM + cwe: CWE-862 + vulnSlugs: [rust-axum-no-auth-extractor] + location: { startLine: 18, endLine: 18, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: rust-helper-no-route-decoy + file: src/main.rs + line: 13 + forbiddenSlugs: [rust-axum-no-auth-extractor] diff --git a/bench/tasks/rust-axum-no-auth/source/Cargo.toml b/bench/tasks/rust-axum-no-auth/source/Cargo.toml new file mode 100644 index 0000000..9d5e4b2 --- /dev/null +++ b/bench/tasks/rust-axum-no-auth/source/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "fixture" +version = "0.0.1" +edition = "2021" + +[dependencies] +axum = "0.7" diff --git a/bench/tasks/rust-axum-no-auth/source/src/main.rs b/bench/tasks/rust-axum-no-auth/source/src/main.rs new file mode 100644 index 0000000..938515e --- /dev/null +++ b/bench/tasks/rust-axum-no-auth/source/src/main.rs @@ -0,0 +1,20 @@ +use axum::{routing::post, Router, Json}; +use serde::Deserialize; + +#[derive(Deserialize)] +struct Item { + name: String, +} + +async fn create_item(Json(_): Json) { + // No auth extractor — anyone can POST. +} + +fn helper(label: &str) -> String { + format!("[{}]", label) +} + +pub fn router() -> Router { + Router::new() + .route("/items", post(create_item)) +} diff --git a/bench/tasks/rust-axum-no-auth/task.toml b/bench/tasks/rust-axum-no-auth/task.toml new file mode 100644 index 0000000..c1fc183 --- /dev/null +++ b/bench/tasks/rust-axum-no-auth/task.toml @@ -0,0 +1,11 @@ +matcher_exclude = ["axum-handler", "auth-bypass"] + +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "Under-covered Phase-2 language fixture per CLAUDE.md project invariant. Axum state-changing POST route without an auth extractor in the handler signature." + +[labels] +change_rule = "freeze" diff --git a/bench/tasks/swift-keychain-no-access/answer.yaml b/bench/tasks/swift-keychain-no-access/answer.yaml new file mode 100644 index 0000000..fecf25a --- /dev/null +++ b/bench/tasks/swift-keychain-no-access/answer.yaml @@ -0,0 +1,13 @@ +issues: + - id: swift-keychain-no-access-001 + file: Keychain.swift + severity: MEDIUM + cwe: CWE-200 + vulnSlugs: [swift-keychain-no-access-control] + location: { startLine: 10, endLine: 10, tolerance: 2 } + scanner: { mustEmitCandidate: true } +decoys: + - id: swift-non-keychain-decoy + file: Keychain.swift + line: 14 + forbiddenSlugs: [swift-keychain-no-access-control] diff --git a/bench/tasks/swift-keychain-no-access/source/Keychain.swift b/bench/tasks/swift-keychain-no-access/source/Keychain.swift new file mode 100644 index 0000000..d143177 --- /dev/null +++ b/bench/tasks/swift-keychain-no-access/source/Keychain.swift @@ -0,0 +1,16 @@ +import Foundation +import Security + +func storeTokenVulnerable(_ token: String) { + let query: [String: Any] = [ + kSecClass as String: kSecClassGenericPassword, + kSecAttrAccount as String: "auth-token", + kSecValueData as String: token.data(using: .utf8)!, + ] + SecItemAdd(query as CFDictionary, nil) +} + +func formatTokenPreview(_ token: String) -> String { + let prefix = token.prefix(6) + return "token: \(prefix)…" +} diff --git a/bench/tasks/swift-keychain-no-access/task.toml b/bench/tasks/swift-keychain-no-access/task.toml new file mode 100644 index 0000000..e15334d --- /dev/null +++ b/bench/tasks/swift-keychain-no-access/task.toml @@ -0,0 +1,9 @@ +[provenance] +source = "handcraft" +added_at = "2026-05-14" +reviewer = "@noeljackson" +review_due = "2027-05-14" +notes = "Under-covered Phase-3 language fixture. Swift SecItemAdd keychain insertion without kSecAttrAccessControl — item readable without auth prompt." + +[labels] +change_rule = "freeze"