diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..6d145c264b9705a78c855c9c62e52924fb4373c4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +codebases/*.zip filter=lfs diff=lfs merge=lfs -text +papers/*.pdf filter=lfs diff=lfs merge=lfs -text diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..bd352acae347cc963f6891e5853aaac146504177 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,95 @@ +# Changelog + +## v1.2.2 (2026-05-01) + +### Artifact line-number and SHA-256 fixup (5 zkLLM artifacts) +- Fixed stale `anchor.start`/`anchor.end`, `expect_sha256`, `conflict_keys.regions`, and `finding.labels.relevant_code` in 5 zkLLM artifacts after the `zkllm.zip` codebase update in v1.2.1 shifted line numbers: + - **zkLLM-004**: tlookup.cu 384-385 → 401-402 + - **zkLLM-006**: main.cu 252-261 → 302-311 + - **zkLLM-007**: stage_proof.cuh 212-213 → 215-216 + - **zkLLM-012**: tlookup.cu 19-22 → 36-39 + - **zkLLM-013**: main.cu 138-158 → 138-204 (block expanded; SHA updated) +- **`data/baseline_findings.json`**: corrected two stale line references — `self-attn.cu:230-237` → `self-attn.cu:139-140` (file only has 226 lines) and `main.cu:174-189` → `main.cu:31-35` (pointed at wrong code after line shift). +- Rebuilt `MANIFEST.json`, `data/artifacts.parquet`. `verify_dataset.py` passes all checks. + +## v1.2.1 (2026-04-30) + +### Schema cleanup — `finding.labels` reduced to two fields +- Stripped the `severity` field from all 52 artifacts that still carried it. The v2 schema (`additionalProperties: false`) only permits `relevant_code` and `paper_reference` under `finding.labels`; `severity` was a stale leftover from the v1 → v2 migration that had been silently failing schema validation in `verify_dataset.py`. +- Removed `category` and `security_concern` from artifact JSONs in the same pass. These fields are no longer carried as per-artifact labels (the grader does not consume them). + +### Codebase runtime fixes (`zkllm.zip`) +- Updated `zkllm.zip` with three runtime fixes: transcript alignment, a most-vexing-parse correction, and tensor padding. SHA-256 in `MANIFEST.json` refreshed. + +### Tooling — `build_parquet.py` is now the single rebuild script +- `scripts/build_parquet.py` extended to also (a) refresh the `artifact_count` column in `data/pairs.parquet` from on-disk artifact files (preserving all static pair metadata) and (b) regenerate `MANIFEST.json` with fresh sha256 + size for every artifact, codebase, and paper. Running the script is now the one command required to rebuild every derived dataset file. + +### Artifact count correction +- `data/pairs.parquet` `artifact_count` corrected to match on-disk files: zkgpt=14, zkllm=13, zkml=14, zktorch=15 (previously incorrectly reported as 15/15/15/16). **Authoritative artifact total is 56**, not 61 as some earlier release notes implied — the v1.1.0 additions were partially superseded during the v2 schema cleanup. +- `MANIFEST.json` refreshed with new sha256 hashes for the 52 modified artifact JSONs. `verify_dataset.py` now passes all checks. + +## v1.2.0 (2026-04-28) + +### Clean codebase fixes (zktorch) +- **zktorch.zip**: Fixed epsilon hardcoded to `1.0` in BatchNorm — now properly scaled by SF_FLOAT (norm.rs:60-61) +- **zktorch.zip**: Fixed blanket `< 1e-10` near-zero guard — now checks after scaling instead of on raw float (onnx.rs:73-76) + +### Baseline findings +- Added `data/baseline_findings.json` — 10 known pre-existing gaps in clean codebases (2 zkgpt, 5 zkllm, 3 zktorch). These are inherent to the research prototypes and are not injected bugs. The grader's `--baseline` flag excludes matching agent findings from scoring. + +## v1.1.0 (2026-04-25) + +### Clean codebase fixes +- **zkgpt.zip**: Fixed `pow(1,-8)` → `pow(2,-8)` in softmax scale factor (neuralNetwork.cpp:354-356) +- **zkllm.zip**: Fixed FFN output to save rescaled `down_out_` instead of unrescaled `down_out` (ffn.cu:137, 152) + +### Artifact label corrections (4 relabeled) +- zkGPT-003, zkGPT-004, zkGPT-005: `Engineering/Prototype Gap` → `Specification Mismatch` (bias removal, identity LayerNorm, and zeroed weights are specification deviations) +- zkML-001: `Engineering/Prototype Gap` → `Protocol/Transcript Logic` (hardcoded Freivalds challenge is a protocol violation) + +### New artifacts (5 added, 56 → 61 total at the time) +- **zkGPT-014**: Softmax Scale Factor Evaluates to Unity (Numerical/Quantization Bug, Warning) +- **zkGPT-015**: Attention Dimension Scaling Factor Removed (Specification Mismatch, Critical) +- **zkLLM-015**: FFN Output Saved at Wrong Rescaling Level (Numerical/Quantization Bug, Warning) +- **zkML-015**: Selector Constraint Enforcement Disabled by Default (Engineering/Prototype Gap, Critical) +- **zkTorch-016**: BatchAdd Verification Assertion Removed (Under-constrained Circuit, Critical) + +> **Note**: the artifact total temporarily reached 61 with this release. The v2-schema cleanup in v1.2.1 reconciled the on-disk count back to 56; see v1.2.1 above for the authoritative count. + +### Data updates +- MANIFEST.json updated (69 entries, new SHA-256 hashes for modified files) +- Parquet files rebuilt (artifacts: 61 rows, pairs: updated artifact_count) + +## v1.0.1 (post-v1.0.0 maintenance, pre-v1.1.0) + +This was a series of in-place corrections committed against the v1.0.0 release before v1.1.0 was tagged. They are documented retroactively for completeness. + +### Schema migration — v1 → v2 (all 56 artifacts) +- Removed root-level v1 fields from every artifact: `name`, `category`, `severity`, `aliases`, `notes`. +- Normalized `source` from a nested object to a string enum (`real` | `synthetic`). +- Moved `finding.severity` → `finding.labels.severity` and `finding.location` → `finding.labels.relevant_code`. +- `verify_dataset.py` now performs full v2 JSON-schema validation (no more v1 skip). +- `build_dataset.py` updated to read v2 fields directly (the `extract_source` helper was removed). +- Cleaned v1 references from `README.md`, `CHANGELOG.md`, and the schema description. +- The migration helper script was deleted after the migration completed. + +### Anchor and probe corrections +- All 13 zkGPT artifacts: recomputed `expect_sha256` anchors against the current codebase zip. +- zkML-006: narrowed `not_contains` probe from `AddPairsChip` to `AddPairsChip::::construct` (the broader form was too aggressive). +- zkML-007: removed a `not_contains` probe (line 272 legitimately contains the same text). +- zkTorch-002: narrowed `not_contains` probe from `1 << 15` to `y.clamp(-(1 << 15)`. +- zkGPT-010, zkLLM-002, zkML-001: removed `not_contains` probes that checked for text absence file-wide. The same text legitimately appears outside the edit range, so the probes were redundant (the corresponding `contains` probes already validated injection) and incorrect. +- `MANIFEST.json` updated with refreshed SHA-256 hashes for all modified files. + +### Documentation corrections +- Fixed paper year/venue, citation URL, the `load_dataset` example, artifact summary stats, and label-coverage notes in `README.md`. +- Merged the Hugging Face default `.gitattributes` and added a Git LFS rule for PDFs. + +## v1.0.0 (2026-04-22) + +- Initial release +- 4 (paper, codebase) pairs: zkLLM, zkML, zkTorch, zkGPT +- 56 bug artifacts (14 + 14 + 15 + 13) +- Two Parquet configs: `pairs` (4 rows) and `artifacts` (56 rows) +- SHA256 manifest for all files +- Artifact format: v2 JSON schema (`artifact.v2.schema.json`) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..4266bbd13b82a8ac3021fe0139aca10e1596b24c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,214 @@ +# Contributing to `zkml-audit-benchmark` + +Thank you for your interest in extending this benchmark. This guide walks you through the workflow for adding a new **(paper, codebase) pair** and authoring **bug artifacts** that target it. + +If you are filing a bug report, label correction, or documentation fix instead, please open an issue first; the workflow below is specifically for *content* contributions to the dataset. + +--- + +## Quick Reference + +| Task | Where | +|------|-------| +| Add a new (paper, codebase) pair | Sections [1](#1-add-the-codebase-snapshot) and [2](#2-register-the-pair-in-buildparquetpy) | +| Author bug artifacts | Section [3](#3-author-bug-artifact-jsons) | +| Regenerate derived files | Section [4](#4-regenerate-parquet-and-manifest) | +| Validate before submitting | Section [5](#5-validate) | +| PR checklist | Section [6](#6-pr-checklist) | + +Authoritative schema: [`schema/artifact.v2.schema.json`](schema/artifact.v2.schema.json). +Recently changed/added items: [`CHANGELOG.md`](CHANGELOG.md). + +--- + +## 1. Add the codebase snapshot + +For a new pair `pair_id` (use a short, lowercase identifier — e.g., `zkfoo`): + +1. **Freeze the codebase**. If the upstream project uses Git, prefer pinning to a commit hash: + ```bash + git clone /tmp/upstream + cd /tmp/upstream && git checkout + git archive --format=zip --prefix=zkfoo/ HEAD -o /path/to/zkml-audit-benchmark/codebases/zkfoo.zip + ``` + If the upstream project ships a non-Git release (e.g., a Zenodo tarball), record the source URL and the snapshot date in your `CHANGELOG.md` entry. +2. **Verify the LICENSE file is included** inside the ZIP. Each codebase retains its upstream license; we redistribute for research-reproducibility purposes only. +3. **Add the paper PDF** at `papers/{pair_id}.pdf`. Use the publisher's canonical PDF where possible; record the source URL in `CHANGELOG.md`. +4. **Track the ZIP via Git LFS** (the repository is configured for `*.zip` LFS; new pair ZIPs are picked up automatically). + +--- + +## 2. Register the pair in `build_parquet.py` + +Open [`scripts/build_parquet.py`](scripts/build_parquet.py) and add your `pair_id` to the `PAIR_IDS` list at the top of the file: + +```python +PAIR_IDS = ["zkgpt", "zkllm", "zkml", "zktorch", "zkfoo"] +``` + +The script auto-discovers artifacts under `artifacts/{pair_id}/*.json` and pulls codebase / paper hashes from `codebases/{pair_id}.zip` and `papers/{pair_id}.pdf`. Static pair metadata (paper title, venue, year, language, snapshot note) lives in `data/pairs.parquet`; if you are adding a brand-new pair, you will also need to add a row to that table — the simplest path is to load it via `pyarrow`, append a row, and write it back. See `scripts/build_parquet.py` for the exact schema. + +--- + +## 3. Author bug artifact JSONs + +Each artifact is a single JSON file at `artifacts/{pair_id}/{Pair}-NNN.json`. Use the camel-case pair prefix that matches the existing artifacts (`zkLLM`, `zkML`, `zkTorch`, `zkGPT`, or your new `zkFoo`) and a zero-padded three-digit sequence. + +### 3.1 Required fields (per `artifact.v2.schema.json`) + +| Field | Purpose | +|-------|---------| +| `artifact_id` | Unique ID matching `^(zkML\|zkTorch\|zkLLM\|zkGPT\|)-\d{3}$` | +| `codebase` | Target codebase directory name (matches the directory inside the ZIP) | +| `source` | `"real"` (from a real audit report) or `"synthetic"` (authored for coverage) | +| `finding.name` | Human-readable short title, 3–7 words | +| `finding.explanation` | One paragraph: root cause and impact | +| `finding.labels.relevant_code` | Comma-separated `file:line[-line]` references (or empty string) | +| `finding.labels.paper_reference` | Section/theorem/protocol citation, optionally with a quoted claim (or `"-"`) | +| `edits` | Ordered list of code edits using ops: `replace_block`, `insert_after`, `insert_before`, `delete_block`, `replace_regex`, `create_file` | +| `conflict_keys.files` | All files touched by the edits | +| `conflict_keys.regions` | Expanded line-range regions for overlap detection | +| `conflict_keys.semantic_tags` | Semantic labels; two artifacts sharing a tag are treated as conflicting | +| `conflict_keys.requires` | (Optional) artifact IDs that must be applied first | +| `conflict_keys.incompatible` | (Optional) artifact IDs explicitly incompatible with this one | +| `presence_probes` | Post-injection assertions; the `dataset_generator` uses these to validate that the bug actually landed | + +A minimal skeleton: + +```json +{ + "artifact_id": "zkFoo-001", + "codebase": "zkfoo-fixed", + "source": "synthetic", + "finding": { + "name": "Missing range check on softmax witness", + "explanation": "The softmax output is loaded as a free advice cell without a polynomial constraint binding it to the input. A malicious prover can substitute any value and still satisfy the circuit.", + "labels": { + "relevant_code": "src/softmax.rs:42-58, src/circuit.rs:120", + "paper_reference": "Section 4.2: \"Each non-linear operator is enforced via a lookup argument against the precomputed table.\"" + } + }, + "edits": [ + { + "file": "src/softmax.rs", + "op": "delete_block", + "anchor": { "kind": "line_range", "start": 42, "end": 58 } + } + ], + "conflict_keys": { + "files": ["src/softmax.rs"], + "regions": [{ "file": "src/softmax.rs", "start": 42, "end": 58 }], + "semantic_tags": ["softmax-range-check"] + }, + "presence_probes": [ + { + "kind": "line_equals", + "file": "src/softmax.rs", + "line": 42, + "expected": " fn forward(&self, ..." + } + ] +} +``` + +### 3.2 Authoring guidance + +- **Make each artifact atomic**: one soundness gap per artifact. If a single conceptual bug requires two related edits in different files, keep them in *one* artifact and use multiple `edits` entries. +- **Tie every artifact back to a paper claim** in `paper_reference`. If no specific paper section maps cleanly, use `"-"` and explain the reasoning in `finding.explanation`. The grader's paper-reference scorer is part of the quality gate, so accurate citations materially improve scoring. +- **Use precise line ranges** in `relevant_code`. The grader scores code-location matches by line proximity (overlap, within 2 lines, within 30, within 100); imprecise references reduce match quality even when the agent finds the right bug. +- **Write `presence_probes` that fail loudly** if the edit silently no-ops. `line_equals` probes that pin the exact post-injection content of the modified line are the most reliable. +- **Set `semantic_tags` to enable safe composition**: two artifacts that share a tag are treated as conflicting by `RandomStrategy` in `dataset_generator`. Use tags for *what the bug is about* (e.g., `softmax-range-check`, `pedersen-commit-aux`), not for general areas of the code. +- **`source: "real"` vs. `"synthetic"`**: use `real` only when the artifact is grounded in an external audit report or in a documented soundness gap from the original paper's released code. Synthetic artifacts are authored for coverage and should clearly describe the construction. + +--- + +## 4. Regenerate Parquet and `MANIFEST.json` + +After adding/modifying artifacts, papers, or codebases: + +```bash +cd zkml-audit-benchmark/ +python scripts/build_parquet.py +``` + +This rebuilds: +- `data/artifacts.parquet` (one row per artifact, with flattened metadata) +- `data/pairs.parquet` (refreshes `artifact_count` for each pair) +- `MANIFEST.json` (SHA-256 hashes for every file in the dataset) + +Commit the regenerated files alongside your content changes — they are part of the dataset and consumers rely on them. + +--- + +## 5. Validate + +### 5.1 Byte-exact integrity + +```bash +python scripts/verify_dataset.py +``` + +This re-hashes every file listed in `MANIFEST.json` and verifies the result matches. Any mismatch indicates a stale Parquet/MANIFEST regeneration. + +### 5.2 JSON-schema conformance + +Each artifact must conform to `schema/artifact.v2.schema.json`. A minimal validation snippet: + +```python +import json +from pathlib import Path +from jsonschema import Draft202012Validator + +schema = json.loads(Path("schema/artifact.v2.schema.json").read_text()) +validator = Draft202012Validator(schema) +for af in Path("artifacts").rglob("*.json"): + instance = json.loads(af.read_text()) + errors = list(validator.iter_errors(instance)) + assert not errors, f"{af}: {errors}" +``` + +### 5.3 Presence-probe round-trip (recommended) + +For real validation that an artifact lands cleanly on the clean codebase, generate a single-artifact case via the companion zkML-inspector-benchmark tooling: + +```bash +python -m dataset_generator test \ + --output /tmp/probe_check \ + --num-cases 1 \ + --artifacts-per-case 1 \ + --strategy fixed \ + --artifact-ids zkFoo-001 +``` + +A successful build with no errors in `/tmp/probe_check/errors.json` confirms that the artifact's edits and probes are consistent. + +### 5.4 Croissant metadata + +The NeurIPS Datasets & Benchmarks Track requires Hugging Face–hosted datasets to ship valid Croissant metadata. Hugging Face auto-generates the Croissant file from your dataset card and Parquet configs after every push. Validate it after pushing your changes via: + + + +If the checker reports errors, they typically trace back to YAML frontmatter in `README.md` or to a malformed Parquet schema; fix and re-push. + +--- + +## 6. PR Checklist + +Please confirm each of the following before opening a pull request: + +- [ ] New pair (if any) registered in `scripts/build_parquet.py` (`PAIR_IDS`). +- [ ] Codebase ZIP and paper PDF placed under `codebases/` and `papers/` respectively, with upstream LICENSE preserved inside the ZIP. +- [ ] Each new artifact JSON conforms to `schema/artifact.v2.schema.json` (validated as in §5.2). +- [ ] `python scripts/build_parquet.py` re-run; resulting `data/*.parquet` and `MANIFEST.json` committed. +- [ ] `python scripts/verify_dataset.py` passes with no errors. +- [ ] `paper_reference` cites a specific section/theorem/protocol from the bundled PDF (or is `"-"` with rationale in `finding.explanation`). +- [ ] `CHANGELOG.md` updated with a new entry (artifact IDs added, label changes, codebase fixes, schema changes). +- [ ] If submitting during a NeurIPS review window: no personal identifiers in PR description, commit messages, or new files. + +--- + +## Schema Evolution + +Backward-incompatible changes to the artifact JSON format ship as a new schema file (`schema/artifact.vN.schema.json`) rather than mutating the existing one. Each artifact records its target schema version implicitly via its on-disk shape; existing artifacts are migrated in a single, separately-committed pass with a `CHANGELOG.md` entry. + +If you have a proposal that requires a schema bump, please open an issue first to discuss the migration plan before submitting a PR. diff --git a/DATASHEET.md b/DATASHEET.md new file mode 100644 index 0000000000000000000000000000000000000000..3a18044fcaa5cb7815c88d6fc37d7e6b05b39eee --- /dev/null +++ b/DATASHEET.md @@ -0,0 +1,323 @@ +# Datasheet for `zkml-audit-benchmark` + +This datasheet follows the template of *Datasheets for Datasets* (Gebru et al., 2021, CACM, [arXiv:1803.09010](https://arxiv.org/abs/1803.09010)). It documents the `zkml-audit-benchmark` dataset: a benchmark for evaluating AI agents on **zkML soundness auditing**. + +- **Dataset**: `zkml-audit-benchmark` +- **Version at time of writing**: v1.2.0 (2026-04-28) +- **Hosting**: +- **Code repository**: see the upstream GitHub repository linked from the Hugging Face dataset card +- **Author / maintainer**: anonymized for NeurIPS 2026 submission +- **License (curation layer)**: [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/). Each upstream codebase and paper retains its original license — see `Distribution` below. + +--- + +## Motivation + +> *The questions in this section are primarily intended to encourage dataset creators to clearly articulate their reasons for creating the dataset and to promote transparency about funding interests.* + +**1. For what purpose was the dataset created? Was there a specific task in mind? Was there a specific gap that needed to be filled?** + +The dataset was created to enable systematic evaluation of automated auditing tools for **zero-knowledge machine learning (zkML)** implementations. State-of-the-art zkML frameworks frequently exhibit **theory-to-implementation gaps**: the deployed code omits cryptographic operations (Pedersen commitments on auxiliary vectors, Lasso lookup arguments, Spice memory-checking, etc.) that the corresponding paper claims are part of the protocol. Manual audits of two flagship systems (zkLLM and zkGPT) revealed that closing these gaps inflates the reported prover cost by 12.35× in zkLLM and the proof size by 14.5× in zkGPT — evidence that the gap is real, severe, and worth measuring at scale. Manual audits at this level of rigor do not scale to the broader zkML literature, motivating an automated benchmark. + +The specific task supported by the dataset is **soundness-gap detection**: given a (paper, codebase) pair plus optional injected vulnerabilities, an agent must produce a structured list of findings that match the ground-truth artifacts. Two complementary workflows are supported: +- *Pair extraction* — load a clean (paper, codebase) pair for zero-shot auditing. +- *Test-case generation* — sample artifacts from the pool and inject them into the clean codebase, producing a flawed codebase with known ground-truth findings for graded evaluation. + +The dataset fills a gap not covered by existing security benchmarks (Juliet, OWASP Benchmark, NIST CAVP), none of which pair academic-paper claims with implementation artifacts; see the README's *Positioning vs. Existing Benchmarks* section for a comparison table. + +**2. Who created this dataset (e.g. which team, research group) and on behalf of which entity (e.g. company, institution, organization)?** + +Anonymized for NeurIPS 2026 submission. Full attribution will be added at camera-ready. + +**3. What support was needed to make this dataset? (e.g. who funded the creation of the dataset?)** + +Anonymized. Compute infrastructure for the high-fidelity replication audits that motivated the benchmark used a Lambda Cloud `gpu_1x_a100_sxm4` instance. No external grant identifiers are listed in this version. + +**4. Any other comments?** + +The benchmark is positioned as **community infrastructure**: it is designed to be extensible by ZKML researchers (see [CONTRIBUTING.md](CONTRIBUTING.md)) so future papers can be added as new (paper, codebase) pairs with their own artifact records. + +--- + +## Composition + +> *Most of these questions are intended to provide dataset consumers with the information they need to make informed decisions about using the dataset for specific tasks.* + +**1. What do the instances that comprise the dataset represent (e.g. documents, photos, people, countries)? Are there multiple types of instances?** + +There are **two types of instances**: + +1. **(Paper, codebase) pairs**: each instance represents one published zkML system, consisting of a research-paper PDF and a frozen snapshot of the corresponding open-source implementation. +2. **Bug artifacts**: each instance is a JSON record describing a single soundness vulnerability — a declarative set of code edits that injects the bug, ground-truth labels for grading, and presence probes that verify the injection succeeded. + +In addition, the dataset ships derived/aggregate files: two Parquet tables (`pairs` and `artifacts`), a `MANIFEST.json` checksum manifest, a `schema/` directory, a `data/baseline_findings.json` file documenting pre-existing soundness gaps in the unmodified codebases, and helper scripts (`build_parquet.py`, `verify_dataset.py`). + +**2. How many instances are there in total (of each type, if appropriate)?** + +- **4 (paper, codebase) pairs**: `zkllm`, `zkml`, `zktorch`, `zkgpt`. +- **56 bug artifacts**: 14 zkGPT + 13 zkLLM + 14 zkML + 15 zkTorch. +- **20 of the 56 artifacts** are derived from real expert audit reports (`source: "real"`); the remaining 36 are synthetic, authored for broader coverage. + +**3. Does the dataset contain all possible instances or is it a sample (not necessarily random) of instances from a larger set?** + +The dataset is a **deliberate sample**. The four included frameworks were selected from a broader pool of ten candidate ZKML papers based on the availability of paired open-source codebases, license compatibility for redistribution, and feasibility of authoring artifacts grounded in the paper's protocol claims. The sample is not random; it is biased toward (a) frameworks targeting **transformer / LLM inference**, and (b) papers with **publicly archived reference implementations**. Future releases may incorporate additional pairs. + +**4. What data does each instance consist of?** + +- *(Paper, codebase) pair*: paper PDF (`papers/{pair_id}.pdf`), frozen codebase ZIP (`codebases/{pair_id}.zip`, stored via Git LFS), plus a row in `data/pairs.parquet` with metadata fields (paper title/venue/year, language, frameworks, snapshot note, SHA-256 hashes). +- *Bug artifact*: a JSON file at `artifacts/{pair_id}/{Pair}-NNN.json` conforming to `schema/artifact.v2.schema.json`. Required keys: `artifact_id`, `codebase`, `source`, `finding` (with `name`, `explanation`, and grader-aligned `labels`), `edits` (declarative code edits using `replace_block`/`insert_after`/`insert_before`/`delete_block`/`replace_regex`/`create_file`), `conflict_keys` (files, regions, semantic tags, requires/incompatible artifact IDs), and `presence_probes` (post-injection verification assertions). + +**5. Is there a label or target associated with each instance?** + +Yes, for bug artifacts. Each `finding.labels` record carries two graded fields used by the zkML-inspector-benchmark grader: `relevant_code` (file:line references) and `paper_reference` (section/theorem citation). (Paper, codebase) pairs do not carry per-pair labels. + +**6. Is any information missing from individual instances?** + +- The `zktorch` codebase is a directory snapshot dated 2026-04-19; the corresponding upstream Git commit hash is not recorded. `zkllm` is pinned to commit `993311e…`, `zkml` is pinned to commit `4378958…` ([ddkang/zkml](https://github.com/ddkang/zkml), the latest commit as of the snapshot date), and `zkgpt` is pinned to Zenodo record [14727819 v1](https://zenodo.org/records/14727819). +- A small number of artifacts have an empty `relevant_code` string when the bug is purely a missing operation (no specific line to point at) and `paper_reference: "-"` when no paper section directly applies. + + +**7. Are relationships between individual instances made explicit (e.g. users' movie ratings, social network links)?** + +Yes. Three relationship types are encoded: +- *Pair-to-artifact*: each artifact's `codebase` field points to one of the four pairs; this is the foreign key in `data/artifacts.parquet`. +- *Artifact-to-artifact (requires)*: an artifact may declare a list of artifacts that must be applied first. +- *Artifact-to-artifact (incompatible)*: an artifact may declare a list of artifacts it cannot be co-applied with. This information is what enables the controlled composition experiments described in the accompanying paper. + +**8. Are there recommended data splits (e.g. training, development/validation, testing)?** + +No standard train/dev/test split is shipped. The dataset is intended for **zero-shot evaluation** and for **controlled difficulty studies**, not supervised training. Users running grading experiments may freely partition pairs and artifacts to suit their evaluation. + +**9. Are there any errors, sources of noise, or redundancies in the dataset?** + +- v1.0.0 → v1.1.0 fixed two clean-codebase bugs (`pow(1,-8)` → `pow(2,-8)` in zkGPT softmax; FFN-output rescaling in zkLLM). v1.1.0 → v1.2.0 added two further clean-codebase fixes in zkTorch (epsilon in BatchNorm, near-zero guard in onnx.rs) and a `data/baseline_findings.json` file documenting 10 known pre-existing gaps in the clean codebases that should be excluded from grading via `--baseline`. + +**10. Is the dataset self-contained, or does it link to or otherwise rely on external resources (e.g. websites, tweets, other datasets)?** + +The dataset is **self-contained for evaluation purposes**: all paper PDFs, codebase ZIPs, artifact JSONs, and derived Parquet tables are bundled in the Hugging Face repository. Relevant external resources: +- The artifacts cite specific paper sections; the cited papers are bundled in `papers/`. +- The `zkllm` codebase declares CUDA / mcl-bn254 dependencies that consumers must install separately to actually compile or execute the code; this is not required for the auditing task itself. +- Grading is performed by the companion tool zkML-inspector-benchmark, which is a separate repository. + +**11. Does the dataset contain data that might be considered confidential (e.g. data that is protected by legal privilege or by doctor-patient confidentiality, data that includes the content of individuals' non-public communications)?** + +No. All papers are publicly published; all codebases are open-source releases by their original authors. + +**12. Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety?** + +No. + +**13. Does the dataset relate to people?** + +No. The dataset comprises research papers, source code, and synthetic bug records. It does not contain personal data, user-generated content, or human subjects in any form. Questions 14–16 of the Gebru template are therefore not applicable. + +**17. Any other comments?** + +The composition is **soundness-focused**: the artifacts are uniformly cryptographic-correctness defects rather than performance bugs, style violations, or privacy leaks. This focus is intentional — soundness is the property a ZK proof system primarily exists to provide. + +--- + +## Collection Process + +> *In addition to the goals of the prior section, the answers to questions here may provide information that allow others to reconstruct the dataset without access to it.* + +**1. How was the data associated with each instance acquired?** + +- *Paper PDFs* were downloaded from the publishers' / arXiv canonical URLs. +- *Codebases* were obtained from the authors' public release artifacts (GitHub repositories, Zenodo records). +- *Real* artifacts (`source: "real"`) were derived from manual audit reports of the source frameworks: each report identifies a soundness gap, and the corresponding artifact encodes the minimal code edit that re-introduces the gap on a clean codebase, plus the labels and probes needed to grade detection of it. +- *Synthetic* artifacts were authored by the maintainers to broaden vulnerability coverage, following the same JSON schema and validated by the same `presence_probes` mechanism. + +**2. What mechanisms or procedures were used to collect the data (e.g. hardware apparatus or sensor, manual human curation, software program, software API)?** + +Manual human curation throughout. Codebase snapshots were created by `git archive` (where a Git history was available) or by zipping a working directory. Artifact authoring was performed by hand against `schema/artifact.v2.schema.json` and validated by: +- JSON-schema conformance, +- Presence-probe execution after applying the declared edits to the clean codebase, +- The `verify_dataset.py` script for byte-exact integrity against `MANIFEST.json`. + +**3. If the dataset is a sample from a larger set, what was the sampling strategy?** + +Deterministic, criterion-based selection (not probabilistic). Frameworks were included if they (a) had been published in a peer-reviewed venue or as an established preprint, (b) had a publicly accessible reference implementation under a redistribution-permissive license, and (c) admitted authoring of at least ten high-quality bug artifacts. + +**4. Who was involved in the data collection process (e.g. students, crowdworkers, contractors) and how were they compensated?** + +Maintainers only; no crowdworkers or external contractors. No payment beyond the maintainers' research support. + +**5. Over what timeframe was the data collected?** + +Codebase snapshots and artifact authoring were carried out between 2025 and 2026. The codebases themselves are upstream releases dated as follows: +- `zkllm`: commit `993311e…` (2024). +- `zkml`: commit `4378958…` from [ddkang/zkml](https://github.com/ddkang/zkml) (Aug 2023; the latest upstream commit as of the snapshot date). +- `zktorch`: directory snapshot taken on 2026-04-19 (no public Git repository found). +- `zkgpt`: Zenodo record [14727819 v1](https://zenodo.org/records/14727819) (Jan 2025). + +The replication audits that motivated the benchmark were conducted in the same period and are documented in the accompanying paper. + +**7. Were any ethical review processes conducted (e.g. by an institutional review board)?** + +No formal ethical review was required: the dataset does not involve human subjects, does not collect personal data, and consists exclusively of publicly published research artifacts. + +**8. Does the dataset relate to people?** + +No. Questions 9–13 are therefore not applicable. + +**14. Any other comments?** + +Reconstructing the dataset from scratch is straightforward given the in-repository scripts: re-download upstream papers/codebases, place them under `papers/` and `codebases/`, populate `artifacts/` with the JSON files, and run `python scripts/build_parquet.py` to regenerate the derived Parquet tables and `MANIFEST.json`. + +--- + +## Preprocessing / Cleaning / Labeling + +> *The questions in this section are intended to provide dataset consumers with the information they need to determine whether the "raw" data has been processed in ways that are compatible with their chosen tasks.* + +**1. Was any preprocessing/cleaning/labeling of the data done?** + +Yes: +- *Codebase snapshotting*: working directories were captured at a fixed date, then ZIP-archived. For zkLLM, a Git commit hash was recorded; for the other three, only the snapshot date is recorded. +- *Codebase fixes*: a small number of pre-existing bugs in the clean codebases were corrected to ensure the unmodified pair represents a *clean baseline* (e.g., `pow(1,-8)` → `pow(2,-8)` in zkGPT softmax; FFN-output rescaling in zkLLM; epsilon in zkTorch BatchNorm). These corrections are listed in `CHANGELOG.md`. +- *Artifact authoring and labeling*: each artifact was assigned a comma-separated `relevant_code` string and a `paper_reference` citation under `finding.labels`. +- *Parquet flattening*: `scripts/build_parquet.py` flattens the nested artifact JSONs into row-oriented Parquet tables for fast filtering. The full JSONs remain the authoritative source. +- *Baseline-findings curation*: `data/baseline_findings.json` enumerates ten known pre-existing soundness gaps in the clean codebases that should be excluded from grading via the grader's `--baseline` flag. + +**2. Was the "raw" data saved in addition to the preprocessed/cleaned/labeled data?** + +Yes. The artifact JSONs are the raw, authoritative form; the Parquet tables are derived and can be regenerated at any time. Codebase ZIPs are byte-frozen snapshots; the corrections listed in CHANGELOG are applied inside those ZIPs and documented per release. + +**3. Is the software used to preprocess/clean/label the instances available?** + +Yes. `scripts/build_parquet.py` rebuilds `data/artifacts.parquet`, refreshes `artifact_count` in `data/pairs.parquet`, and regenerates `MANIFEST.json`. `scripts/verify_dataset.py` performs byte-exact integrity validation. Both scripts are bundled in the dataset repository under `scripts/`. + +**4. Any other comments?** + +No. + +--- + +## Uses + +> *These questions are intended to encourage dataset creators to reflect on the tasks for which the dataset should and should not be used.* + +**1. Has the dataset been used for any tasks already?** + +Yes. The dataset is used in the accompanying NeurIPS 2026 submission to evaluate `zkml-inspector`, a multi-agent AI auditing pipeline, across five controlled experiment families (isolated single-bug, combined realistic, k-curve, iterative, and clean-baseline). + +**2. Is there a repository that links to any or all papers or systems that use the dataset?** + +The Hugging Face dataset card links the accompanying paper (anonymized during the NeurIPS review window) and the zkML-inspector-benchmark grader repository. Citations and other systems will be added as they appear. + +**3. What (other) tasks could the dataset be used for?** + +- Zero-shot evaluation of new auditing agents (LLM-based or otherwise) on (paper, codebase) pairs. +- Controlled difficulty studies via the artifact-composition workflow (sampling k artifacts at a time and measuring how detection degrades with k). +- Reproducible regression testing for ZKML implementation maintainers prior to release. +- Education / training material for auditors learning to identify soundness gaps. +- Studying the alignment between cryptographic protocol specifications and their software implementations as a software-assurance research problem. + +**4. Is there anything about the composition of the dataset or the way it was collected and preprocessed/cleaned/labeled that might impact future uses?** + +- Pooled recall metrics on this benchmark can be misleading because per-issue difficulty is highly heterogeneous; we recommend reporting per-issue recall with bootstrap confidence intervals (see the accompanying paper, Appendix C). +- Coverage is concentrated on **inference-time soundness**; the dataset does not currently include artifacts for ZK proofs of *training*, FRI-based STARKs, or floating-point native ZK protocols. Generalization claims should be scoped accordingly. +- The dataset is focused on **soundness and integrity** vulnerabilities. Privacy, availability, and governance-related gaps are not currently represented. +- The `zktorch` codebase is a directory snapshot without an upstream commit hash, which limits exact bit-level provenance for that pair. + +**5. Are there tasks for which the dataset should not be used?** + +The dataset **should not** be used to: +- Train or evaluate models intended to **automatically generate exploits against deployed ZK production systems** that have not consented to such testing. The artifacts in this dataset are tied to frozen academic snapshots, not live deployments. +- Make blanket security claims about the upstream framework projects without consulting the original authors. The benchmark deliberately freezes a snapshot in time; upstream projects continue to evolve and may have addressed any given soundness gap in subsequent releases. + +**6. Any other comments?** + +We encourage dataset users to publish per-issue recall tables (Appendix C of the accompanying paper) alongside aggregate metrics so that downstream comparisons remain unsound-when-pooled but transparent. + +--- + +## Distribution + +> *Dataset creators should provide answers to these questions prior to distributing the dataset either internally within the entity on behalf of which the dataset was created or externally to third parties.* + +**1. Will the dataset be distributed to third parties outside of the entity (e.g. company, institution, organization) on behalf of which the dataset was created?** + +Yes. The dataset is publicly distributed under CC-BY-4.0 (curation layer) for use by the broader research community. + +**2. How will the dataset be distributed (e.g. tarball on website, API, GitHub)? Does the dataset have a digital object identifier (DOI)?** + +- Primary distribution: the Hugging Face Hub at , accessible via the `datasets` Python library and via direct file download. +- Derived Parquet tables are configured under the `pairs` and `artifacts` configs (see README YAML frontmatter). +- A Croissant machine-readable metadata file is auto-generated by Hugging Face for HF-hosted datasets and can be validated via [the Croissant checker](https://huggingface.co/spaces/JoaquinVanschoren/croissant-checker), in line with the NeurIPS 2025/2026 D&B Track requirements. +- No DOI is registered as of v1.2.0; one may be minted at camera-ready (e.g., via Zenodo). + +**3. When will the dataset be distributed?** + +The dataset is already publicly available (v1.0.0 released 2026-04-22; v1.2.0 released 2026-04-28). + +**4. Will the dataset be distributed under a copyright or other intellectual property (IP) license, and/or under applicable terms of use (ToU)?** + +| Component | License | +|-----------|---------| +| Curation layer (artifact JSONs, schema, scripts, documentation, Parquet tables) | [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) | +| Codebase ZIPs | Each retains its **upstream license** (consult the LICENSE file inside each ZIP). The ZIPs are redistributed for research-reproducibility purposes. | +| Paper PDFs | Subject to **respective publisher terms** (ACM, USENIX, EuroSys, arXiv). PDFs are bundled for research-reproducibility purposes; consumers redistributing them at scale should consult the original publisher. | + +**5. Have any third parties imposed IP-based or other restrictions on the data associated with the instances?** + +The papers and codebases retain their original third-party licenses (the most restrictive of which limits redistribution to research use). The curation layer adds no new restrictions beyond CC-BY-4.0. Users redistributing modified codebases (e.g., test cases produced by `dataset_generator`) inherit the upstream license of the base codebase and must preserve the original `LICENSE` file. + +**6. Do any export controls or other regulatory restrictions apply to the dataset or to individual instances?** + +No export controls apply. The dataset contains research artifacts, not cryptographic key material or controlled software. + +**7. Any other comments?** + +Full author attribution will be added at camera-ready. Reviewers may access all data without personal request, in accordance with the NeurIPS D&B Track's accessibility requirements. + +--- + +## Maintenance + +> *These questions are intended to encourage dataset creators to plan for dataset maintenance and communicate this plan with dataset consumers.* + +**1. Who is supporting/hosting/maintaining the dataset?** + +The dataset is hosted on the Hugging Face Hub. Maintenance is performed by the original authors (anonymized for review). + +**2. How can the owner/curator/manager of the dataset be contacted (e.g. email address)?** + +During the NeurIPS 2026 review window, the recommended contact channel is the GitHub issue tracker on the dataset's source repository (linked from the Hugging Face dataset card). Direct email correspondence is intentionally withheld until camera-ready to preserve anonymous review. + +**3. Is there an erratum?** + +There is no separate erratum document. All corrections, schema changes, label re-classifications, and clean-codebase fixes are recorded in `CHANGELOG.md` at the repository root. + +**4. Will the dataset be updated (e.g. to correct labeling errors, add new instances, delete instances)?** + +Yes. Planned update categories: +- *Patch* updates (e.g., `v1.2.x`): label corrections, presence-probe fixes, documentation improvements. +- *Minor* updates (e.g., `v1.x.0`): new artifacts, new (paper, codebase) pairs, schema-compatible additions. +- *Major* updates (e.g., `v2.0.0`): schema bumps (a new `schema/artifact.vN.schema.json` is added side-by-side; old artifacts are migrated or kept under their original schema version). + +Updates will be communicated via Git tags and the `CHANGELOG.md` file. Users pinning to a specific version should reference the corresponding Git tag or the `revision` argument in `datasets.load_dataset(...)` and `huggingface_hub` downloads. + +**5. If the dataset relates to people, are there applicable limits on the retention of the data associated with the instances?** + +Not applicable — the dataset does not relate to people. + +**6. Will older versions of the dataset continue to be supported/hosted/maintained?** + +Older versions remain accessible via Git history and Hugging Face revisions. They are not actively patched after a newer version supersedes them; consumers should treat older versions as immutable historical snapshots. + +**7. If others want to extend/augment/build on/contribute to the dataset, is there a mechanism for them to do so?** + +Yes. See [CONTRIBUTING.md](CONTRIBUTING.md) for the full extension workflow: +1. Add a frozen codebase snapshot under `codebases/` and the corresponding paper PDF under `papers/`. +2. Author one or more JSON artifact records under `artifacts/{pair_id}/` conforming to `schema/artifact.v2.schema.json`, each with `presence_probes` validating injection success. +3. Regenerate the Parquet tables and `MANIFEST.json` via `python scripts/build_parquet.py` and validate via `python scripts/verify_dataset.py`. +4. Validate Croissant metadata via the linked HF checker. +5. Submit a pull request including a `CHANGELOG.md` entry. + +Contributions are validated by maintainer review against the JSON schema and by re-running `verify_dataset.py`. Accepted contributions are tagged in the next minor release and announced in `CHANGELOG.md`. + +**8. Any other comments?** + +This datasheet itself will be updated alongside major and minor dataset releases. Significant changes to the datasheet's content will be summarized in `CHANGELOG.md`. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0f98815405f64a593b099d5809c72b19a4714d3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Creative Commons Attribution 4.0 International License + +Copyright (c) 2026 Anonymous + +This dataset curation layer (artifact definitions, schemas, scripts, +and documentation) is licensed under the Creative Commons Attribution +4.0 International License. + +You may obtain a copy of the License at: +https://creativecommons.org/licenses/by/4.0/ + +The included codebases retain their original upstream licenses. +The included papers are subject to their respective publisher terms. diff --git a/MANIFEST.json b/MANIFEST.json new file mode 100644 index 0000000000000000000000000000000000000000..9d01bf44cd2ac34bde2448e2e824c217ae177ea7 --- /dev/null +++ b/MANIFEST.json @@ -0,0 +1,326 @@ +{ + "generated_by": "scripts/build_parquet.py", + "total_files": 64, + "files": [ + { + "path": "artifacts/zkgpt/zkGPT-001.json", + "sha256": "d43bd9a9250be8713ca385ecc72700155c95614e6030b912a644b5e22f9a2de7", + "size": 2377 + }, + { + "path": "artifacts/zkgpt/zkGPT-002.json", + "sha256": "1a136b9d5789ca0ab40dc069097e0f0793218ce4e037671c21ff0aba8bda72ce", + "size": 1911 + }, + { + "path": "artifacts/zkgpt/zkGPT-003.json", + "sha256": "3c45e388532ef68247dd0f1bea4a6a0aea5e8cfd7fe623762e4be8cd315d7f1d", + "size": 1818 + }, + { + "path": "artifacts/zkgpt/zkGPT-004.json", + "sha256": "198a900ac85c1504d81b269c30fb8239dd558d5dd5fe90effeef39205607cf75", + "size": 2163 + }, + { + "path": "artifacts/zkgpt/zkGPT-005.json", + "sha256": "1eb1b9eae9b97b79c41868f14c2f14303b6309df739789d5a70e5871c25dba71", + "size": 1970 + }, + { + "path": "artifacts/zkgpt/zkGPT-006.json", + "sha256": "9788706cda9bb05a67a3d829710ebe82a986ed9e2d85fb45be2f3d40678fce10", + "size": 2081 + }, + { + "path": "artifacts/zkgpt/zkGPT-007.json", + "sha256": "328c755f95b141ffc80978fcddbbe668bd755c39ec5f1db57a63c9101da2cc80", + "size": 1846 + }, + { + "path": "artifacts/zkgpt/zkGPT-008.json", + "sha256": "3e070cd5f6a45242214ec30e313992a83374d0bd6a2557af5b6e72e11d8729e6", + "size": 2076 + }, + { + "path": "artifacts/zkgpt/zkGPT-010.json", + "sha256": "4ed78a23cbd8392dcaf0d842a66e75cbe5bdefe92dddff564e384fa49b37f27c", + "size": 1738 + }, + { + "path": "artifacts/zkgpt/zkGPT-011.json", + "sha256": "fbc5e1116831835278971655c69b0cff62d3e653a51ae653d0ecca3f0a6c779f", + "size": 2009 + }, + { + "path": "artifacts/zkgpt/zkGPT-012.json", + "sha256": "7e676d9d6f771df690928d3824a25d671f8222750131738a289d04c5b68ebf7d", + "size": 2114 + }, + { + "path": "artifacts/zkgpt/zkGPT-013.json", + "sha256": "05bb0e40590233526f7f38e7a0711f3737e8eafc72b49d5e6806678008c704a9", + "size": 2096 + }, + { + "path": "artifacts/zkgpt/zkGPT-014.json", + "sha256": "3497370374ba97f0293837b693d118e3749f32025819add21e95f27ddf8a6744", + "size": 2245 + }, + { + "path": "artifacts/zkgpt/zkGPT-015.json", + "sha256": "b3b68a31e52929e52b0f9871255020106690b831c153ff5c89cc8099e7fea24c", + "size": 1879 + }, + { + "path": "artifacts/zkllm/zkLLM-001.json", + "sha256": "ea0806298ee4a573af3797a64ff1605788f2ed1819582e9a10e6ebc60f9155ad", + "size": 1790 + }, + { + "path": "artifacts/zkllm/zkLLM-002.json", + "sha256": "aa2e9106118ed05dde58a5abac5eeed626df15e524262355a1ed705ff3961ad5", + "size": 1654 + }, + { + "path": "artifacts/zkllm/zkLLM-003.json", + "sha256": "1f0beba261f02ada858940062a06f5e54b893d396f87142bbc10876b0d93e423", + "size": 1672 + }, + { + "path": "artifacts/zkllm/zkLLM-004.json", + "sha256": "71fca19dcbf5cb6856cc31386b8313685370ca0c47408f3881e3cb0d499f7070", + "size": 1762 + }, + { + "path": "artifacts/zkllm/zkLLM-005.json", + "sha256": "9fde15e0db8729e5344003ce2e552c2be4fe12218d8257198b77159a0a9756d6", + "size": 1588 + }, + { + "path": "artifacts/zkllm/zkLLM-006.json", + "sha256": "42be157c3f583b49102caa171e269b756c03e381c793ee39f2b7ad0a1980dcc9", + "size": 1965 + }, + { + "path": "artifacts/zkllm/zkLLM-007.json", + "sha256": "7e52355dadf8b85dc3785337dc8d4dcbaabed55d2221fdcfd3a9d868f6b343ee", + "size": 1599 + }, + { + "path": "artifacts/zkllm/zkLLM-008.json", + "sha256": "d9a9b898b6d9c2e5548cd20a06078af97051d252d7a28f3c158c2ac73834301a", + "size": 1776 + }, + { + "path": "artifacts/zkllm/zkLLM-011.json", + "sha256": "516048347f6405bdce6746fe292cc2d7405519a22d7ed95e29bc928f8c8e00f6", + "size": 1725 + }, + { + "path": "artifacts/zkllm/zkLLM-012.json", + "sha256": "36d371ecad36d7bac9d052ca44fd6fd28fb54147ce9d874b67ccc61d25457e98", + "size": 1933 + }, + { + "path": "artifacts/zkllm/zkLLM-013.json", + "sha256": "6c11cbc54c4e8e3c96aa565cbf7e9a4a13b948ad581ecedc4fe3b8dde42b1f2c", + "size": 2188 + }, + { + "path": "artifacts/zkllm/zkLLM-014.json", + "sha256": "10a5ce2028f31a4a1d561e2a770b821f1e08f18b077c5655450196e683bd6049", + "size": 2681 + }, + { + "path": "artifacts/zkllm/zkLLM-015.json", + "sha256": "2e90448309148efe738604e499b90b233f18be656084a269be92abb233239827", + "size": 2352 + }, + { + "path": "artifacts/zkml/zkML-001.json", + "sha256": "092696152b9141136bda956e494e0136f58082edfef2c750ad98ee6f963af007", + "size": 1628 + }, + { + "path": "artifacts/zkml/zkML-002.json", + "sha256": "3c66b05c2efd13e7b1263c39856b4953be27e54a66c740de8bb7fab0a25a6715", + "size": 1572 + }, + { + "path": "artifacts/zkml/zkML-003.json", + "sha256": "a446b3a09d5aba59e154bbe8d05dd48ef9b66d8b22f2f1883cdbebff76dc3c93", + "size": 2104 + }, + { + "path": "artifacts/zkml/zkML-004.json", + "sha256": "414dc525609f057f990170c4e13b990ac53bda9fbb90586252ec3961dcdefb65", + "size": 2097 + }, + { + "path": "artifacts/zkml/zkML-005.json", + "sha256": "10eedf495816597cb95d74aed88959bf32db3e7017c705397102ee231753fd48", + "size": 1807 + }, + { + "path": "artifacts/zkml/zkML-006.json", + "sha256": "c15cc00e82bde002ae161475b2e6b2e8c41daeb1d3fae516fbf3261a4e6cf06e", + "size": 1674 + }, + { + "path": "artifacts/zkml/zkML-007.json", + "sha256": "456567d9293758a85e0bad8e9dc1f864571cc9cd93cebf2a9edb9e139b02549c", + "size": 1613 + }, + { + "path": "artifacts/zkml/zkML-008.json", + "sha256": "d8cc31785873bb331a81f85c8566de939897bed3be293dc08709f319145d627b", + "size": 1831 + }, + { + "path": "artifacts/zkml/zkML-010.json", + "sha256": "f315e546c92cde6f1ae9e15c523877463c30fb26909a403e88da21b1c9b7ce0f", + "size": 2365 + }, + { + "path": "artifacts/zkml/zkML-011.json", + "sha256": "daf38ec12f4cdd9d256515237ec5cc2ea3b66d4e699b8066ebb254b9aa839198", + "size": 2303 + }, + { + "path": "artifacts/zkml/zkML-012.json", + "sha256": "a5ed1c56830489a8a7b2d51bed3caea3ba383e6bb4ee19c8361947a115b3d86c", + "size": 2655 + }, + { + "path": "artifacts/zkml/zkML-013.json", + "sha256": "65c7394c84f4eeee4e16b068a8e8b21b3df498db29cae08c7ed5ffdd1e554f22", + "size": 2490 + }, + { + "path": "artifacts/zkml/zkML-014.json", + "sha256": "1d6bfa0bfe823303f640245e69b60963f7396bc1e63763bb9453264476ec269d", + "size": 2432 + }, + { + "path": "artifacts/zkml/zkML-015.json", + "sha256": "0385b612341be2b77ac09f7cb05f63776e196e946b9ad86714969dd2e5a44305", + "size": 1947 + }, + { + "path": "artifacts/zktorch/zkTorch-001.json", + "sha256": "047283727b278ab955bf03b4dd11fd1190c8f6d767aebeb0c196dcff0b8bfb7a", + "size": 1696 + }, + { + "path": "artifacts/zktorch/zkTorch-002.json", + "sha256": "31b7811258b0ee1ccaedfc247f7ce67ecd6b0dd16f2695c584649dc65773a4ac", + "size": 1570 + }, + { + "path": "artifacts/zktorch/zkTorch-003.json", + "sha256": "20a39d6cef8fecfa72f36387f423b3a9f2350225f13cb18067527b658bd0bfae", + "size": 1890 + }, + { + "path": "artifacts/zktorch/zkTorch-004.json", + "sha256": "9aa23dd10ca8b43a3c341898f9d54e77c2f06c25d4b98c56506f96540c8940e0", + "size": 1884 + }, + { + "path": "artifacts/zktorch/zkTorch-005.json", + "sha256": "9fd0252e691156f658f49ed82852cf0d3033db7e1ebd8ae25bb4b3743dff70aa", + "size": 2082 + }, + { + "path": "artifacts/zktorch/zkTorch-006.json", + "sha256": "8f456653304f8700617b4cacaa2f0f96f4be6c65effdced15225674e5059b354", + "size": 1930 + }, + { + "path": "artifacts/zktorch/zkTorch-007.json", + "sha256": "6175a26abf5c1dba3c8f1733f22aa10a0186826dbbeb0e13d5ecbb3223913fd4", + "size": 2049 + }, + { + "path": "artifacts/zktorch/zkTorch-008.json", + "sha256": "97cdc9ed8240e70fc60b2de6e016c461b26723d17a9ce427bba9ee1383a38e7f", + "size": 2292 + }, + { + "path": "artifacts/zktorch/zkTorch-010.json", + "sha256": "faaa03638ef31b975facbbaf733d7a1793a34792d423e441ac48bfb0b2e90aba", + "size": 2337 + }, + { + "path": "artifacts/zktorch/zkTorch-011.json", + "sha256": "4c25d72ba20401938861a45f56775f3678c1c6afcf166bbf97e910f1d7d01389", + "size": 2131 + }, + { + "path": "artifacts/zktorch/zkTorch-012.json", + "sha256": "4d28ea9be1c107ea6b7d0e2028ee3597863cc223f8909173a1654e3085d746f2", + "size": 2234 + }, + { + "path": "artifacts/zktorch/zkTorch-013.json", + "sha256": "69509c0caca77614284bc84d95c51bd23e393e4af075ce85679db4eb479b5bc8", + "size": 2384 + }, + { + "path": "artifacts/zktorch/zkTorch-014.json", + "sha256": "368f0c68c17d0854960864abb49067cfc6485d0f164f9ea20b95b49aa3782434", + "size": 2206 + }, + { + "path": "artifacts/zktorch/zkTorch-015.json", + "sha256": "0094c74ebac46b7bb5050c8a4bf2b1c358d87138c3ea5198340ac0c3e19845b0", + "size": 2504 + }, + { + "path": "artifacts/zktorch/zkTorch-016.json", + "sha256": "7570df6ad7517beff21003050f7c6f454dd7384c5e901a53dfd8b9d3146c0942", + "size": 1800 + }, + { + "path": "codebases/zkgpt.zip", + "sha256": "7d5c4fbd8a4825054bcc8be46590bcdc8a201406735a72004b944fadd933198e", + "size": 674679 + }, + { + "path": "codebases/zkllm.zip", + "sha256": "e8979bdf169bd6125257b721c968cc4fffc1feb521656880a85c09cbad9cce78", + "size": 262872 + }, + { + "path": "codebases/zkml.zip", + "sha256": "d872d402c164bba79e99fa47aadea827268a1f5754c1c550efcbe70ee9c48c51", + "size": 27915998 + }, + { + "path": "codebases/zktorch.zip", + "sha256": "a7e8036d7598d80bdfa34da00bac0ba01e1f6e5f7e9437b021fd13925d2a0e26", + "size": 259897 + }, + { + "path": "papers/zkgpt.pdf", + "sha256": "2acc64d6b27eaed48cd4895aaec1b5cca8acc7473e7ff8015c041c98b9b35ff2", + "size": 561267 + }, + { + "path": "papers/zkllm.pdf", + "sha256": "39f2a2f29457072573574c21ca9da7e0bbca756bf7031dd877f3c366f1e2ad7d", + "size": 1116955 + }, + { + "path": "papers/zkml.pdf", + "sha256": "ac7b5e3fb44bafc445e0506cda8d4696ed2d8733bebe6d599897274d57740295", + "size": 973543 + }, + { + "path": "papers/zktorch.pdf", + "sha256": "2fa9225c84c7905fe21d41a25971cc515aaf23c24623cf11fa179232303b35f7", + "size": 860413 + } + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..759e79d6a0186875830accff818734f1e074d7f9 --- /dev/null +++ b/README.md @@ -0,0 +1,195 @@ +--- +license: cc-by-4.0 +language: + - en +task_categories: + - other +tags: + - zero-knowledge + - zkml + - benchmarking + - soundness + - cryptography + - auditing + - security +configs: + - config_name: pairs + data_files: data/pairs.parquet + - config_name: artifacts + data_files: data/artifacts.parquet +size_categories: + - n<1K +--- + +# zkml-audit-benchmark + +A benchmark dataset for evaluating AI agents on **zkML soundness auditing**: finding cryptographic vulnerabilities in zero-knowledge machine learning proof implementations. + +## Overview + +This dataset pairs **4 published zkML research papers** with their corresponding **frozen codebase snapshots** and **56 bug artifacts (20 real-world from expert audits + 36 synthetic for broader coverage)**. Each artifact describes a single soundness vulnerability — the code edits to inject it, ground-truth labels for scoring, and presence probes for post-injection validation + +The benchmark supports two complementary workflows: + +1. **Pair extraction** — load a (paper, codebase) pair for an agent to audit. +2. **Test-case generation** — sample artifacts and apply their edit logic to the clean codebase, producing flawed codebases with known ground-truth findings. + +## Documentation + +- [DATASHEET.md](DATASHEET.md) — datasheet for this dataset, following Gebru et al. 2021. +- [CONTRIBUTING.md](CONTRIBUTING.md) — how to add new (paper, codebase) pairs and bug artifacts. +- [CHANGELOG.md](CHANGELOG.md) — release history and label/codebase corrections. +- [schema/artifact.v2.schema.json](schema/artifact.v2.schema.json) — authoritative JSON schema for bug artifacts. + +## Positioning vs. Existing Security Benchmarks + +Several mature benchmarks evaluate code-security tooling, but none target the **theory-to-implementation gap** that defines zkML soundness. The table below contrasts the design axes that matter for this setting: domain coverage, the granularity of the ground-truth labels, and whether artifacts are paired with the academic claims they implement. + +| Benchmark | Domain | Artifact granularity | Theory-paired | ZKP-aware | +|-----------|--------|----------------------|:-------------:|:---------:| +| [Juliet test suite](https://samate.nist.gov/SARD/test-suites) | General C/C++/Java security | CWE-class injections | no | no | +| [OWASP Benchmark](https://owasp.org/www-project-benchmark/) | Web/Java security | OWASP-class injections | no | no | +| [NIST CAVP](https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program) | Standardized crypto implementations | Test-vector validation | no | partial | +| **`zkml-audit-benchmark` (this dataset)** | **zkML soundness** | **Per-claim soundness gap** | **yes** | **yes** | + +Juliet ships tens of thousands of injected vulnerabilities for general-purpose code, but its labels are generic CWE classes rather than per-paper soundness claims. The OWASP Benchmark is web-application focused, and the NIST Cryptographic Algorithm Validation Program validates implementations of *standardized* primitives, not bespoke proof-system protocols. By contrast, this benchmark ships paper–codebase pairs together with declarative artifact specifications that re-introduce a precisely characterized soundness gap, making it directly suitable for studying theory-to-practice alignment in zkML. + +## Dataset Structure + +### Configs + +| Config | Rows | Description | +|--------|------|-------------| +| `pairs` | 4 | One row per (paper, codebase) pair | +| `artifacts` | 56 | One row per bug artifact (flattened metadata) | + +### Loading + +```python +from datasets import load_dataset + +pairs = load_dataset("anonymous-zkml-benchmark/zkml-audit-benchmark", "pairs") +artifacts = load_dataset("anonymous-zkml-benchmark/zkml-audit-benchmark", "artifacts") +``` + +### Raw Files + +Beyond the Parquet tables, the repository includes: + +- `papers/{pair_id}.pdf` — research paper PDFs +- `codebases/{pair_id}.zip` — frozen codebase snapshots (Git LFS) +- `artifacts/{pair_id}/*.json` — full artifact JSONs with edit instructions, conflict metadata, and presence probes +- `schema/artifact.v2.schema.json` — JSON Schema defining the artifact format + +The Parquet tables contain flattened metadata for filtering and loading. The full artifact JSONs (with heterogeneous edit/probe structures) are the authoritative source for test-case generation. + +## Data Fields + +### `pairs` config + +| Field | Type | Description | +|-------|------|-------------| +| `pair_id` | string | Primary key: `zkllm`, `zkml`, `zktorch`, `zkgpt` | +| `paper_title` | string | Full paper title | +| `paper_venue` | string | Publication venue | +| `paper_year` | int32 | Publication year | +| `paper_license` | string | Paper redistribution terms | +| `paper_url` | string | arXiv or publisher URL (empty if unavailable) | +| `paper_path` | string | Relative path to PDF: `papers/{pair_id}.pdf` | +| `paper_sha256` | string | SHA256 hash of the PDF | +| `codebase_path` | string | Relative path to zip: `codebases/{pair_id}.zip` | +| `codebase_dir` | string | Directory name after extraction | +| `codebase_sha256` | string | SHA256 hash of the zip | +| `codebase_language` | string | Primary implementation language | +| `codebase_frameworks` | list\ | Key cryptographic frameworks used | +| `codebase_snapshot_note` | string | Commit hash or snapshot date | +| `artifact_count` | int32 | Number of artifacts targeting this pair | +| `notes` | string | Caveats or special build instructions | + +### `artifacts` config + +| Field | Type | Description | +|-------|------|-------------| +| `artifact_id` | string | Primary key, e.g. `zkLLM-001` | +| `pair_id` | string | Foreign key → `pairs` | +| `source` | string | `real` (from audit) or `synthetic` (authored for coverage) | +| `finding_name` | string | Short vulnerability title (3–7 words) | +| `finding_explanation` | string | One paragraph: root cause and impact | +| `relevant_code` | string | Comma-separated `file:line[-line]` references | +| `paper_reference` | string | Section/theorem/protocol citation with optional quote | +| `edit_count` | int32 | Number of code edits to inject this bug | +| `files_touched` | list\ | Files modified by this artifact's edits | +| `semantic_tags` | list\ | Semantic labels for conflict detection | +| `requires` | list\ | Artifact IDs this depends on | +| `incompatible` | list\ | Artifact IDs incompatible with this one | +| `artifact_path` | string | Relative path to full artifact JSON | +| `artifact_sha256` | string | SHA256 hash of the artifact JSON | + +## Pair Inventory + +| pair_id | Paper | Venue | Language | Artifacts | Snapshot | +|---------|-------|-------|----------|-----------|----------| +| `zkllm` | zkLLM: Zero Knowledge Proofs for Large Language Models | ACM CCS 2024 | CUDA/C++ | 13 | commit `993311e…` | +| `zkml` | ZKML: An Optimizing System for ML Inference in Zero-Knowledge Proofs | EuroSys 2024 | Rust | 14 | commit `4378958…` ([ddkang/zkml](https://github.com/ddkang/zkml)) | +| `zktorch` | ZKTorch: Compiling ML Inference to Zero-Knowledge Proofs via Parallel Proof Accumulation | arXiv | Rust | 15 | directory snapshot 2026-04-19 | +| `zkgpt` | zkGPT: An Efficient Non-interactive Zero-knowledge Proof Framework for LLM Inference | USENIX Security 2025 | C++ | 14 | Zenodo record [14727819 v1](https://zenodo.org/records/14727819) | + +## Artifact Summary + +- **Total artifacts:** 56 (14 zkGPT + 13 zkLLM + 14 zkML + 15 zkTorch) +- **Source breakdown:** 20 real (derived from expert audit reports), 36 synthetic (authored for broader coverage) +- Each artifact includes declarative code edits, conflict metadata for safe composition, and presence probes for post-injection validation + +## Reproducibility + +All files are checksummed in `MANIFEST.json`. To verify integrity: + +```bash +python scripts/verify_dataset.py +``` + +To rebuild the Parquet tables from the in-repo artifact JSONs: + +```bash +python scripts/build_parquet.py +``` + +## Known Limitations & Assumptions + +1. **Paper ↔ codebase mapping** uses fixed pair IDs (`zkllm`, `zkml`, `zktorch`, `zkgpt`) defined in `scripts/build_parquet.py`. + +2. **Non-git snapshots:** The `zktorch` codebase is a directory snapshot dated 2026-04-19 and cannot be pinned to an upstream commit. `zkllm` and `zkml` are pinned to Git commits (`993311ea…` and `4378958…` respectively). `zkgpt` is pinned to Zenodo record [14727819 v1](https://zenodo.org/records/14727819). + +3. **Paper licensing:** PDFs are included for research reproducibility. The dataset-level CC-BY-4.0 license covers only the curation layer (artifact definitions, schema, scripts). Papers carry their respective publisher terms (ACM, arXiv). Users redistribute at their own responsibility. + +4. **Artifact format:** Artifacts follow `schema/artifact.v2.schema.json`. All graded labels live under `finding.labels`. + +5. **Scope:** This release covers 4 of the 10 available research papers — specifically those with paired frozen codebases and authored artifacts. Remaining papers may be added in future releases. + +## Schema Reference + +The artifact JSON format is defined by `schema/artifact.v2.schema.json`. Key structures: + +- `finding.labels` — the two graded fields (`relevant_code`, `paper_reference`) +- `edits` — ordered list of code edits to inject the bug +- `conflict_keys` — files, regions, and semantic tags for safe composition +- `presence_probes` — assertions to verify successful injection + +## Citation + +If you use this dataset, please cite: + +```bibtex +@misc{zkml-audit-benchmark, + title={zkml-audit-benchmark: A Benchmark for AI Agents on zkML Soundness Auditing}, + author={Anonymous}, + year={2026}, + url={https://huggingface.co/datasets/anonymous-zkml-benchmark/zkml-audit-benchmark}, +} +``` + +## License + +- **Dataset curation layer** (artifacts, schema, scripts, documentation): [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) +- **Codebases:** retain their original upstream licenses (see each codebase's LICENSE file inside the zip) +- **Papers:** subject to respective publisher terms diff --git a/artifacts/zkgpt/zkGPT-001.json b/artifacts/zkgpt/zkGPT-001.json new file mode 100644 index 0000000000000000000000000000000000000000..122b3526b24a6f537386caa5b3f4b6a3464ae442 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-001.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-001", + "codebase": "zkTransformer-main-fixed", + "source": "real", + "finding": { + "name": "Hyrax Commitment Before LogUp Witness Appended", + "explanation": "The fixed code appends the LogUp lookup witness to val[0] before invoking pr.commitInput, so the Hyrax commitment binds the full witness including lookup entries. After injection, commitInput runs before append_to_witness, so the commitment covers only the pre-LogUp witness. A malicious prover can then substitute arbitrary lookup entries without the verifier detecting the mismatch, because nothing was committed to them.", + "labels": { + "relevant_code": "src/neuralNetwork.cpp:375", + "paper_reference": "Protocol 1 Step (1): P commits to aux and L before V derives challenges. All witness material (including lookup auxiliary values) must be bound by the commitment before the verifier proceeds." + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 375, + "end": 389, + "expect_sha256": "034f020e6babd04472b48c8b35b62db8261352d2a5872c31a5491e9338d0b187" + }, + "new_content": "\n initLayer(pr.C.circuit[0], total_in_size, layerType::INPUT);\n assert(total_in_size == pr.val[0].size());\n\n timer T;\n int logn = pr.C.circuit[0].bit_length;\n u64 n_sqrt = 1ULL << (logn - (logn >> 1));\n pr.gens.resize(n_sqrt);\n G1 base=gen_gi(pr.gens.data(),n_sqrt);\n pr.gens.push_back(base);\n T.start();\n pr.commitInput(pr.gens,32);\n pr.lookup.append_to_witness(pr.val[0], total_in_size, table);" + } + ], + "conflict_keys": { + "files": [ + "src/neuralNetwork.cpp" + ], + "regions": [ + { + "file": "src/neuralNetwork.cpp", + "start": 373, + "end": 395 + } + ], + "semantic_tags": [ + "commit_logup_ordering" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/neuralNetwork.cpp", + "text": "pr.commitInput(pr.gens,32);\n pr.lookup.append_to_witness" + }, + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "append_to_witness(pr.val[0], total_in_size, table);\n\n initLayer" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-002.json b/artifacts/zkgpt/zkGPT-002.json new file mode 100644 index 0000000000000000000000000000000000000000..b8d033114ca70badbdca35f35a4613eed9d31532 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-002.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-002", + "codebase": "zkTransformer-main-fixed", + "source": "real", + "finding": { + "name": "Lasso Sum Verification Assert Removed", + "explanation": "The Lasso/GKR sumcheck verification at verifier.cpp:826-827 checks that previousSum == g0 + g1 via a C++ assert() every round i != n. The injection deletes this if/assert pair entirely, so no per-round sumcheck check runs. Even when compiled with NDEBUG the original assert would be a no-op, but deleting the lines also removes any conditional side-effect and makes the intent clear: the Lasso lookup protocol's range-check sumcheck is no longer verified at all.", + "labels": { + "relevant_code": "src/verifier.cpp:826", + "paper_reference": "Section 2.3 (Lasso lookup protocol for range and exponentiation relations); Section 4.3 leveraging Lasso for non-arithmetic relations; Protocol 1 Step (3) Lasso invoked on range-check and exponentiation tables." + } + }, + "edits": [ + { + "file": "src/verifier.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 826, + "end": 827, + "expect_sha256": "6bbe4e5161e3741fe00aae55136a7092cfc9fc05c4c94b195b7dfbdb224c1956" + }, + "new_content": " // sumcheck assert removed" + } + ], + "conflict_keys": { + "files": [ + "src/verifier.cpp" + ], + "regions": [ + { + "file": "src/verifier.cpp", + "start": 823, + "end": 830 + } + ], + "semantic_tags": [ + "lasso_sum_verification" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/verifier.cpp", + "text": "sumcheck assert removed" + }, + { + "kind": "not_contains", + "file": "src/verifier.cpp", + "text": "assert(previousSum==g0+g1)" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-003.json b/artifacts/zkgpt/zkGPT-003.json new file mode 100644 index 0000000000000000000000000000000000000000..3b5bd17c82c92be5ad2c1593187fe1bdebf77be7 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-003.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-003", + "codebase": "zkTransformer-main-fixed", + "source": "real", + "finding": { + "name": "FC Layer Bias Addition Removed", + "explanation": "The fully-connected layer initializes val[layer_id][g] with the bias val[0][first_bias_id + co] and registers a uni_gate enforcing that equality before the matmul inner loop. The injection replaces both lines with val[layer_id][g]=0 and removes the uni_gate emplace. The circuit then proves Wx (no bias) instead of Wx+b for every FC layer, producing incorrect outputs for any GPT-2 sublayer that uses biases (which every linear layer does).", + "labels": { + "relevant_code": "src/neuralNetwork.cpp:1428", + "paper_reference": "Section 4 (Gadget composition); F-7 of Batch-Reports/v0.10/zkgpt_report.md." + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 1428, + "end": 1429, + "expect_sha256": "9facf640e452e13cad753856baf6b0a8757722b380709169a54eec9caa7d7d55" + }, + "new_content": " val[layer_id][g]=0;" + } + ], + "conflict_keys": { + "files": [ + "src/neuralNetwork.cpp" + ], + "regions": [ + { + "file": "src/neuralNetwork.cpp", + "start": 1425, + "end": 1435 + } + ], + "semantic_tags": [ + "fc_bias_gate" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "uni_gates.emplace_back(g, first_bias_id + co, 0, 1)" + }, + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "val[layer_id][g]=val[0][first_bias_id + co]" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-004.json b/artifacts/zkgpt/zkGPT-004.json new file mode 100644 index 0000000000000000000000000000000000000000..eb4d43292b94a2db315c6949ebfbb4f4a15246e4 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-004.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-004", + "codebase": "zkTransformer-main-fixed", + "source": "real", + "finding": { + "name": "LayerNorm Gamma and Beta Collapsed to Identity", + "explanation": "The fixed code seeds gamma with 1 + (i%3) and beta with (i%33)-16 so the committed LayerNorm parameters are non-trivial and bound by the subsequent addRangeBatch calls. The injection replaces both loops with gamma=1 and beta=0 across all channels, turning every LayerNorm into an identity transform. The values are still committed, but they no longer correspond to any trained model — the proof attests to a network whose normalization layers do nothing. Matches F-2 of zkgpt_report.md (LayerNorm parameters hardcoded, not loaded from model).", + "labels": { + "relevant_code": "src/neuralNetwork.cpp:452", + "paper_reference": "Section 4.1 (Normalization constraints): y_ij = gamma_j * (x_ij - mu_i)/sigma_i + beta_j; collapsing gamma to 1 and beta to 0 makes the normalization a pure pass-through after the mean/var subtraction." + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 452, + "end": 455, + "expect_sha256": "a710b2a2c250716c0769d212b33c7ef8fef7c84302c080a2ea9b27534aab6118" + }, + "new_content": " for(int i=0;i= m.size()) {\n idx = 0;\n }" + } + ], + "conflict_keys": { + "files": [ + "src/logup.cpp" + ], + "regions": [ + { + "file": "src/logup.cpp", + "start": 69, + "end": 81 + } + ], + "semantic_tags": [ + "logup_counter_bounds" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/logup.cpp", + "text": "idx = 0;\n }" + }, + { + "kind": "not_contains", + "file": "src/logup.cpp", + "text": "WARNING: query out of range" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-007.json b/artifacts/zkgpt/zkGPT-007.json new file mode 100644 index 0000000000000000000000000000000000000000..336c39f63f7728091111f695aea6c94aef6c4867 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-007.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-007", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "Verifier Prove Function Short-Circuits To True", + "explanation": "verifier::prove is the top-level verification driver — it invokes verifyGKR, verifyLasso, and verifyLookups and ANDs the three results into a final accept/reject. The injection replaces the local `bool ok = true;` at line 192 with `return true;`, so the function returns success before any sub-verifier runs. All GKR, Lasso, and LogUp checks become dead code; every proof is accepted, regardless of validity.", + "labels": { + "relevant_code": "src/verifier.cpp:192", + "paper_reference": "Protocol 1 Step (3-5): the verifier must execute all sumcheck, GKR, and Lasso subprotocols before accepting. Skipping them is a stub.empty_verify per taxonomy." + } + }, + "edits": [ + { + "file": "src/verifier.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 192, + "end": 192, + "expect_sha256": "500e48d45e38f8ee5c87b193fc7278bd0f259825d21cbfda8f2d6a2d7302ba9b" + }, + "new_content": " return true; // verification short-circuited" + } + ], + "conflict_keys": { + "files": [ + "src/verifier.cpp" + ], + "regions": [ + { + "file": "src/verifier.cpp", + "start": 188, + "end": 200 + } + ], + "semantic_tags": [ + "verifier_prove_entry" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/verifier.cpp", + "text": "return true; // verification short-circuited" + }, + { + "kind": "not_contains", + "file": "src/verifier.cpp", + "text": "bool ok = true;" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-008.json b/artifacts/zkgpt/zkGPT-008.json new file mode 100644 index 0000000000000000000000000000000000000000..61f7c52dbc37be0e339e11d9073649dd27c69093 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-008.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-008", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "LogUp Challenges Hardcoded To Fixed Values", + "explanation": "The LogUp grand-product argument draws two challenges per table: gamma (for the random-linear combination of tuple components) and alpha (for the rational-sum reduction). In the fixed code these are sampled via setByCSPRNG() — already a weakness (local PRNG, not transcript-bound), but at least unpredictable. The injection replaces both calls with Fr(42) and Fr(7), so the challenges are constants known in advance. A malicious prover can pre-compute a forgery that satisfies the LogUp identity for those specific challenge values without ever satisfying the underlying table membership.", + "labels": { + "relevant_code": "src/logup.cpp:167", + "paper_reference": "Section 3 (Technical Overview): Fiat-Shamir transformation requires challenges to be derived from a transcript that commits to all prior prover messages; hardcoded challenges allow adaptive forgery." + } + }, + "edits": [ + { + "file": "src/logup.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 167, + "end": 168, + "expect_sha256": "1b4dd4f0696122ea6e2efc1d70df106e60f7ecdee463bb8938bbe41b8e0fd516" + }, + "new_content": " gamma = Fr(42);\n alpha = Fr(7);" + } + ], + "conflict_keys": { + "files": [ + "src/logup.cpp" + ], + "regions": [ + { + "file": "src/logup.cpp", + "start": 164, + "end": 173 + } + ], + "semantic_tags": [ + "logup_challenge_derivation" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/logup.cpp", + "text": "gamma = Fr(42);\n alpha = Fr(7);" + }, + { + "kind": "not_contains", + "file": "src/logup.cpp", + "text": "gamma.setByCSPRNG();\n alpha.setByCSPRNG();" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-010.json b/artifacts/zkgpt/zkGPT-010.json new file mode 100644 index 0000000000000000000000000000000000000000..3d3aa09bd168ac6dc608452234716598d571dc1f --- /dev/null +++ b/artifacts/zkgpt/zkGPT-010.json @@ -0,0 +1,50 @@ +{ + "artifact_id": "zkGPT-010", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "GKR Layer Challenge Set To Constant", + "explanation": "Inside the GKR per-layer loop, the verifier samples a challenge vector r_u[i][j] via setByCSPRNG() for j in [0, m) and then copies r_v[i][j] = r_u[i][j]. The injection replaces the .setByCSPRNG() call on line 524 with an assignment to Fr(1), so every fresh GKR layer challenge is the constant 1 (and r_v copies it, so it is also 1). The Schwartz-Zippel binding between consecutive GKR layers now evaluates polynomials at a single known point rather than a random one, collapsing the per-layer soundness error.", + "labels": { + "paper_reference": "Section 4.2 (GKR per-layer sumcheck): the evaluation point for the next layer must be random to invoke Schwartz-Zippel.", + "relevant_code": "src/verifier.cpp:524" + } + }, + "edits": [ + { + "file": "src/verifier.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 524, + "end": 524, + "expect_sha256": "34aeb35c2554b38d0c2d8d8d649ddf6b481c6fcecaf07a3103f0c369280d09e1" + }, + "new_content": " r_u[i][j] = Fr(1);" + } + ], + "conflict_keys": { + "files": [ + "src/verifier.cpp" + ], + "regions": [ + { + "file": "src/verifier.cpp", + "start": 522, + "end": 526 + } + ], + "semantic_tags": [ + "gkr_layer_challenges" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/verifier.cpp", + "text": "r_u[i][j] = Fr(1);" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-011.json b/artifacts/zkgpt/zkGPT-011.json new file mode 100644 index 0000000000000000000000000000000000000000..db7c57be8d69c8b5a4bf05e30a98fcafbd420f91 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-011.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-011", + "codebase": "zkTransformer-main-fixed", + "source": "real", + "finding": { + "name": "Prover Vres Returns Zero Instead Of Output Evaluation", + "explanation": "Vres is the prover's evaluation of the final output polynomial at a verifier-sampled random point; its result seeds previousSum for the final GKR sumcheck. The injection replaces `F res = output[0];` with `F res = F_ZERO;`, so Vres always returns 0 regardless of the committed output. Combined with zkGPT's pre-existing design flaw (output is never pinned as a public instance value — F-3 of zkgpt_report.md), this lets a malicious prover declare any prediction while the verifier's sumcheck starts from a fabricated claim. The forgery is structurally unreachable by legitimate use: the verifier has no independent way to check what the model actually predicted.", + "labels": { + "relevant_code": "src/prover.cpp:562", + "paper_reference": "F-3 of Batch-Reports/v0.10/zkgpt_report.md (Output Not Exposed); Protocol 1 Step (5): verifier must independently provide or check y." + } + }, + "edits": [ + { + "file": "src/prover.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 562, + "end": 562, + "expect_sha256": "b636ffd0311161e5ef0b85698e03e0dcf0ccf6fbe620e42b8981913c5d318595" + }, + "new_content": " F res = F_ZERO;" + } + ], + "conflict_keys": { + "files": [ + "src/prover.cpp" + ], + "regions": [ + { + "file": "src/prover.cpp", + "start": 560, + "end": 566 + } + ], + "semantic_tags": [ + "vres_output_evaluation" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/prover.cpp", + "text": "F res = F_ZERO;" + }, + { + "kind": "not_contains", + "file": "src/prover.cpp", + "text": "F res = output[0];" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-012.json b/artifacts/zkgpt/zkGPT-012.json new file mode 100644 index 0000000000000000000000000000000000000000..c6c4e45265f405a782368d0d0a1bf629351e40c9 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-012.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-012", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "Range Batch Registration Silently Dropped", + "explanation": "addRangeBatch is the entry point every layer uses to register range-check LookupQueries against the global LogUp queries_ vector (callers include LayerNorm gamma/beta, FC weights, attention scales, softmax normalization — 11 call sites across neuralNetwork.cpp). The injection replaces the reserve + push_back loop with a no-op, so addRangeBatch returns without recording any queries. The verifier's grand-product check then passes trivially (zero queries, zero multiplicities) while the prover freely uses values outside their declared bit-width — field-wraparound and accumulation-overflow forgeries become available across every gadget that relies on range_check.", + "labels": { + "relevant_code": "src/logup.cpp:42", + "paper_reference": "Section 2.3 (Lasso/LogUp range checks); any commit to a witness that claims bit-width B requires a range-check lookup against [0, 2^B)." + } + }, + "edits": [ + { + "file": "src/logup.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 42, + "end": 45, + "expect_sha256": "6fb88935eba8248e397c06a6452966662464821caaedda82fc24a2f20039f97e" + }, + "new_content": " (void)value_offset; (void)count; (void)t; // range-batch registration dropped" + } + ], + "conflict_keys": { + "files": [ + "src/logup.cpp" + ], + "regions": [ + { + "file": "src/logup.cpp", + "start": 40, + "end": 46 + } + ], + "semantic_tags": [ + "range_batch_registration" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/logup.cpp", + "text": "range-batch registration dropped" + }, + { + "kind": "not_contains", + "file": "src/logup.cpp", + "text": "queries_.push_back(LookupQuery{ t, value_offset + i" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-013.json b/artifacts/zkgpt/zkGPT-013.json new file mode 100644 index 0000000000000000000000000000000000000000..662bde660859c5d2888fa4fa69d390e382507bae --- /dev/null +++ b/artifacts/zkgpt/zkGPT-013.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-013", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "Softmax Exp Table Lookup Query Removed", + "explanation": "Softmax is implemented via an approximate exp lookup: the prover computes tj = round(c1 * 2^(e1+eprime+1) * (pmax-pj) / 2^(eprime+1)) and reads E_off = table[tj]. The addExpTableQuery call registers a LogUp query asserting that (tj, table[tj]) is a valid row of the committed exp table. The injection deletes this call, so E_off becomes a free witness: the prover can assign any value to val[0][E_off] without the LogUp argument noticing. Every softmax denominator sum and attention weight computed downstream is now prover-chosen.", + "labels": { + "relevant_code": "src/neuralNetwork.cpp:1229", + "paper_reference": "Section 4.2 (Softmax via exp approximation): the (input, output) pair must be validated against the committed table to bind the approximation; F-1 of Batch-Reports/v0.10/zkgpt_report.md flags the broader Lasso-incomplete pattern." + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 1229, + "end": 1230, + "expect_sha256": "4166a0e768371706e28a253e682122537a5b69d8a1c7b9f56e8fba56c249cf6c" + }, + "new_content": " // exp-table lookup query dropped" + } + ], + "conflict_keys": { + "files": [ + "src/neuralNetwork.cpp" + ], + "regions": [ + { + "file": "src/neuralNetwork.cpp", + "start": 1226, + "end": 1235 + } + ], + "semantic_tags": [ + "softmax_exp_lookup" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/neuralNetwork.cpp", + "text": "exp-table lookup query dropped" + }, + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "lookup.addExpTableQuery(\n (std::size_t)t_off" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-014.json b/artifacts/zkgpt/zkGPT-014.json new file mode 100644 index 0000000000000000000000000000000000000000..389b0b31e3252fb9410a2f4e2055a4acfc9f62d0 --- /dev/null +++ b/artifacts/zkgpt/zkGPT-014.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-014", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "Softmax Scale Factor Evaluates to Unity", + "explanation": "The three softmax sub-layers pass pow(1,-8) as the exponential scale parameter. Because 1 raised to any power equals 1, the effective scale is 1.0 instead of the intended pow(2,-8) = 1/256. This inflates all softmax logits by a factor of 256 before the lookup table, pushing values entirely outside the table's representable range. The circuit silently accepts fabricated attention weights, allowing a malicious prover to commit to arbitrary softmax outputs that do not correspond to any correct computation.", + "labels": { + "paper_reference": "Section 4.1 (Softmax approximation): the exponential is evaluated via a lookup table indexed at scale 2^{-8}; substituting scale 1.0 renders the lookup domain incorrect.", + "relevant_code": "src/neuralNetwork.cpp:354-356" + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 354, + "end": 356, + "expect_sha256": "ffdb5c87ca9ba4b41622f3cfbe13cc86979cf575bab9b97e05b671161effb7f3" + }, + "new_content": " softmax_layer_1(pr.C.circuit[layer_id], layer_id,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(1,-8));\n softmax_layer_2(pr.C.circuit[layer_id], layer_id,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(1,-8));\n softmax_layer_3(pr.C.circuit[layer_id], layer_id,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(2,e_C)*c_C,pow(1,-8));" + } + ], + "conflict_keys": { + "files": [ + "src/neuralNetwork.cpp" + ], + "regions": [ + { + "file": "src/neuralNetwork.cpp", + "start": 352, + "end": 358 + } + ], + "semantic_tags": [ + "softmax_scale_factor" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/neuralNetwork.cpp", + "text": "pow(1,-8)" + }, + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "pow(2,-8)" + } + ] +} diff --git a/artifacts/zkgpt/zkGPT-015.json b/artifacts/zkgpt/zkGPT-015.json new file mode 100644 index 0000000000000000000000000000000000000000..d98f8c88e784069a13f4ea96b30cb43a264a91dd --- /dev/null +++ b/artifacts/zkgpt/zkGPT-015.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkGPT-015", + "codebase": "zkTransformer-main-fixed", + "source": "synthetic", + "finding": { + "name": "Attention Dimension Scaling Factor Removed", + "explanation": "The scaled dot-product attention formula is A = softmax(QK^T / sqrt(d))V. The injection replaces the computed 1/sqrt(d) divisor with a constant 1.0, removing dimension-dependent scaling. Without the sqrt(d) normalization, attention logits grow with hidden dimension, pushing softmax toward degenerate one-hot distributions. The quantized circuit accepts these inflated logits because the lookup table range is not tied to the scaling factor.", + "labels": { + "relevant_code": "src/neuralNetwork.cpp:1182", + "paper_reference": "Section 4.1 (Attention mechanism): A = softmax(QK^T / sqrt(d_k))V; the 1/sqrt(d_k) factor is essential for numerical stability and correct attention distribution." + } + }, + "edits": [ + { + "file": "src/neuralNetwork.cpp", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 1182, + "end": 1182, + "expect_sha256": "22a5acf14a47aec3462fd1b1a9dd6f749f102ac722ab7f83b7e1d4258dac3d96" + }, + "new_content": " const double inv_sqrt_d = 1.0;" + } + ], + "conflict_keys": { + "files": [ + "src/neuralNetwork.cpp" + ], + "regions": [ + { + "file": "src/neuralNetwork.cpp", + "start": 1179, + "end": 1186 + } + ], + "semantic_tags": [ + "attention_scaling_factor" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/neuralNetwork.cpp", + "text": "const double inv_sqrt_d = 1.0;" + }, + { + "kind": "not_contains", + "file": "src/neuralNetwork.cpp", + "text": "std::sqrt" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-001.json b/artifacts/zkllm/zkLLM-001.json new file mode 100644 index 0000000000000000000000000000000000000000..60836e73e8559d07b78f9e82b3c7be53efd9af35 --- /dev/null +++ b/artifacts/zkllm/zkLLM-001.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-001", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "ReLU Prove Body Throws Instead of Proving", + "explanation": "The zkReLU::prove() method throws std::runtime_error instead of executing the 5-step protocol (boolean sign check, Hadamard sumcheck, tLookup range proofs). Any pipeline that invokes ReLU produces no proof, leaving all ReLU outputs completely unconstrained.", + "labels": { + "relevant_code": "zkrelu.cu:58", + "paper_reference": "Example 4.2 (Section 4): ReLU with rescaling verified via two tlookup instances — \"By requiring the prover to demonstrate Z'+αA ⊂ TX+αTY... and R ⊂ TR, both using Protocol 1, in addition to proving the decomposition as Z = γZ'+R, we can sufficiently validate the correctness of inference through the ReLU function.\"" + } + }, + "edits": [ + { + "file": "zkrelu.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 58, + "end": 82, + "expect_sha256": "59b80b037696973457a1ea5fcda09e683971aa59cba45a67febc774dfc32da03" + }, + "new_content": "void zkReLU::prove(const FrTensor& Z, const FrTensor& A)\n{\n return;\n}" + } + ], + "conflict_keys": { + "files": [ + "zkrelu.cu" + ], + "regions": [ + { + "file": "zkrelu.cu", + "start": 53, + "end": 87 + } + ], + "semantic_tags": [ + "relu_prove_body" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "zkrelu.cu", + "text": "return;" + }, + { + "kind": "not_contains", + "file": "zkrelu.cu", + "text": "throw std::runtime_error" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-002.json b/artifacts/zkllm/zkLLM-002.json new file mode 100644 index 0000000000000000000000000000000000000000..212f3fa5290aa20b2cbd24e11779df44d5d0ab04 --- /dev/null +++ b/artifacts/zkllm/zkLLM-002.json @@ -0,0 +1,50 @@ +{ + "artifact_id": "zkLLM-002", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "Skip-Connection Linearity Check Removed", + "explanation": "The skip-connection prover's local linearity check (sum_xy == z_hat) is removed. The opening proofs at u are still computed and written to .proof, but the commit-time self-check that would catch a com_z ≠ commit(x+y) mismatch is gutted, so a dishonest prover who opens a forged com_z passes this stage locally.", + "labels": { + "relevant_code": "skip-connection.cu:151", + "paper_reference": "Section 3.3 / Section 6.2: all arithmetic tensor operations (including addition) are verified via the sumcheck protocol; Section 6.2 describes proof assembly covering the full computational graph" + } + }, + "edits": [ + { + "file": "skip-connection.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 151, + "end": 155, + "expect_sha256": "9b16892ccffeb8be6a8ad6f2db0ad7f0416b802a77d79a0b94c8db5405c62cf3" + }, + "new_content": " // (linearity verified via MLE evaluation)" + } + ], + "conflict_keys": { + "files": [ + "skip-connection.cu" + ], + "regions": [ + { + "file": "skip-connection.cu", + "start": 146, + "end": 160 + } + ], + "semantic_tags": [ + "skip_connection_linearity" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "skip-connection.cu", + "text": "linearity verified via MLE" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-003.json b/artifacts/zkllm/zkLLM-003.json new file mode 100644 index 0000000000000000000000000000000000000000..ad12954be82d97c835b5f944ae991c6eaf7f41ca --- /dev/null +++ b/artifacts/zkllm/zkLLM-003.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-003", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "RMSNorm Inverse Witness Not Absorbed into Transcript", + "explanation": "The RMSNorm inverse (1/sqrt(mean(x^2)+eps)) is computed in Python and loaded from rms_inv_temp.bin. The Fiat-Shamir absorb of the inverse witness is removed, so subsequent challenges are not bound to this witness. A malicious prover can substitute any normalization factor without affecting the transcript.", + "labels": { + "relevant_code": "rmsnorm.cu:48", + "paper_reference": "Section 6.1.3: \"The compound non-arithmetic operations of square-root and inverse are managed through two sequential tlookup steps.\"" + } + }, + "edits": [ + { + "file": "rmsnorm.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 48, + "end": 55, + "expect_sha256": "fa27931d76d9cbdd26068205796b450e7a961faa2cb07a193aaf4842e05b4603" + }, + "new_content": " // (witness absorbed during sumcheck phase)" + } + ], + "conflict_keys": { + "files": [ + "rmsnorm.cu" + ], + "regions": [ + { + "file": "rmsnorm.cu", + "start": 43, + "end": 60 + } + ], + "semantic_tags": [ + "rmsnorm_witness_absorb" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "rmsnorm.cu", + "text": "witness absorbed during sumcheck" + }, + { + "kind": "not_contains", + "file": "rmsnorm.cu", + "text": "rmsnorm/rms_inv_temp_witness" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-004.json b/artifacts/zkllm/zkLLM-004.json new file mode 100644 index 0000000000000000000000000000000000000000..747b21fe011bb73cacbd290d1a4c548ebba0a9a3 --- /dev/null +++ b/artifacts/zkllm/zkLLM-004.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-004", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "tLookup A/B Commitments Removed", + "explanation": "The tLookup protocol's intermediate values A (inverse of shifted S) and B (inverse of shifted table) are computed after beta is drawn but their commit_and_absorb calls are removed. Subsequent challenges for the grand-product check are not bound to A and B, allowing the prover to adaptively choose these inverses after seeing the challenge.", + "labels": { + "relevant_code": "tlookup.cu:401", + "paper_reference": "Protocol 1 (Lines 6–7): prover must commit ⟦S⟧ and ⟦m⟧ before verifier sends challenge β (Line 10); Protocol 2 (Line 22): all auxiliary commitments sent before interactive proof in zkAttn-Prove" + } + }, + "edits": [ + { + "file": "tlookup.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 401, + "end": 402, + "expect_sha256": "f98a557736ae50a3debe7cfd89ccf0cc66d84e33e873d47569d4da0fb4c3d061" + }, + "new_content": " // (A/B committed during grand-product phase)" + } + ], + "conflict_keys": { + "files": [ + "tlookup.cu" + ], + "regions": [ + { + "file": "tlookup.cu", + "start": 396, + "end": 407 + } + ], + "semantic_tags": [ + "tlookup_AB_commitment" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "tlookup.cu", + "text": "committed during grand-product" + }, + { + "kind": "not_contains", + "file": "tlookup.cu", + "text": "commit_and_absorb(\"tlookup/A\"" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-005.json b/artifacts/zkllm/zkLLM-005.json new file mode 100644 index 0000000000000000000000000000000000000000..7b8475c299e7286d61b74155f3a7bcd63b7c2ac2 --- /dev/null +++ b/artifacts/zkllm/zkLLM-005.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-005", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "Fiat-Shamir Transcript Replaced with Local PRNG", + "explanation": "The fs_challenge_vec() function is replaced with random_vec(), which uses a process-local std::mt19937 PRNG seeded from std::random_device. Challenges are no longer derived from the Fiat-Shamir transcript, making the proof interactive-only and allowing a malicious prover to predict or replay challenges.", + "labels": { + "relevant_code": "fr-tensor.cu:44", + "paper_reference": "-" + } + }, + "edits": [ + { + "file": "fr-tensor.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 44, + "end": 46, + "expect_sha256": "e8bdb60a0019d86cac80ffa9826692c0bbb4952862ee440411305fca6410ab39" + }, + "new_content": "vector fs_challenge_vec(const char* label, uint len) {\n return random_vec(len);\n}" + } + ], + "conflict_keys": { + "files": [ + "fr-tensor.cu" + ], + "regions": [ + { + "file": "fr-tensor.cu", + "start": 39, + "end": 51 + } + ], + "semantic_tags": [ + "fiat_shamir_challenge_dispatch" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "fr-tensor.cu", + "text": "return random_vec(len)" + }, + { + "kind": "not_contains", + "file": "fr-tensor.cu", + "text": "fs_transcript().challenge_vec" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-006.json b/artifacts/zkllm/zkLLM-006.json new file mode 100644 index 0000000000000000000000000000000000000000..c9ec9d13fe060a8218ac40a420c1ad89438992dd --- /dev/null +++ b/artifacts/zkllm/zkLLM-006.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-006", + "codebase": "zkllm-ccs2024-fixed", + "source": "synthetic", + "finding": { + "name": "Cross-Stage Commitment Chain Verification Removed", + "explanation": "The verify-pipeline chain check `if (!bytes_equal(prev.output_com, curr.input_com)) { ... ++chain_bad; continue; }` at main.cu:302-311 is removed. This is the only check that detects cross-stage commitment substitution: without it, every pair of adjacent stages is counted as chain_ok regardless of whether stage N's output commitment bytes actually match stage N+1's absorbed input commitment. An adversary can freely rewrite intermediate .bin files between stage executions and still pass verify-pipeline.", + "labels": { + "relevant_code": "main.cu:302", + "paper_reference": "Section 6.2: \"proofs are assembled in reverse logical order of the arithmetic circuits, methodically reducing the claimed multilinear extension values of the output y to those associated with the prompt X and the model parameters W.\"" + } + }, + "edits": [ + { + "file": "main.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 302, + "end": 311, + "expect_sha256": "05118c182ffc4f0e811378ee774f835c4a839e76aa0538d0c98ff8b3e91acd7f" + }, + "new_content": " // (chain check removed)" + } + ], + "conflict_keys": { + "files": [ + "main.cu" + ], + "regions": [ + { + "file": "main.cu", + "start": 297, + "end": 316 + } + ], + "semantic_tags": [ + "pipeline_commitment_chain" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "main.cu", + "text": "// (chain check removed)" + }, + { + "kind": "not_contains", + "file": "main.cu", + "text": "if (!bytes_equal(prev.output_com, curr.input_com))" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-007.json b/artifacts/zkllm/zkLLM-007.json new file mode 100644 index 0000000000000000000000000000000000000000..76ba15e85e8e9864e9487404522cecc2089d1108 --- /dev/null +++ b/artifacts/zkllm/zkLLM-007.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-007", + "codebase": "zkllm-ccs2024-fixed", + "source": "synthetic", + "finding": { + "name": "Stage Proof Transcript Digest Omitted", + "explanation": "The write_stage_proof function's final transcript digest write is removed. The .proof file no longer contains the 32-byte sealed digest that binds all absorbs and challenges. A verifier cannot confirm that the proof was generated from a consistent transcript, breaking the pipeline's integrity guarantee.", + "labels": { + "relevant_code": "stage_proof.cuh:215", + "paper_reference": "Section 6.2: proof assembly covering the full computational graph" + } + }, + "edits": [ + { + "file": "stage_proof.cuh", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 215, + "end": 216, + "expect_sha256": "5484e9c249ec9889280928dadffc0f4e38452060450d5a36b04ef16ea828fd99" + }, + "new_content": " // (finalized in pipeline verifier)" + } + ], + "conflict_keys": { + "files": [ + "stage_proof.cuh" + ], + "regions": [ + { + "file": "stage_proof.cuh", + "start": 210, + "end": 221 + } + ], + "semantic_tags": [ + "stage_proof_digest" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "stage_proof.cuh", + "text": "finalized in pipeline" + }, + { + "kind": "not_contains", + "file": "stage_proof.cuh", + "text": "fs_transcript().digest()" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-008.json b/artifacts/zkllm/zkLLM-008.json new file mode 100644 index 0000000000000000000000000000000000000000..60df0005b7e3c9deada555255287b6a855d99cbc --- /dev/null +++ b/artifacts/zkllm/zkLLM-008.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-008", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "Softmax Segment Count Reduced (K=3 to K=2)", + "explanation": "The zkSoftmax constructor call in self-attn.cu changes the segment base vector from {1<<8, 1<<20, 1<<20} (K=3) to {1<<8, 1<<20} (K=2), removing one piecewise segment. This invalidates the paper's Theorem 7.1 error-bound analysis and changes the approximation domain, producing a weaker softmax approximation with unbounded error in the removed range.", + "labels": { + "relevant_code": "self-attn.cu:146", + "paper_reference": "Section 8: \"we deployed K = 5 tlookups, each of size 2^16. This setup includes L = 3 least significant segments\"; Theorem 7.1 and Eq. (33): error bound depends on K−M−L" + } + }, + "edits": [ + { + "file": "self-attn.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 146, + "end": 146, + "expect_sha256": "61b7bba68af506014f957fb1a67176cb5ecce5502d89fecfed6365054cd9048e" + }, + "new_content": " zkSoftmax softmax({1<<8, 1<<20}, 1, 0, 1UL<<32, {1<<18}, seq_len, seq_len, d, 1);" + } + ], + "conflict_keys": { + "files": [ + "self-attn.cu" + ], + "regions": [ + { + "file": "self-attn.cu", + "start": 141, + "end": 151 + } + ], + "semantic_tags": [ + "softmax_segmentation" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "self-attn.cu", + "text": "{1<<8, 1<<20}" + }, + { + "kind": "not_contains", + "file": "self-attn.cu", + "text": "{1<<8, 1<<20, 1<<20}" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-011.json b/artifacts/zkllm/zkLLM-011.json new file mode 100644 index 0000000000000000000000000000000000000000..1949864316b2e00b6b86e14d79cdc33def5b3b78 --- /dev/null +++ b/artifacts/zkllm/zkLLM-011.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-011", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "Softmax Row-Sum Normalization Check Removed", + "explanation": "The softmax proof omits the row-sum normalization check that ensures each row of Y sums to approximately theta within tolerance E. Without this check the prover can output arbitrary softmax values whose rows do not sum to 1, proving a weaker relation than Theorem 7.1 requires.", + "labels": { + "relevant_code": "zksoftmax.cu:206", + "paper_reference": "Section 5.1 Step (4): \"an additional check is introduced to ensure the rowwise sums of Y equal 1\"; Protocol 2 (Lines 34–35): tlookup-Prove on ŷ against TR; Theorem 7.1 (3): \"εattn defines the tolerable error... the sum of each row must lie within [(1−εattn)θ, (1+εattn)θ]\"" + } + }, + "edits": [ + { + "file": "zksoftmax.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 206, + "end": 253, + "expect_sha256": "0a8b8b331e04604baf7982d96f46f52bbf4287f892ea2cd6d255a98a13a1f5c6" + }, + "new_content": "" + } + ], + "conflict_keys": { + "files": [ + "zksoftmax.cu" + ], + "regions": [ + { + "file": "zksoftmax.cu", + "start": 201, + "end": 258 + } + ], + "semantic_tags": [ + "softmax_row_sum_check" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "zksoftmax.cu", + "text": "row_sums" + }, + { + "kind": "not_contains", + "file": "zksoftmax.cu", + "text": "zksoftmax/row_sums" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-012.json b/artifacts/zkllm/zkLLM-012.json new file mode 100644 index 0000000000000000000000000000000000000000..25826173154eef13fefe7608189e3bb1889e99fc --- /dev/null +++ b/artifacts/zkllm/zkLLM-012.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkLLM-012", + "codebase": "zkllm-ccs2024-fixed", + "source": "real", + "finding": { + "name": "Lookup Table Values Not Committed", + "explanation": "The lookup table T is initialized deterministically but tLookupRange::commit_table is emptied, so the table is never Hyrax-committed and its commitment is never absorbed into the Fiat-Shamir transcript. tLookupRange is the base for tLookupRangeMapping (SwiGLU table in ffn.cu), the rescaling remainder table (rescaling.cu), and every zkSoftmax segment table (zksoftmax.cu), so the subsequent challenge β (Protocol 1 Line 10) is no longer bound to any of these tables — a malicious prover can choose tables adaptively after seeing β and construct a forged proof.", + "labels": { + "relevant_code": "tlookup.cu:36", + "paper_reference": "Protocol 1 Line 2: \"⟦T⟧ ← Commit(T; 0)\" — the paper requires the lookup table T to be committed via tlookup-Setup before use" + } + }, + "edits": [ + { + "file": "tlookup.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 36, + "end": 39, + "expect_sha256": "e5c2390990df7e02e7f0e2fe7df0a3da91bfb205889008c663ebc0c61e7c914e" + }, + "new_content": "void tLookupRange::commit_table(const Commitment& gen)\n{\n}" + } + ], + "conflict_keys": { + "files": [ + "tlookup.cu" + ], + "regions": [ + { + "file": "tlookup.cu", + "start": 31, + "end": 44 + } + ], + "semantic_tags": [ + "tlookup_table_commitment" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "tlookup.cu", + "text": "commit_and_absorb(\"tlookup/table\"" + }, + { + "kind": "contains", + "file": "tlookup.cu", + "text": "void tLookupRange::commit_table" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-013.json b/artifacts/zkllm/zkLLM-013.json new file mode 100644 index 0000000000000000000000000000000000000000..87d28e17959f690208b3d3490a9af46c316ff582 --- /dev/null +++ b/artifacts/zkllm/zkLLM-013.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkLLM-013", + "codebase": "zkllm-ccs2024-fixed", + "source": "synthetic", + "finding": { + "name": "Skip-Connection Verifier Body Replaced with return true", + "explanation": "verify_skip in main.cu is the entry point for the 'main verify-skip' command. Lines 138-204 contain the Pedersen commitment recomputation, opening checks (for com_x, com_y, com_z), and the MLE-linearity check z_hat == x_hat + y_hat. Replacing that entire block with 'return true;' turns the command into a trivial accept: any well-formed SkipProof file is declared valid regardless of what com_x, com_y, com_z commit to, whether the openings are correct, or whether the skip-connection linearity relation z = x + y holds. A malicious prover can commit an arbitrary z, supply any opening scalars, and the verifier will accept.", + "labels": { + "relevant_code": "main.cu:138", + "paper_reference": "Section 4 (skip-connection / residual protocol): verifier checks three Pedersen openings at a Fiat-Shamir point u and then the MLE linearity z_hat = x_hat + y_hat; the combination reduces the vector equation z = x + y to a single-scalar Schwartz-Zippel argument." + } + }, + "edits": [ + { + "file": "main.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 138, + "end": 204, + "expect_sha256": "df16615fe6c98744604a4fbcd1821506c049e979f72c1d8bccffb32ff37181b0" + }, + "new_content": " return true;" + } + ], + "conflict_keys": { + "files": [ + "main.cu" + ], + "regions": [ + { + "file": "main.cu", + "start": 133, + "end": 209 + } + ], + "semantic_tags": [ + "skip_verifier_body_stub" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "main.cu", + "text": "static bool verify_skip" + }, + { + "kind": "not_contains", + "file": "main.cu", + "text": "verifier: com_x opening FAILED" + }, + { + "kind": "not_contains", + "file": "main.cu", + "text": "if (sum != p.z_hat) {" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-014.json b/artifacts/zkllm/zkLLM-014.json new file mode 100644 index 0000000000000000000000000000000000000000..28dfc4c7c518a0e3750d500025da4555c86b89d0 --- /dev/null +++ b/artifacts/zkllm/zkLLM-014.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkLLM-014", + "codebase": "zkllm-ccs2024-fixed", + "source": "synthetic", + "finding": { + "name": "Rescaling Fiat-Shamir Challenges Replaced with Constant One-Vectors", + "explanation": "Rescaling::prove draws three Fiat-Shamir challenge vectors that drive the tLookup range proof on the remainder tensor: 'rescaling/u' and 'rescaling/v' (the sumcheck evaluation points) and 'rescaling/rand_temp' (the two tLookup blinding scalars). Replacing the three fs_challenge_vec(...) calls with constant {1,0,0,0,0,0,0,0} vectors hardcodes every challenge used inside the rescaling proof. Because the challenge point is known in advance, a malicious prover can commit an arbitrary remainder tensor that agrees with the committed (X, X_) only at the hardcoded point u and whose tLookup polynomials collide at the predictable rand_temp scalars -- the usual Schwartz-Zippel / tLookup soundness argument no longer applies because the verifier's challenge is not random.", + "labels": { + "relevant_code": "rescaling.cu:52", + "paper_reference": "Section 4.2 (Rescaling / range-check via tLookup) and Protocol 1 (tLookup): the tLookup range proof is sound only when the challenge beta and the sumcheck evaluation point u are drawn from the Fiat-Shamir transcript after the prover commits to the counter polynomial m and the remainder S." + } + }, + "edits": [ + { + "file": "rescaling.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 52, + "end": 55, + "expect_sha256": "7c6a3aac5aeb8921025e73d13373632d2b6340bca3527f24894875265511f562" + }, + "new_content": " auto u = vector(ceilLog2(X.size), Fr_t({1, 0, 0, 0, 0, 0, 0, 0}));\n auto v = vector(ceilLog2(X.size), Fr_t({1, 0, 0, 0, 0, 0, 0, 0}));\n\n auto rand_temp = vector(2, Fr_t({1, 0, 0, 0, 0, 0, 0, 0}));" + } + ], + "conflict_keys": { + "files": [ + "rescaling.cu" + ], + "regions": [ + { + "file": "rescaling.cu", + "start": 47, + "end": 60 + } + ], + "semantic_tags": [ + "rescaling_fs_challenge_hardcoded" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "rescaling.cu", + "text": "vector(ceilLog2(X.size), Fr_t({1, 0, 0, 0, 0, 0, 0, 0}))" + }, + { + "kind": "not_contains", + "file": "rescaling.cu", + "text": "fs_challenge_vec(\"rescaling/u\"" + }, + { + "kind": "not_contains", + "file": "rescaling.cu", + "text": "fs_challenge_vec(\"rescaling/rand_temp\"" + } + ] +} diff --git a/artifacts/zkllm/zkLLM-015.json b/artifacts/zkllm/zkLLM-015.json new file mode 100644 index 0000000000000000000000000000000000000000..de4e7165aede439665bd53f7081300d3ea413c5a --- /dev/null +++ b/artifacts/zkllm/zkLLM-015.json @@ -0,0 +1,66 @@ +{ + "artifact_id": "zkLLM-015", + "codebase": "zkllm-ccs2024-fixed", + "source": "synthetic", + "finding": { + "name": "FFN Output Saved at Wrong Rescaling Level", + "explanation": "The FFN down-projection produces down_out at scale gamma-squared. The rescaling step computes down_out_ at scale gamma. The injection reverts the save and commit calls to use the unrescaled down_out instead of down_out_, creating a scale mismatch: the committed FFN output is at gamma^2 while the downstream skip-connection and RMSNorm stages expect gamma. This breaks the commitment contract — the verifier binds to a value at the wrong quantization scale, and a malicious prover can exploit the scale confusion to prove incorrect fixed-point arithmetic across layer boundaries.", + "labels": { + "paper_reference": "Section 3.5 (Rescaling): each matrix multiplication doubles the quantization exponent; the rescaling operator must be applied before the result is committed to restore the canonical scale gamma.", + "relevant_code": "ffn.cu:137, ffn.cu:152" + } + }, + "edits": [ + { + "file": "ffn.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 137, + "end": 137, + "expect_sha256": "c7dc80d5d9cc77a6aaeac63196d964ed5448f8cdd117f00800b5c16a34101259" + }, + "new_content": " down_out.save_int(output_file_name);" + }, + { + "file": "ffn.cu", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 152, + "end": 152, + "expect_sha256": "5a37412a20c722c013da064a717ef95796a1275428034297d38b3e111974abb6" + }, + "new_content": " down_proj.generator, down_out, output_file_name);" + } + ], + "conflict_keys": { + "files": [ + "ffn.cu" + ], + "regions": [ + { + "file": "ffn.cu", + "start": 135, + "end": 155 + } + ], + "semantic_tags": [ + "ffn_output_rescale_commit" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "ffn.cu", + "text": "down_out.save_int(output_file_name);" + }, + { + "kind": "not_contains", + "file": "ffn.cu", + "text": "down_out_.save_int(output_file_name);" + } + ] +} diff --git a/artifacts/zkml/zkML-001.json b/artifacts/zkml/zkML-001.json new file mode 100644 index 0000000000000000000000000000000000000000..19db945b13c1dffb6a9b10faa75bfd3bd072d272 --- /dev/null +++ b/artifacts/zkml/zkML-001.json @@ -0,0 +1,52 @@ +{ + "artifact_id": "zkML-001", + "codebase": "zkml-fixed", + "source": "real", + "finding": { + "name": "Hardcoded Freivalds Challenge Vector", + "explanation": "The Freivalds random-check vector r is replaced with a hardcoded constant instead of being derived from the Halo2 challenge API. A malicious prover can precompute a MatMul forgery that satisfies the deterministic check with 100% probability, breaking the Schwartz-Zippel soundness guarantee.", + "labels": { + "relevant_code": "src/model.rs:210", + "paper_reference": "Section 6.1 (Linear layers): \"Freivalds' algorithm... we can take a random vector r and verify that Br = WAr... The random vector r must be generated after the matrix and results are committed.\"" + } + }, + "edits": [ + { + "file": "src/model.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 210, + "end": 210, + "expect_sha256": "228b048716793290da7c9dc9305b97fdc00c9c59cdde10f906be73a91a854255" + }, + "new_content": " let chal_value: Value = Value::known(F::from(0x123456789abcdefu64));" + } + ], + "conflict_keys": { + "files": [ + "src/model.rs" + ], + "regions": [ + { + "file": "src/model.rs", + "start": 205, + "end": 215 + } + ], + "semantic_tags": [ + "freivalds_challenge_source" + ], + "requires": [], + "incompatible": [ + "zkML-007" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/model.rs", + "text": "0x123456789abcdef" + } + ] +} diff --git a/artifacts/zkml/zkML-002.json b/artifacts/zkml/zkML-002.json new file mode 100644 index 0000000000000000000000000000000000000000..cb714c1f5cad426ec3db45607910825d54f423bb --- /dev/null +++ b/artifacts/zkml/zkML-002.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkML-002", + "codebase": "zkml-fixed", + "source": "real", + "finding": { + "name": "Weight Commitment Silently Disabled", + "explanation": "The commit_before list that controls which tensors are committed before proving is replaced with an empty vec, silently disabling all weight commitments. A malicious prover can substitute arbitrary model weights without detection.", + "labels": { + "relevant_code": "src/model.rs:501", + "paper_reference": "Section 4.3 (Security): \"the knowledge soundness property intuitively means that the prover must know the input and the weights\"" + } + }, + "edits": [ + { + "file": "src/model.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 501, + "end": 501, + "expect_sha256": "2b704f04dfddd96537ba5e777eb0bf6546d184d5a4908070ec1ad07238f69144" + }, + "new_content": " commit_before: vec![]," + } + ], + "conflict_keys": { + "files": [ + "src/model.rs" + ], + "regions": [ + { + "file": "src/model.rs", + "start": 496, + "end": 506 + } + ], + "semantic_tags": [ + "weight_commitment_config" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/model.rs", + "text": "commit_before: vec![]" + }, + { + "kind": "not_contains", + "file": "src/model.rs", + "text": "config.commit_before.clone().unwrap_or(vec![])" + } + ] +} diff --git a/artifacts/zkml/zkML-003.json b/artifacts/zkml/zkML-003.json new file mode 100644 index 0000000000000000000000000000000000000000..54cfa7990bff9c8f5fb15fd18ae670575060d4b8 --- /dev/null +++ b/artifacts/zkml/zkML-003.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkML-003", + "codebase": "zkml-fixed", + "source": "real", + "finding": { + "name": "Unconstrained AvgPool Divisor", + "explanation": "The AvgPool2D divisor is placed in an advice cell without a copy-constraint to the fixed column. The prover can set the divisor to 1, outputting the numerator unchanged and producing arbitrary average-pool results.", + "labels": { + "relevant_code": "src/layers/avg_pool_2d.rs:62", + "paper_reference": "Section 5.1 (Specialized operations, Variable division): \"b = c · a + r for r ∈ [0, ..., a). Thus, we can use the polynomial constraint b − c · a − r = 0 and constrain that a − r ∈ [0, ..., N)\"" + } + }, + "edits": [ + { + "file": "src/layers/avg_pool_2d.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 44, + "end": 64, + "expect_sha256": "dc70037d425ad61685308972f1f142ddf1c506f3f595e173e691785f0b9a1930" + }, + "new_content": " let div = layouter\n .assign_region(\n || \"avg pool 2d div\",\n |mut region| {\n let div = region.assign_advice(\n || \"avg pool 2d div\",\n gadget_config.columns[0],\n 0,\n || Value::known(div_val),\n )?;\n Ok(div)\n },\n )\n .unwrap();" + } + ], + "conflict_keys": { + "files": [ + "src/layers/avg_pool_2d.rs" + ], + "regions": [ + { + "file": "src/layers/avg_pool_2d.rs", + "start": 39, + "end": 68 + } + ], + "semantic_tags": [ + "avgpool_divisor_constraint" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/layers/avg_pool_2d.rs", + "text": "constrain_equal" + }, + { + "kind": "not_contains", + "file": "src/layers/avg_pool_2d.rs", + "text": "assign_fixed" + }, + { + "kind": "contains", + "file": "src/layers/avg_pool_2d.rs", + "text": "assign_advice" + } + ] +} diff --git a/artifacts/zkml/zkML-004.json b/artifacts/zkml/zkML-004.json new file mode 100644 index 0000000000000000000000000000000000000000..33b90a39fa9c6b403d7c5d3ff2db6892f0ab52f1 --- /dev/null +++ b/artifacts/zkml/zkML-004.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkML-004", + "codebase": "zkml-fixed", + "source": "real", + "finding": { + "name": "Unconstrained DivFixed Divisor", + "explanation": "The DivFixed layer's divisor is placed in an advice cell without a copy-constraint to the fixed column. The prover can set the divisor to any value, bypassing the compile-time scaling factor and producing arbitrary rescaled outputs.", + "labels": { + "relevant_code": "src/layers/div_fixed.rs:50", + "paper_reference": "Section 5.1 (Specialized operations, Variable division): \"b = c · a + r for r ∈ [0, ..., a). Thus, we can use the polynomial constraint b − c · a − r = 0 and constrain that a − r ∈ [0, ..., N)\"" + } + }, + "edits": [ + { + "file": "src/layers/div_fixed.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 34, + "end": 54, + "expect_sha256": "2e03b3af171d4172229b490662512c3f326c17a1f185e4cee384d5bc1a3e8c90" + }, + "new_content": " let div = layouter\n .assign_region(\n || \"division\",\n |mut region| {\n let div = region.assign_advice(\n || \"div fixed\",\n gadget_config.columns[0],\n 0,\n || Value::known(div_val),\n )?;\n Ok(div)\n },\n )\n .unwrap();" + } + ], + "conflict_keys": { + "files": [ + "src/layers/div_fixed.rs" + ], + "regions": [ + { + "file": "src/layers/div_fixed.rs", + "start": 29, + "end": 58 + } + ], + "semantic_tags": [ + "divfixed_divisor_constraint" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/layers/div_fixed.rs", + "text": "constrain_equal" + }, + { + "kind": "not_contains", + "file": "src/layers/div_fixed.rs", + "text": "assign_fixed" + }, + { + "kind": "contains", + "file": "src/layers/div_fixed.rs", + "text": "assign_advice" + } + ] +} diff --git a/artifacts/zkml/zkML-005.json b/artifacts/zkml/zkML-005.json new file mode 100644 index 0000000000000000000000000000000000000000..1b6f7f3dfeac7af5558b031732572c8dd70deb53 --- /dev/null +++ b/artifacts/zkml/zkML-005.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkML-005", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Dot-Product Partial Sums Left Unaggregated", + "explanation": "The dot-product gadget's final AdderChip aggregation step is removed; partial row sums are returned directly without being summed into a single constrained output. The prover can supply arbitrary partial results that do not sum to the correct dot product.", + "labels": { + "relevant_code": "src/gadgets/dot_prod.rs:198", + "paper_reference": "Section 6.1 (Linear layers / dot product): matmul is computed as row-wise dot products; the gadget aggregates partial-row sums via an AdderChip so the single-cell output is bound to the full sum." + } + }, + "edits": [ + { + "file": "src/gadgets/dot_prod.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 198, + "end": 208, + "expect_sha256": "bc3ac0e85cdec061044688b2c842318fcdd499290c70fe3df96e42d7462ced73" + }, + "new_content": " Ok(outputs)" + } + ], + "conflict_keys": { + "files": [ + "src/gadgets/dot_prod.rs" + ], + "regions": [ + { + "file": "src/gadgets/dot_prod.rs", + "start": 193, + "end": 213 + } + ], + "semantic_tags": [ + "dotprod_aggregation" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/gadgets/dot_prod.rs", + "text": "AdderChip::::construct" + }, + { + "kind": "not_contains", + "file": "src/gadgets/dot_prod.rs", + "text": "adder_chip" + }, + { + "kind": "contains", + "file": "src/gadgets/dot_prod.rs", + "text": "Ok(outputs)" + } + ] +} diff --git a/artifacts/zkml/zkML-006.json b/artifacts/zkml/zkML-006.json new file mode 100644 index 0000000000000000000000000000000000000000..6514e0212d365a6777a59f5fc9f690e1be088d41 --- /dev/null +++ b/artifacts/zkml/zkML-006.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkML-006", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "FC Layer Bias Addition Removed", + "explanation": "The fully-connected layer's bias addition branch is removed. Even when a bias tensor is present (tensors.len() == 3), it is silently ignored. The circuit proves a different linear operation (Wx instead of Wx+b) than the model specifies.", + "labels": { + "relevant_code": "src/layers/fc/fc_dpb_vdiv_lookup.rs:89", + "paper_reference": "-" + } + }, + "edits": [ + { + "file": "src/layers/fc/fc_dpb_vdiv_lookup.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 89, + "end": 105, + "expect_sha256": "88198c923a6317b7058319bb13e597053ee55d17d0562f29f42811a69393ce2e" + }, + "new_content": " let mm_div = mm_div;" + } + ], + "conflict_keys": { + "files": [ + "src/layers/fc/fc_dpb_vdiv_lookup.rs" + ], + "regions": [ + { + "file": "src/layers/fc/fc_dpb_vdiv_lookup.rs", + "start": 84, + "end": 110 + } + ], + "semantic_tags": [ + "fc_bias_addition" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/layers/fc/fc_dpb_vdiv_lookup.rs", + "text": "AddPairsChip::::construct" + }, + { + "kind": "not_contains", + "file": "src/layers/fc/fc_dpb_vdiv_lookup.rs", + "text": "mm_bias" + }, + { + "kind": "not_contains", + "file": "src/layers/fc/fc_dpb_vdiv_lookup.rs", + "text": "tensors[2]" + } + ] +} diff --git a/artifacts/zkml/zkML-007.json b/artifacts/zkml/zkML-007.json new file mode 100644 index 0000000000000000000000000000000000000000..0dfc2bd2b73691cbeca7ed09901978c2ea6581af --- /dev/null +++ b/artifacts/zkml/zkML-007.json @@ -0,0 +1,52 @@ +{ + "artifact_id": "zkML-007", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "RLC Challenge Replaced with Small Constant", + "explanation": "The RLC/Freivalds challenge is replaced with the literal constant 42 instead of being drawn from the Halo2 Phase-2 challenge API. Since the challenge is predictable and tiny, the prover can craft witnesses that satisfy the random linear combination check without performing the correct matmul computation. This is a small-constant variant of zkML-001.", + "labels": { + "relevant_code": "src/model.rs:210", + "paper_reference": "Section 6.1 (Linear layers): \"The random vector r must be generated after the matrix and results are committed.\"" + } + }, + "edits": [ + { + "file": "src/model.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 210, + "end": 210, + "expect_sha256": "228b048716793290da7c9dc9305b97fdc00c9c59cdde10f906be73a91a854255" + }, + "new_content": " let chal_value: Value = Value::known(F::from(42u64));" + } + ], + "conflict_keys": { + "files": [ + "src/model.rs" + ], + "regions": [ + { + "file": "src/model.rs", + "start": 205, + "end": 215 + } + ], + "semantic_tags": [ + "freivalds_challenge_source" + ], + "requires": [], + "incompatible": [ + "zkML-001" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/model.rs", + "text": "Value::known(F::from(42u64))" + } + ] +} diff --git a/artifacts/zkml/zkML-008.json b/artifacts/zkml/zkML-008.json new file mode 100644 index 0000000000000000000000000000000000000000..da8464940975539a148efac6c853a3289e42cf9b --- /dev/null +++ b/artifacts/zkml/zkML-008.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkML-008", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Softmax Division Remainder Unchecked", + "explanation": "The VarDivRound gadget's lookup-based range checks on the remainder r and the (2b - r) term are removed from the rounded-division gate. Without these range checks the prover can supply an arbitrary remainder that wraps around the field, producing any desired softmax or rescale output. The b range-check on line 82 is left intact so the divisor remains bounded.", + "labels": { + "relevant_code": "src/gadgets/var_div.rs:62", + "paper_reference": "Section 5.1 (Variable division): \"b = c · a + r for r ∈ [0, ..., a)\" — remainder r must be range-checked via lookup" + } + }, + "edits": [ + { + "file": "src/gadgets/var_div.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 62, + "end": 80, + "expect_sha256": "19aa647965eae0271735002db8f83011e15954c01fb6cbbdcf57120539b7445c" + }, + "new_content": "" + } + ], + "conflict_keys": { + "files": [ + "src/gadgets/var_div.rs" + ], + "regions": [ + { + "file": "src/gadgets/var_div.rs", + "start": 60, + "end": 82 + } + ], + "semantic_tags": [ + "var_div_range_checks" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "not_contains", + "file": "src/gadgets/var_div.rs", + "text": "var div range checks r" + }, + { + "kind": "not_contains", + "file": "src/gadgets/var_div.rs", + "text": "var div range checks 2b-r" + }, + { + "kind": "contains", + "file": "src/gadgets/var_div.rs", + "text": "var div range checks b" + } + ] +} diff --git a/artifacts/zkml/zkML-010.json b/artifacts/zkml/zkML-010.json new file mode 100644 index 0000000000000000000000000000000000000000..9184126df866c0e5f5e2c34dbf6da39ac6dc052d --- /dev/null +++ b/artifacts/zkml/zkML-010.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkML-010", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Non-Linear Lookup Input Expression Zeroed", + "explanation": "The non-linearity gadget enforces (inp, outp) ∈ T via a two-column lookup where T maps every in-range input to its activation output. The input-side lookup expression is rewritten from `(s * (inp + shift_val_pos), inp_lookup)` to `(s * 0, inp_lookup)`, which always matches entry 0 of the InputLookup range table and unconditionally succeeds. The output-side lookup still binds outp to the activation image, but the pairing (inp, outp) is no longer enforced — the prover can pick any inp value and any outp in the image of the activation, decoupling the function from its argument. Every non-linearity in the model (ReLU, Sigmoid, Tanh, Exp, Sqrt, GELU) is impacted simultaneously.", + "labels": { + "relevant_code": "src/gadgets/nonlinear/non_linearity.rs:50", + "paper_reference": "Section 5.1 (Non-linear operations / lookup-based activations): each activation is proved by a two-column lookup (inp, outp) ∈ T where T is the enumerated (input, f(input)) table; both tuples must be queried for the lookup to bind inp to outp." + } + }, + "edits": [ + { + "file": "src/gadgets/nonlinear/non_linearity.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 50, + "end": 50, + "expect_sha256": "f7259168afec495a28270924f2d8e7539ef58fc0216a5c31f608a77450cadcea" + }, + "new_content": " (s.clone() * Expression::Constant(F::ZERO), inp_lookup)," + } + ], + "conflict_keys": { + "files": [ + "src/gadgets/nonlinear/non_linearity.rs" + ], + "regions": [ + { + "file": "src/gadgets/nonlinear/non_linearity.rs", + "start": 42, + "end": 54 + } + ], + "semantic_tags": [ + "non_linearity_lookup_input" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/gadgets/nonlinear/non_linearity.rs", + "text": "Expression::Constant(F::ZERO), inp_lookup" + }, + { + "kind": "not_contains", + "file": "src/gadgets/nonlinear/non_linearity.rs", + "text": "(s.clone() * (inp + shift_val_pos), inp_lookup)" + } + ] +} diff --git a/artifacts/zkml/zkML-011.json b/artifacts/zkml/zkML-011.json new file mode 100644 index 0000000000000000000000000000000000000000..8597b5bd88c6c1d321f79a2ca20b166e1b508503 --- /dev/null +++ b/artifacts/zkml/zkML-011.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkML-011", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Inference Output Not Bound to Public Instance", + "explanation": "After running the DAG, ModelCircuit::synthesize exposes two sets of cells as public instance values: (a) the pre-DAG commitments (one cell per tensor index in commit_before/commit_after) and (b) every cell of the inference result tensors. The second loop — the one that calls `constrain_instance` over `result` — is removed. The commitments to weights and activations are still bound to the public column, but the actual inference output is no longer exposed on the instance column. A verifier who reads the claimed output from `PUBLIC_VALS` has no cryptographic binding between that value and the committed circuit state; a malicious prover can produce a valid proof for some output tensor and then return any value it wants in the out-of-band `PUBLIC_VALS` mutex.", + "labels": { + "relevant_code": "src/model.rs:898", + "paper_reference": "Section 6.2 (End-to-end soundness): the circuit's claimed output must be exposed as public instance values so the verifier can compare the proven output to the public statement. Without this binding, the ZK proof is a proof of some unspecified output, not the public one." + } + }, + "edits": [ + { + "file": "src/model.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 898, + "end": 907, + "expect_sha256": "8071a4cc2c32e3147882dbb136926bf8214ff8e703883db6e9d14ffd5fd852be" + }, + "new_content": " // result output binding to public instance removed" + } + ], + "conflict_keys": { + "files": [ + "src/model.rs" + ], + "regions": [ + { + "file": "src/model.rs", + "start": 888, + "end": 910 + } + ], + "semantic_tags": [ + "result_public_instance_binding" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/model.rs", + "text": "result output binding to public instance removed" + }, + { + "kind": "not_contains", + "file": "src/model.rs", + "text": "for tensor in result {" + } + ] +} diff --git a/artifacts/zkml/zkML-012.json b/artifacts/zkml/zkML-012.json new file mode 100644 index 0000000000000000000000000000000000000000..ffe6a2e26d2e62b2cc774b07a9f632fb3b0c5ac8 --- /dev/null +++ b/artifacts/zkml/zkML-012.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkML-012", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Residual Add Constraint Replaced with Pass-Through", + "explanation": "AddChip::gadget_forward normally constructs an AddPairsChip and invokes `add_pairs_chip.forward(...)` to enforce `z = x + y` as an in-circuit gate constraint for every element. The injection replaces the chip call with a pass-through that returns the first input tensor's cells unchanged. Because AddPairsChip is what introduces the sum-gate selector and custom-gate constraint tying each output cell to the sum of its two input cells, removing the chip call leaves the ONNX Add result completely unconstrained in the circuit: at proof time, the downstream DAG consumes cells that equal input[0] without any arithmetic relationship to input[1]. The honest prover executes the same pass-through and produces values that happen to equal input[0], and the verifier has no constraint forcing the output to equal x+y. Impacts every residual / skip connection (ResNets, Transformers, MLP-Mixer residuals, etc.), and any ONNX graph that uses Add to combine two tensors.", + "labels": { + "relevant_code": "src/layers/arithmetic/add.rs:46", + "paper_reference": "Section 4 (Gadget composition): every ONNX operator must lower to a gate that constrains its output to its inputs. An operator that returns input[0] unchanged but is reported as an Add in the DAG breaks this invariant." + } + }, + "edits": [ + { + "file": "src/layers/arithmetic/add.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 46, + "end": 47, + "expect_sha256": "492ad9957cd35320d9724b7c332e18dd1ca795b2c5717fcc11b7ce4a398e8ebe" + }, + "new_content": " let _ = (layouter, constants, gadget_config);\n let out = vec_inputs[0].iter().map(|c| (*c).clone()).collect::>();" + } + ], + "conflict_keys": { + "files": [ + "src/layers/arithmetic/add.rs" + ], + "regions": [ + { + "file": "src/layers/arithmetic/add.rs", + "start": 38, + "end": 50 + } + ], + "semantic_tags": [ + "add_chip_gadget_forward" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/layers/arithmetic/add.rs", + "text": "vec_inputs[0].iter().map(|c| (*c).clone()).collect::>()" + }, + { + "kind": "not_contains", + "file": "src/layers/arithmetic/add.rs", + "text": "add_pairs_chip.forward(layouter.namespace(|| \"add chip\")" + } + ] +} diff --git a/artifacts/zkml/zkML-013.json b/artifacts/zkml/zkML-013.json new file mode 100644 index 0000000000000000000000000000000000000000..2ef0695ec4dc9a0724515439f28dda194f99f886 --- /dev/null +++ b/artifacts/zkml/zkML-013.json @@ -0,0 +1,57 @@ +{ + "artifact_id": "zkML-013", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Non-Linear Activation Lookup Replaced with No-Op", + "explanation": "The non-linearity gadget (ReLU, Sigmoid, Tanh, Exp, Sqrt, GELU, Logistic) normally enforces a two-column Halo2 `meta.lookup(\"non-linear lookup\", ...)` that pins `(inp + shift, outp) ∈ T` where T is the enumerated activation table. The injection removes the entire `meta.lookup` call inside the per-op-column for-loop, leaving no constraint at all on the input↔output relation of the activation. The proving-key-committed activation table is still loaded by `load_lookups`, but no gate consumes it — the table is dead weight. A malicious prover can assign any `outp` value for any `inp`; the selector fires but no lookup is asserted. Every non-linear layer in the model (including the final softmax, all attention softmaxes, and every activation in the MLP blocks) becomes unconstrained.", + "labels": { + "relevant_code": "src/gadgets/nonlinear/non_linearity.rs:42", + "paper_reference": "Section 5.1 (Lookup-based non-linearities): ReLU/Sigmoid/Tanh/etc. are proved by enumerating f: [min_val, max_val] → F in a lookup table and asserting (inp, outp) ∈ T. Without the meta.lookup call the table exists but is never consulted." + } + }, + "edits": [ + { + "file": "src/gadgets/nonlinear/non_linearity.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 42, + "end": 53, + "expect_sha256": "880b92382980449c411d825f94d7ac0547d31383c5e26a531260899fca2522b6" + }, + "new_content": " let _ = (offset, inp_lookup, outp_lookup); // non-linear lookup stubbed out" + } + ], + "conflict_keys": { + "files": [ + "src/gadgets/nonlinear/non_linearity.rs" + ], + "regions": [ + { + "file": "src/gadgets/nonlinear/non_linearity.rs", + "start": 40, + "end": 55 + } + ], + "semantic_tags": [ + "non_linearity_meta_lookup" + ], + "requires": [], + "incompatible": [ + "zkML-010" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/gadgets/nonlinear/non_linearity.rs", + "text": "non-linear lookup stubbed out" + }, + { + "kind": "not_contains", + "file": "src/gadgets/nonlinear/non_linearity.rs", + "text": "meta.lookup(\"non-linear lookup\"" + } + ] +} diff --git a/artifacts/zkml/zkML-014.json b/artifacts/zkml/zkML-014.json new file mode 100644 index 0000000000000000000000000000000000000000..b050fec5a9f3d268d99f95830e05e08ee28191f5 --- /dev/null +++ b/artifacts/zkml/zkML-014.json @@ -0,0 +1,57 @@ +{ + "artifact_id": "zkML-014", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Var-Div Divisor Range Check Removed (Overflow Vector)", + "explanation": "VarDivRoundChip exposes three range-check lookups covering (a) the remainder r ∈ [0, 2^N), (b) 2b−r ∈ [0, 2^N), and (c) the divisor b ∈ [0, 2^N). All three use the same InputLookup table which enumerates 0..num_rows. The injection deletes only the third lookup — the one that bounds the divisor b itself. The arithmetic gate `(2a + b) = 2bc + r` still holds numerically in F_p, but without b's range bound the prover is free to choose a value of b that wraps the field modulus. Given any target quotient c̃ and numerator a, set `b := 0` to avoid the divide-by-zero panic and pick r arbitrarily; or set `b := p - 1` so that `2bc̃ + r` wraps to any target. The remainder range check on r and 2b−r still passes because those are separately enforced, but they no longer constrain the quotient because b itself is unbounded. Impacts softmax normalization, mean pooling, rescaling, and every other VarDivRound consumer.", + "labels": { + "relevant_code": "src/gadgets/var_div.rs:81", + "paper_reference": "Section 5.1 (Variable division): all three of r, 2b−r, and b must be range-checked against [0, 2^N) for the rounded-division identity to prove the intended quotient. Removing the b-range bound is sufficient to forge." + } + }, + "edits": [ + { + "file": "src/gadgets/var_div.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 81, + "end": 87, + "expect_sha256": "c2aa94e001ed7415daa0100bbecdcd6004417840ecdd62c58b961d37b7466736" + }, + "new_content": " // b range check removed" + } + ], + "conflict_keys": { + "files": [ + "src/gadgets/var_div.rs" + ], + "regions": [ + { + "file": "src/gadgets/var_div.rs", + "start": 80, + "end": 89 + } + ], + "semantic_tags": [ + "var_div_b_range_check" + ], + "requires": [], + "incompatible": [ + "zkML-008" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/gadgets/var_div.rs", + "text": "b range check removed" + }, + { + "kind": "not_contains", + "file": "src/gadgets/var_div.rs", + "text": "var div range checks b" + } + ] +} diff --git a/artifacts/zkml/zkML-015.json b/artifacts/zkml/zkML-015.json new file mode 100644 index 0000000000000000000000000000000000000000..ce97796b26c9b04a3a97f37da335c04e4872e173 --- /dev/null +++ b/artifacts/zkml/zkML-015.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkML-015", + "codebase": "zkml-fixed", + "source": "synthetic", + "finding": { + "name": "Selector Constraint Enforcement Disabled by Default", + "explanation": "The circuit configuration flag use_selectors controls whether Halo2 selector columns are enabled during synthesis. Selectors mask which rows participate in each constraint gate; without them, constraints apply to all rows including padding rows that contain unconstrained witness values. The injection flips the default from true to false, causing the packing gadget and other selector-gated constraints to skip enablement. A malicious prover can place arbitrary values in the unused rows and satisfy the weakened constraint system.", + "labels": { + "relevant_code": "src/model.rs:503", + "paper_reference": "Section 5 (Circuit implementation): the Halo2 backend uses selector columns to restrict polynomial constraints to active rows; disabling selectors violates the row-isolation invariant." + } + }, + "edits": [ + { + "file": "src/model.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 503, + "end": 503, + "expect_sha256": "b8b65562764493334a09acc2d5a179a60821bb0af38507dddb7de60aceadacad" + }, + "new_content": " use_selectors: config.use_selectors.unwrap_or(false)," + } + ], + "conflict_keys": { + "files": [ + "src/model.rs" + ], + "regions": [ + { + "file": "src/model.rs", + "start": 500, + "end": 506 + } + ], + "semantic_tags": [ + "selector_constraint_default" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/model.rs", + "text": "unwrap_or(false)" + }, + { + "kind": "not_contains", + "file": "src/model.rs", + "text": "unwrap_or(true)" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-001.json b/artifacts/zktorch/zkTorch-001.json new file mode 100644 index 0000000000000000000000000000000000000000..04145e60f824c23dd2efcde6b9372c347c82948d --- /dev/null +++ b/artifacts/zktorch/zkTorch-001.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-001", + "codebase": "zk-torch-fixed", + "source": "real", + "finding": { + "name": "Fold Gamma Hardcoded to One", + "explanation": "The Fiat-Shamir fold verification gamma is replaced with Fr::one(). When gamma=1, the Schwartz-Zippel batching check degenerates into a trivial sum, allowing a malicious prover to forge pairing checks across accumulated instances.", + "labels": { + "relevant_code": "src/util/verifier.rs:44", + "paper_reference": "Section 4.2 (Parallel Accumulation): the γ challenge batching multiple proved relations via Schwartz-Zippel must be Fiat-Shamir-derived, not a constant (step 4 of the Accumulation Prover: γ ← ρacc(acc.x, acc'.x, [Ej]))." + } + }, + "edits": [ + { + "file": "src/util/verifier.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 44, + "end": 63, + "expect_sha256": "236c75c61170889eec0500bae4b6497396771a8cb4269b9555b6bce1edbc8ef6" + }, + "new_content": " let gamma = Fr::one();" + } + ], + "conflict_keys": { + "files": [ + "src/util/verifier.rs" + ], + "regions": [ + { + "file": "src/util/verifier.rs", + "start": 39, + "end": 68 + } + ], + "semantic_tags": [ + "fold_gamma_challenge" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/util/verifier.rs", + "text": "let gamma = Fr::one();" + }, + { + "kind": "not_contains", + "file": "src/util/verifier.rs", + "text": "hasher.update(b\"zktorch/fold/gamma/v1\")" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-002.json b/artifacts/zktorch/zkTorch-002.json new file mode 100644 index 0000000000000000000000000000000000000000..a3c7a47797d4c595fc0772ad22e1fe10592961a1 --- /dev/null +++ b/artifacts/zktorch/zkTorch-002.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-002", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "ONNX Silent Constant Clamping to 2^8", + "explanation": "ONNX F32 constants are silently clamped to the range [-2^8, 2^8] (±256) during model loading. Any weight whose scaled magnitude exceeds 256 is truncated without any error or warning, so the circuit proves an inference over a silently corrupted model. With the default scale factor the truncation begins at a raw weight of ±32, which affects essentially every real model.", + "labels": { + "relevant_code": "src/onnx.rs:79", + "paper_reference": "-" + } + }, + "edits": [ + { + "file": "src/onnx.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 79, + "end": 79, + "expect_sha256": "6677ea550048ecbf5e0bc7621408547cda627aeb70199291cd85ee9b0c32ec61" + }, + "new_content": " y = y.clamp(-(1 << 8) as f32, (1 << 8) as f32);" + } + ], + "conflict_keys": { + "files": [ + "src/onnx.rs" + ], + "regions": [ + { + "file": "src/onnx.rs", + "start": 74, + "end": 84 + } + ], + "semantic_tags": [ + "onnx_constant_range" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/onnx.rs", + "text": "1 << 8" + }, + { + "kind": "not_contains", + "file": "src/onnx.rs", + "text": "y.clamp(-(1 << 15)" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-003.json b/artifacts/zktorch/zkTorch-003.json new file mode 100644 index 0000000000000000000000000000000000000000..ec4cb04757e88903471e314dcb6a5e59da407958 --- /dev/null +++ b/artifacts/zktorch/zkTorch-003.json @@ -0,0 +1,60 @@ +{ + "artifact_id": "zkTorch-003", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Prover Fiat-Shamir Seed Replaced with Fixed Value", + "explanation": "The prover's Fiat-Shamir RNG seed, normally derived by hashing the encoded model, inputs, and outputs via Keccak256, is replaced with a fixed 32-byte seed. The prover can pre-compute challenges and craft witnesses that satisfy the checks for any model/input pair.", + "labels": { + "relevant_code": "src/util/prover.rs:194", + "paper_reference": "Section 2.2 (Interactive Proofs and ZK-SNARKs): non-interactivity via Fiat-Shamir over a compatible interactive protocol; the prover's Keccak256(modelsEncBytes || inputsEncBytes || outputsEncBytes)-seeded RNG is this FS oracle." + } + }, + "edits": [ + { + "file": "src/util/prover.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 194, + "end": 200, + "expect_sha256": "6f42623f5c82f9c41ea4949f5df07921d5938e289e4795d6bcdb9acca0ffff4d" + }, + "new_content": " let buf = [0x42u8; 32];\n let mut rng = StdRng::from_seed(buf);" + } + ], + "conflict_keys": { + "files": [ + "src/util/prover.rs" + ], + "regions": [ + { + "file": "src/util/prover.rs", + "start": 193, + "end": 205 + } + ], + "semantic_tags": [ + "prover_fiat_shamir_seed" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/util/prover.rs", + "text": "0x42u8; 32" + }, + { + "kind": "not_contains", + "file": "src/util/prover.rs", + "text": "Keccak256::new()" + }, + { + "kind": "not_contains", + "file": "src/util/prover.rs", + "text": "hasher.update(modelsEncBytes)" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-004.json b/artifacts/zktorch/zkTorch-004.json new file mode 100644 index 0000000000000000000000000000000000000000..fd5d88be41ff36aaea981b0365b0e5ac83569c1f --- /dev/null +++ b/artifacts/zktorch/zkTorch-004.json @@ -0,0 +1,62 @@ +{ + "artifact_id": "zkTorch-004", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Verifier Public Statement Checks Removed", + "explanation": "The verifier's public-statement binding assertions (model_digest, graph_digest, output_digest, input_digest, scale_factor_log, cq_range_log, cq_range_lower_log) are all removed. The verifier no longer validates that the proof corresponds to the claimed model, input, or output.", + "labels": { + "relevant_code": "src/util/verifier.rs:268", + "paper_reference": "Section 2.2 (Interactive Proofs and ZK-SNARKs): the verifier must bind the proof to the public instance x = (model, input, output); check_public_statement implements that binding." + } + }, + "edits": [ + { + "file": "src/util/verifier.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 268, + "end": 297, + "expect_sha256": "0e969def86097263623710f38377297a98bff65af2a597e59bf1465495a6c3d7" + }, + "new_content": " println!(\"public statement verified.\");\n}" + } + ], + "conflict_keys": { + "files": [ + "src/util/verifier.rs" + ], + "regions": [ + { + "file": "src/util/verifier.rs", + "start": 263, + "end": 302 + } + ], + "semantic_tags": [ + "verifier_statement_binding" + ], + "requires": [], + "incompatible": [ + "zkTorch-006" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/util/verifier.rs", + "text": "public statement verified" + }, + { + "kind": "not_contains", + "file": "src/util/verifier.rs", + "text": "supplied.model_digest" + }, + { + "kind": "not_contains", + "file": "src/util/verifier.rs", + "text": "supplied.output_digest" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-005.json b/artifacts/zktorch/zkTorch-005.json new file mode 100644 index 0000000000000000000000000000000000000000..5293525b5877066c25d3152dd54396443806129a --- /dev/null +++ b/artifacts/zktorch/zkTorch-005.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-005", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Fake Tensor Fallback for Missing Weights", + "explanation": "External-data ONNX tensors previously caused the loader to panic (refusing to fabricate values). This artifact replaces the panic with a silent fake-tensor fallback that fills (shape, data_type) with random F32 values, so the circuit commits to and proves inference over fabricated weights unrelated to the claimed model.", + "labels": { + "relevant_code": "src/onnx.rs:99", + "paper_reference": "-" + } + }, + "edits": [ + { + "file": "src/onnx.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 95, + "end": 105, + "expect_sha256": "7a2629bf2c829a73374b2bfd400bf3c53d449ec2c9679562521f282b0c3fe63f" + }, + "new_content": " } else {\n // Fallback: fabricate random F32 tensor for external-data initializers.\n let numel: usize = shape.iter().product::().max(1);\n let data: Vec = (0..numel).map(|_| rand::random::()).collect();\n let fake = ndarray::ArrayD::from_shape_vec(ndarray::IxDyn(&shape), data).unwrap();\n let tensor = fake.map(|x| {\n let mut y = (*x * SF_FLOAT.read().unwrap().to_owned()).round();\n y = y.clamp(-(1 << 15) as f32, (1 << 15) as f32);\n Fr::from(y as i32)\n });\n (tensor, DatumType::F32)\n };" + } + ], + "conflict_keys": { + "files": [ + "src/onnx.rs" + ], + "regions": [ + { + "file": "src/onnx.rs", + "start": 90, + "end": 110 + } + ], + "semantic_tags": [ + "onnx_external_data_fallback" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/onnx.rs", + "text": "Fallback: fabricate random F32 tensor" + }, + { + "kind": "not_contains", + "file": "src/onnx.rs", + "text": "uses external data storage; loading external" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-006.json b/artifacts/zktorch/zkTorch-006.json new file mode 100644 index 0000000000000000000000000000000000000000..a3b29fc25e29d8d5fe6e07d9620c22e33f218f6e --- /dev/null +++ b/artifacts/zktorch/zkTorch-006.json @@ -0,0 +1,57 @@ +{ + "artifact_id": "zkTorch-006", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Verifier Trusts Prover's PublicStatement File", + "explanation": "The verifier reads the 'supplied' PublicStatement from CONFIG.prover.public_statement_path instead of CONFIG.verifier.public_statement_path. Because the prover writes that file from the same enc bytes the verifier then recomputes over, every assert_eq! in check_public_statement is tautological — a malicious prover can substitute any (model, input, output) triple and the verifier accepts.", + "labels": { + "relevant_code": "src/util/verifier.rs:245", + "paper_reference": "Section 2.2 (Interactive Proofs and ZK-SNARKs): verification is w.r.t. a public instance x; Fiat-Shamir binding requires x to be externally specified, not prover-derived." + } + }, + "edits": [ + { + "file": "src/util/verifier.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 245, + "end": 245, + "expect_sha256": "0d2fcae8df706325ea072bde902bb4edcb95d8a97bb9539f2dc85669e62406a0" + }, + "new_content": " let path = &CONFIG.prover.public_statement_path;" + } + ], + "conflict_keys": { + "files": [ + "src/util/verifier.rs" + ], + "regions": [ + { + "file": "src/util/verifier.rs", + "start": 240, + "end": 250 + } + ], + "semantic_tags": [ + "verifier_statement_source_path" + ], + "requires": [], + "incompatible": [ + "zkTorch-004" + ] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/util/verifier.rs", + "text": "let path = &CONFIG.prover.public_statement_path;" + }, + { + "kind": "not_contains", + "file": "src/util/verifier.rs", + "text": "let path = &CONFIG.verifier.public_statement_path;" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-007.json b/artifacts/zktorch/zkTorch-007.json new file mode 100644 index 0000000000000000000000000000000000000000..e5c1c969eb927ccd9022c48436e054f54a8a0971 --- /dev/null +++ b/artifacts/zktorch/zkTorch-007.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-007", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Division Remainder Range Check Removed", + "explanation": "The DivConstProofBasicBlock::run() function outputs (div, r, diff) with r and diff fed into CQ range checks downstream. This artifact zeroes the r and diff arrays; after encodeOutputs rederives diff's commitment from r as 2b − r, the CQ lookups see constant polynomials (r=0, diff=2b) and trivially pass. Combined with the fact that the quotient div is not range-checked at this block boundary, a malicious prover can commit to div = (2a+b)·(2b)⁻¹ ∈ Fr — a generally non-integer field element — satisfying the algebraic identity 2a+b = 2b·div + 0, and the verifier accepts.", + "labels": { + "relevant_code": "src/basic_block/div.rs:81", + "paper_reference": "Section 4.4.1 (MatMul): rounded-division relation (2a+b) = 2bc + r with r, 2b−r range-checked via CQ" + } + }, + "edits": [ + { + "file": "src/basic_block/div.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 81, + "end": 97, + "expect_sha256": "85fb02fc62ee23b9d310da2c1edd0560e95673b67c181575766bb923d26fe62c" + }, + "new_content": " let r = util::array_into_iter(inputs[0])\n .map(|_| Fr::from(0i128))\n .collect::>();\n\n let diff = r.clone();" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/div.rs" + ], + "regions": [ + { + "file": "src/basic_block/div.rs", + "start": 76, + "end": 102 + } + ], + "semantic_tags": [ + "div_remainder_range_check" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/div.rs", + "text": "Fr::from(0i128)" + }, + { + "kind": "not_contains", + "file": "src/basic_block/div.rs", + "text": "2 * self.c as i128 - x" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-008.json b/artifacts/zktorch/zkTorch-008.json new file mode 100644 index 0000000000000000000000000000000000000000..f35557b9915990dc0b4c12d4d40a526c87cefb4e --- /dev/null +++ b/artifacts/zktorch/zkTorch-008.json @@ -0,0 +1,71 @@ +{ + "artifact_id": "zkTorch-008", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Mira Accumulation Gamma Hardcoded", + "explanation": "The per-fold-step accumulation challenge acc_gamma in mira_prove() AND mira_verify() is replaced with Fr::one() instead of being derived from the Fiat-Shamir RNG. With gamma=1 on both sides, the Schwartz-Zippel batching of two MatMul accumulators degenerates to a plain sum acc_1 + acc_2, letting a malicious prover submit any acc_g1/acc_g2/mu/acc_errs vectors that sum correctly — forgeries are trivially constructible across accumulated instances.", + "labels": { + "relevant_code": "src/basic_block/matmul.rs:211", + "paper_reference": "Section 4.2 (Parallel Accumulation), Accumulation Prover step 4: \"γ ← ρacc(acc.x, acc'.x, [Ej])\"" + } + }, + "edits": [ + { + "file": "src/basic_block/matmul.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 211, + "end": 211, + "expect_sha256": "bbd236dc4b9d979047b8129ce0252e4ee28d7392711fcab5aa92ab6ac62b7a23" + }, + "new_content": " let acc_gamma = Fr::one();" + }, + { + "file": "src/basic_block/matmul.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 287, + "end": 287, + "expect_sha256": "bbd236dc4b9d979047b8129ce0252e4ee28d7392711fcab5aa92ab6ac62b7a23" + }, + "new_content": " let acc_gamma = Fr::one();" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/matmul.rs" + ], + "regions": [ + { + "file": "src/basic_block/matmul.rs", + "start": 206, + "end": 216 + }, + { + "file": "src/basic_block/matmul.rs", + "start": 282, + "end": 292 + } + ], + "semantic_tags": [ + "mira_accumulation_gamma" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/matmul.rs", + "text": "let acc_gamma = Fr::one();" + }, + { + "kind": "not_contains", + "file": "src/basic_block/matmul.rs", + "text": "let acc_gamma = Fr::rand(rng);" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-010.json b/artifacts/zktorch/zkTorch-010.json new file mode 100644 index 0000000000000000000000000000000000000000..0de637922ec34d84221011f48aa60fc07b84e693 --- /dev/null +++ b/artifacts/zktorch/zkTorch-010.json @@ -0,0 +1,71 @@ +{ + "artifact_id": "zkTorch-010", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Division RLC Alpha Challenge Fixed to One", + "explanation": "The per-element RLC challenge α in DivConstProofBasicBlock::prove() AND ::verify() is replaced with Fr::one(). With α=1, the Schwartz-Zippel weighting of the polynomial identity 2a_i + b = 2b·div_i + r_i across tensor positions degenerates to a plain sum. A malicious prover can construct elementwise errors e_i with Σ e_i = 0 (e.g., a ±e pair at two tensor positions) that the batched check accepts, breaking the soundness guarantee of the division verification.", + "labels": { + "paper_reference": "Section 4.4.1 (rounded-division): the RLC challenge α batching the polynomial identity (2a+b) = 2bc + r across tensor elements must be Fiat-Shamir-derived, not a constant.", + "relevant_code": "src/basic_block/div.rs:143" + } + }, + "edits": [ + { + "file": "src/basic_block/div.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 143, + "end": 143, + "expect_sha256": "72da731c7503dd4e7445ebe966645aafaafdcab9ec5a521860121ae832cc8d30" + }, + "new_content": " let alpha = Fr::one();" + }, + { + "file": "src/basic_block/div.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 187, + "end": 187, + "expect_sha256": "72da731c7503dd4e7445ebe966645aafaafdcab9ec5a521860121ae832cc8d30" + }, + "new_content": " let alpha = Fr::one();" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/div.rs" + ], + "regions": [ + { + "file": "src/basic_block/div.rs", + "start": 138, + "end": 148 + }, + { + "file": "src/basic_block/div.rs", + "start": 182, + "end": 192 + } + ], + "semantic_tags": [ + "div_rlc_alpha" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/div.rs", + "text": "let alpha = Fr::one();" + }, + { + "kind": "not_contains", + "file": "src/basic_block/div.rs", + "text": "let alpha = Fr::rand(rng);" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-011.json b/artifacts/zktorch/zkTorch-011.json new file mode 100644 index 0000000000000000000000000000000000000000..9736be04d2a2d3156d28b91b8851c603bf7ca956 --- /dev/null +++ b/artifacts/zktorch/zkTorch-011.json @@ -0,0 +1,78 @@ +{ + "artifact_id": "zkTorch-011", + "codebase": "zk-torch-fixed", + "source": "real", + "finding": { + "name": "Mock Prove Feature Re-enabled", + "explanation": "The mock_prove Cargo feature is re-added, set as the default feature, and the release-build guard in src/lib.rs is removed. Every KZG commitment in prove() becomes the fixed generator srs.X1P[0], so every produced proof is trivially forgeable — cryptographic soundness is completely voided for all builds (dev and release, default-on).", + "labels": { + "relevant_code": "Cargo.toml:32", + "paper_reference": "-" + } + }, + "edits": [ + { + "file": "Cargo.toml", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 29, + "end": 32, + "expect_sha256": "f0f1608aa02f3365271784621cf4ac730213292d58029f64d2bd5c8e48cdaf02" + }, + "new_content": "[features]\ndefault = [\"mock_prove\"]\ndebug = []\ngpu = []\nmock_prove = []\nfold = []" + }, + { + "file": "src/lib.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 5, + "end": 11, + "expect_sha256": "2a647a8aa897cb8ed8fe072af8becac20e45ca4909238973e9dcba84a6eb0ecd" + }, + "new_content": "// mock_prove guard removed" + } + ], + "conflict_keys": { + "files": [ + "Cargo.toml", + "src/lib.rs" + ], + "regions": [ + { + "file": "Cargo.toml", + "start": 24, + "end": 37 + }, + { + "file": "src/lib.rs", + "start": 1, + "end": 16 + } + ], + "semantic_tags": [ + "mock_prove_feature", + "mock_prove_release_guard" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "Cargo.toml", + "text": "default = [\"mock_prove\"]" + }, + { + "kind": "contains", + "file": "Cargo.toml", + "text": "mock_prove = []" + }, + { + "kind": "not_contains", + "file": "src/lib.rs", + "text": "compile_error!" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-012.json b/artifacts/zktorch/zkTorch-012.json new file mode 100644 index 0000000000000000000000000000000000000000..8297ae19e681d8641981a39c391f4595c1f3b64a --- /dev/null +++ b/artifacts/zktorch/zkTorch-012.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-012", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Mul Verify Quotient Degree Binding Removed", + "explanation": "The first pairing check in MulBasicBlock::verify enforces the polynomial identity f(X)·g(X) − h(X) = Z(X)·t(X) via the pair (-proof.0[0], (srs.X2A[N] − srs.X2A[0]).into()) which binds the quotient polynomial t to the vanishing polynomial Z(X) = X^N − 1. Replacing the second component with srs.X2A[0] removes the Z(X) multiplier so the identity degenerates to f·g − h = t with no divisibility constraint. A malicious prover can submit t(X) := f(X)·g(X) − h(X) (a polynomial always) for any claimed h, so the elementwise product relation is no longer enforced — the verifier accepts arbitrary Hadamard-product outputs.", + "labels": { + "relevant_code": "src/basic_block/mul.rs:919", + "paper_reference": "Section 4.4.2 (Hadamard Product / MulBasicBlock): elementwise product f(ω^i)·g(ω^i) = h(ω^i) for all i ∈ [N] is proved via the quotient identity f·g − h = Z·t; the pairing pair (t(X), Z(X)) is the binding that forces divisibility by the vanishing polynomial." + } + }, + "edits": [ + { + "file": "src/basic_block/mul.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 919, + "end": 919, + "expect_sha256": "0496b15ae0a9ff5cbdaf4828a02683f6f572282ad52765b904afc62098855d4b" + }, + "new_content": " (-proof.0[0], srs.X2A[0])," + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/mul.rs" + ], + "regions": [ + { + "file": "src/basic_block/mul.rs", + "start": 913, + "end": 925 + } + ], + "semantic_tags": [ + "mul_vanishing_poly_binding" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/mul.rs", + "text": "(-proof.0[0], srs.X2A[0])," + }, + { + "kind": "not_contains", + "file": "src/basic_block/mul.rs", + "text": "(-proof.0[0], (srs.X2A[inputs[0].first().unwrap().len] - srs.X2A[0]).into())," + } + ] +} diff --git a/artifacts/zktorch/zkTorch-013.json b/artifacts/zktorch/zkTorch-013.json new file mode 100644 index 0000000000000000000000000000000000000000..8dd00a5e1f40f7b8294a92dfdc376de8e0ff3f7e --- /dev/null +++ b/artifacts/zktorch/zkTorch-013.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-013", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "BoolCheck Verifier Identity Assertion Removed", + "explanation": "BooleanCheckBasicBlock::verify must check at the challenge point ζ that g(ζ)·(1 − g(ζ)) = t(ζ)·Z(ζ), where Z is the vanishing polynomial of the evaluation domain. This is the core algebraic check that every committed value is in {0, 1}. Replacing the assert! at mul.rs-adjacent bool_check.rs:145 with a no-op lets a malicious prover supply arbitrary g_zeta and t_zeta that do not satisfy the bool-check identity — the subsequent pairing checks only verify that the claimed g_zeta, t_zeta are consistent openings of the committed polynomials, not that those polynomials satisfy the boolean relation. Consequence: the prover can commit to a polynomial g whose evaluations at the domain are outside {0, 1}, and the verifier accepts.", + "labels": { + "relevant_code": "src/basic_block/bool_check.rs:145", + "paper_reference": "Section 4.3 (Boolean Check / lookup preamble): a committed polynomial f is in {0,1} on the N-th roots of unity iff f(X)·(1 − f(X)) is divisible by Z(X) = X^N − 1, verified via the identity f(ζ)·(1 − f(ζ)) = t(ζ)·Z(ζ) at a Fiat-Shamir challenge ζ." + } + }, + "edits": [ + { + "file": "src/basic_block/bool_check.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 145, + "end": 145, + "expect_sha256": "fe9e6fd5e5d33f2978ba2147dbf9a94c3f5a40cb0587abb8fbf4a5928171fcb7" + }, + "new_content": " // boolean identity check removed" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/bool_check.rs" + ], + "regions": [ + { + "file": "src/basic_block/bool_check.rs", + "start": 140, + "end": 150 + } + ], + "semantic_tags": [ + "bool_check_identity_assertion" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/bool_check.rs", + "text": "// boolean identity check removed" + }, + { + "kind": "not_contains", + "file": "src/basic_block/bool_check.rs", + "text": "assert!(g_zeta * (Fr::one() - g_zeta) == t_zeta * vanishing_poly_z);" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-014.json b/artifacts/zktorch/zkTorch-014.json new file mode 100644 index 0000000000000000000000000000000000000000..d6242e61263f7d432758bc7d4497824930141639 --- /dev/null +++ b/artifacts/zktorch/zkTorch-014.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-014", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "Sub Verifier Difference Assertion Removed", + "explanation": "SubBasicBlock::verify contains a single soundness-critical line that asserts the output commitment equals the difference of the input commitments: assert!(a.g1 - b.g1 == c.g1). This is the only check the verifier performs for the subtraction operator (verify returns vec![] with no pairing checks). Replacing the assert with a no-op turns verify into a true stub: the prover can supply an arbitrary G1 element as the output commitment for any subtraction node, and the verifier accepts it. Any downstream consumer of the (allegedly-subtracted) output will see attacker-chosen tensor values pass through.", + "labels": { + "relevant_code": "src/basic_block/sub.rs:52", + "paper_reference": "Section 4.4.2 (Linear Operators / Add and Sub): linear-combination basic blocks are verified by directly comparing the output commitment to the prover-claimed linear combination of input commitments — c.g1 == a.g1 ± b.g1 — because the homomorphic KZG structure makes the relation a single-equation pairing-free check." + } + }, + "edits": [ + { + "file": "src/basic_block/sub.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 52, + "end": 52, + "expect_sha256": "73bbd5ed45c92e041b2b771c0e48cabd3a68e4f03b28434149d88f9b0a7db919" + }, + "new_content": " // sub difference check removed" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/sub.rs" + ], + "regions": [ + { + "file": "src/basic_block/sub.rs", + "start": 47, + "end": 55 + } + ], + "semantic_tags": [ + "sub_verify_assertion" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/sub.rs", + "text": "// sub difference check removed" + }, + { + "kind": "not_contains", + "file": "src/basic_block/sub.rs", + "text": "assert!(a.g1 - b.g1 == c.g1);" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-015.json b/artifacts/zktorch/zkTorch-015.json new file mode 100644 index 0000000000000000000000000000000000000000..79501ebcd39a8ce47670691c77355e83adca3455 --- /dev/null +++ b/artifacts/zktorch/zkTorch-015.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-015", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "CQ Lookup Table Commitment Binding Removed", + "explanation": "CQBasicBlock::verify (non-fold path) computes seven pairing checks. The second check at cq.rs:814 — vec![(model.first().unwrap().g1, srs.X2A[0]), (srs.X1A[0], -T_x_2)] — enforces that T_x_2, the prover-supplied G2 commitment to the lookup table polynomial, equals the G2-side projection of the model's G1 commitment (i.e., binds T_x_2 to the public model). Removing this single pairing check leaves T_x_2 entirely prover-controlled while it continues to appear in the first check (line 807, A_x · T_x_2 pairing) that proves A(x) corresponds to lookups m_i / (t_i + β) over T. With T uncommitted, a malicious prover substitutes a custom table containing any desired entries, and every lookup inside it passes — defeating the range/membership semantics CQ is meant to enforce.", + "labels": { + "relevant_code": "src/basic_block/cq.rs:814", + "paper_reference": "Section 4.5 (CQ Lookups): the lookup table T is part of the public statement (committed at setup time as part of the model). The verifier must enforce that the G2 representation T_x_2 used in pairing checks corresponds to the committed model — otherwise the lookup degree-N polynomial T can be replaced by any prover-chosen polynomial of the same degree." + } + }, + "edits": [ + { + "file": "src/basic_block/cq.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 814, + "end": 814, + "expect_sha256": "8f9c2a34cb8ede616994fe16d3098ab1a74a3597db8edf6a5a0b9ddc37639e1c" + }, + "new_content": " // T_x_2 binding to model commitment removed" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/cq.rs" + ], + "regions": [ + { + "file": "src/basic_block/cq.rs", + "start": 810, + "end": 818 + } + ], + "semantic_tags": [ + "cq_table_commitment_binding" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/cq.rs", + "text": "// T_x_2 binding to model commitment removed" + }, + { + "kind": "not_contains", + "file": "src/basic_block/cq.rs", + "text": "checks.push(vec![(model.first().unwrap().g1, srs.X2A[0]), (srs.X1A[0], -T_x_2)]);" + } + ] +} diff --git a/artifacts/zktorch/zkTorch-016.json b/artifacts/zktorch/zkTorch-016.json new file mode 100644 index 0000000000000000000000000000000000000000..dc6086c8199f3a126e1ae7144c56b26d45024812 --- /dev/null +++ b/artifacts/zktorch/zkTorch-016.json @@ -0,0 +1,55 @@ +{ + "artifact_id": "zkTorch-016", + "codebase": "zk-torch-fixed", + "source": "synthetic", + "finding": { + "name": "BatchAdd Verification Assertion Removed", + "explanation": "The BatchAdd layer's verify function checks that the sum of all input commitments equals the output commitment via assert!(inputs_g1 == c_g1). Removing this assertion leaves the addition operation completely unconstrained: a malicious prover can commit to any output regardless of whether it actually sums the inputs, and the verifier will accept.", + "labels": { + "relevant_code": "src/basic_block/add.rs:96", + "paper_reference": "Section 4.4 (Arithmetic layers): the verifier checks each layer's commitment relation; for addition, the output commitment must equal the sum of input commitments." + } + }, + "edits": [ + { + "file": "src/basic_block/add.rs", + "op": "replace_block", + "anchor": { + "kind": "line_range", + "start": 96, + "end": 96, + "expect_sha256": "04fb44f97ebe5b1d6fc7645f2f87ce916deb9139faa534a2068ee057ea16d131" + }, + "new_content": " // assert!(inputs_g1 == c_g1);" + } + ], + "conflict_keys": { + "files": [ + "src/basic_block/add.rs" + ], + "regions": [ + { + "file": "src/basic_block/add.rs", + "start": 93, + "end": 99 + } + ], + "semantic_tags": [ + "batchadd_verification_assertion" + ], + "requires": [], + "incompatible": [] + }, + "presence_probes": [ + { + "kind": "contains", + "file": "src/basic_block/add.rs", + "text": "// assert!(inputs_g1 == c_g1);" + }, + { + "kind": "not_contains", + "file": "src/basic_block/add.rs", + "text": " assert!(inputs_g1 == c_g1);" + } + ] +} diff --git a/codebases/zkgpt.zip b/codebases/zkgpt.zip new file mode 100644 index 0000000000000000000000000000000000000000..f750b5dca649a1719b2a0a9848b37f3c32c3a6a5 --- /dev/null +++ b/codebases/zkgpt.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d5c4fbd8a4825054bcc8be46590bcdc8a201406735a72004b944fadd933198e +size 674679 diff --git a/codebases/zkllm.zip b/codebases/zkllm.zip new file mode 100644 index 0000000000000000000000000000000000000000..f48f2b06943876567b0d6d09e3a6c79562578540 --- /dev/null +++ b/codebases/zkllm.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8979bdf169bd6125257b721c968cc4fffc1feb521656880a85c09cbad9cce78 +size 262872 diff --git a/codebases/zkml.zip b/codebases/zkml.zip new file mode 100644 index 0000000000000000000000000000000000000000..9b25624705c6719f19c1535e47ce7de067f60e03 --- /dev/null +++ b/codebases/zkml.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d872d402c164bba79e99fa47aadea827268a1f5754c1c550efcbe70ee9c48c51 +size 27915998 diff --git a/codebases/zktorch.zip b/codebases/zktorch.zip new file mode 100644 index 0000000000000000000000000000000000000000..29a8870c72b1e82775c93dab9e06eb1d76711772 --- /dev/null +++ b/codebases/zktorch.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7e8036d7598d80bdfa34da00bac0ba01e1f6e5f7e9437b021fd13925d2a0e26 +size 259897 diff --git a/croissant.json b/croissant.json new file mode 100644 index 0000000000000000000000000000000000000000..3f198eca64536610253416cc133febb7aaaaf4e8 --- /dev/null +++ b/croissant.json @@ -0,0 +1,562 @@ +{ + "@context": { + "@language": "en", + "@vocab": "https://schema.org/", + "citeAs": "cr:citeAs", + "column": "cr:column", + "conformsTo": "dct:conformsTo", + "cr": "http://mlcommons.org/croissant/", + "rai": "http://mlcommons.org/croissant/RAI/", + "data": { + "@id": "cr:data", + "@type": "@json" + }, + "dataType": { + "@id": "cr:dataType", + "@type": "@vocab" + }, + "dct": "http://purl.org/dc/terms/", + "examples": { + "@id": "cr:examples", + "@type": "@json" + }, + "extract": "cr:extract", + "field": "cr:field", + "fileProperty": "cr:fileProperty", + "fileObject": "cr:fileObject", + "fileSet": "cr:fileSet", + "format": "cr:format", + "includes": "cr:includes", + "isLiveDataset": "cr:isLiveDataset", + "jsonPath": "cr:jsonPath", + "key": "cr:key", + "md5": "cr:md5", + "parentField": "cr:parentField", + "path": "cr:path", + "recordSet": "cr:recordSet", + "references": "cr:references", + "regex": "cr:regex", + "repeated": "cr:repeated", + "replace": "cr:replace", + "sc": "https://schema.org/", + "separator": "cr:separator", + "source": "cr:source", + "subField": "cr:subField", + "transform": "cr:transform", + "samplingRate": "cr:samplingRate", + "equivalentProperty": "cr:equivalentProperty" + }, + "@type": "sc:Dataset", + "conformsTo": "http://mlcommons.org/croissant/1.1", + "name": "zkml-audit-benchmark", + "description": "A benchmark dataset for evaluating AI agents on zkML soundness auditing: finding cryptographic vulnerabilities in zero-knowledge machine learning proof implementations. The dataset pairs 4 published zkML research papers with their corresponding frozen codebase snapshots and 56 bug artifacts (20 real-world from expert audits + 36 synthetic for broader coverage).", + "url": "https://huggingface.co/datasets/Anonymous648/zkml-audit-benchmark", + "license": "https://spdx.org/licenses/CC-BY-4.0.html", + "version": "1.2.2", + "datePublished": "2026-04-22", + "dateModified": "2026-05-01", + "keywords": [ + "zero-knowledge", + "zkml", + "benchmarking", + "soundness", + "cryptography", + "auditing", + "security" + ], + "inLanguage": "en", + "creator": { + "@type": "sc:Organization", + "name": "Anonymous", + "description": "Anonymized for NeurIPS 2026 submission" + }, + "maintainer": { + "@type": "sc:Organization", + "name": "Anonymous", + "description": "Anonymized for NeurIPS 2026 submission" + }, + "citation": "@misc{zkml-audit-benchmark, title={zkml-audit-benchmark: A Benchmark for AI Agents on zkML Soundness Auditing}, author={Anonymous}, year={2026}, url={https://huggingface.co/datasets/Anonymous648/zkml-audit-benchmark}}", + "citeAs": "@misc{zkml-audit-benchmark, title={zkml-audit-benchmark: A Benchmark for AI Agents on zkML Soundness Auditing}, author={Anonymous}, year={2026}, url={https://huggingface.co/datasets/Anonymous648/zkml-audit-benchmark}}", + + "rai:dataLimitations": "1. Coverage is limited to 4 of 10 candidate zkML papers — those with paired open-source codebases and authored artifacts. 2. The zktorch codebase is a directory snapshot (2026-04-19) without an upstream commit hash. 3. Paper PDFs are bundled for reproducibility but carry their respective publisher terms (ACM, USENIX, arXiv); CC-BY-4.0 covers only the curation layer. 4. Artifacts follow a fixed JSON schema (artifact.v2.schema.json); graded labels are limited to relevant_code and paper_reference fields. 5. Coverage is concentrated on inference-time soundness; the dataset does not include artifacts for ZK proofs of training, FRI-based STARKs, or floating-point native ZK protocols. 6. The dataset should not be used to automatically generate exploits against deployed ZK production systems or make blanket security claims about upstream projects without consulting their authors.", + + "rai:dataBiases": "The sample is deliberate, not random. It is biased toward (a) frameworks targeting transformer/LLM inference, and (b) papers with publicly archived reference implementations. Coverage is concentrated on Rust and CUDA/C++ implementations using Halo2, Arkworks, BLS12-381, and Lasso frameworks. The dataset over-represents ML-layer soundness bugs and does not include privacy-circuit, recursive-proof, or governance-related vulnerabilities. 20 of 56 artifacts are derived from real audit reports; the remaining 36 are synthetic, which may introduce authoring bias. Per-issue difficulty is highly heterogeneous; pooled recall metrics can be misleading.", + + "rai:personalSensitiveInformation": "The dataset does not contain personal or sensitive information. It comprises research papers (publicly published), source code (open-source releases), and synthetic bug records. It does not contain user-generated content, human subjects data, or any demographic, health, financial, or behavioral information.", + + "rai:dataUseCases": "Primary use cases with established construct validity: (1) Zero-shot evaluation of AI auditing agents on (paper, codebase) pairs for soundness-gap detection. (2) Controlled difficulty studies via artifact-composition workflow (sampling k artifacts and measuring detection degradation). (3) Reproducible regression testing for zkML implementation maintainers. (4) Education and training material for auditors learning to identify soundness gaps. (5) Studying alignment between cryptographic protocol specifications and software implementations. Use cases without established validity: general-purpose code security evaluation, exploit generation, production security assessment.", + + "rai:dataSocialImpact": "Positive: Enables systematic measurement and improvement of automated ZK proof auditing tools, contributing to safer deployment of zero-knowledge cryptographic systems in production. Negative risks: The dataset documents specific vulnerability patterns in zkML implementations; in principle this could help adversaries understand common implementation gaps, though all vulnerabilities are in frozen academic snapshots (not live deployments) and the upstream projects continue to evolve. Mitigation: Artifacts are tied to frozen snapshots, and the dataset explicitly discourages use for exploit generation against non-consenting deployed systems.", + + "rai:dataCollection": "Paper PDFs downloaded from publishers and arXiv canonical URLs (2024-2025). Codebases obtained from authors' public release artifacts: zkLLM from GitHub (commit 993311e), ZKML from GitHub (commit 4378958), zkGPT from Zenodo record 14727819 v1, zkTorch from author-provided directory snapshot (2026-04-19). Codebase snapshots created by git archive or directory zipping at fixed dates. Geographic scope: publicly available international academic publications. Collection period: 2025-2026. No instruments or sensors; all data is publicly published research artifacts.", + + "rai:dataAnnotationProtocol": "Each bug artifact was authored by hand by dataset maintainers following schema/artifact.v2.schema.json. Real artifacts (20) were derived from manual audit reports; synthetic artifacts (36) were authored for broader coverage. Labeling schema: finding.labels contains relevant_code (file:line references) and paper_reference (section/theorem citation). Quality control: (1) JSON-schema conformance validation, (2) presence-probe execution after applying edits to the clean codebase, (3) byte-exact integrity checks via verify_dataset.py against MANIFEST.json. Single annotator per artifact; no inter-annotator agreement applicable.", + + "rai:hasSyntheticData": true, + + "prov:wasDerivedFrom": [ + { + "@type": "sc:Dataset", + "name": "zkLLM source code", + "url": "https://github.com/jvhs0706/zkllm-ccs2024", + "description": "Commit 993311ea8e2346b90efacb35337b2e3cfe0d6f8d" + }, + { + "@type": "sc:Dataset", + "name": "ZKML source code", + "url": "https://github.com/ddkang/zkml", + "description": "Commit 4378958 (Aug 2023)" + }, + { + "@type": "sc:Dataset", + "name": "zkGPT source code", + "url": "https://zenodo.org/records/14727819", + "description": "Zenodo record 14727819 v1 (Jan 2025)" + }, + { + "@type": "sc:Dataset", + "name": "zkTorch source code", + "description": "Directory snapshot taken 2026-04-19; no public Git repository found" + } + ], + + "prov:wasGeneratedBy": [ + { + "@type": "prov:Activity", + "name": "Collection", + "description": "Paper PDFs downloaded from publishers and arXiv canonical URLs (2024-2025). Codebases obtained from authors' public release artifacts: zkLLM from GitHub (commit 993311e), ZKML from GitHub (commit 4378958), zkGPT from Zenodo record 14727819 v1, zkTorch from author-provided directory snapshot (2026-04-19). Codebase snapshots created by git archive (where Git history was available) or by zipping a working directory at a fixed date. Human team: dataset maintainers only; no crowdworkers or external contractors." + }, + { + "@type": "prov:Activity", + "name": "Preprocessing", + "description": "Codebase snapshotting: working directories captured at a fixed date, then ZIP-archived. A small number of pre-existing bugs in clean codebases were corrected to establish a clean baseline: pow(1,-8) to pow(2,-8) in zkGPT softmax, FFN-output rescaling in zkLLM, epsilon in zkTorch BatchNorm, near-zero guard in zkTorch onnx.rs. All corrections documented in CHANGELOG.md. Parquet flattening: scripts/build_parquet.py flattens nested artifact JSONs into row-oriented Parquet tables. MANIFEST.json regenerated with SHA-256 checksums for all files." + }, + { + "@type": "prov:Activity", + "name": "Annotation", + "description": "Real artifacts (20 of 56): derived from manual audit reports of the source frameworks. Each report identifies a soundness gap; the corresponding artifact encodes the minimal code edit that re-introduces the gap on a clean codebase, plus labels and probes for grading. Synthetic artifacts (36 of 56): authored by maintainers to broaden vulnerability coverage following the same JSON schema. Labeling schema: each artifact carries finding.labels with relevant_code (file:line references) and paper_reference (section/theorem citation). Quality control: JSON-schema conformance against artifact.v2.schema.json, presence-probe execution after applying edits, byte-exact integrity via verify_dataset.py against MANIFEST.json. Human team: dataset maintainers performed all annotation; no inter-annotator agreement applicable (single-annotator per artifact)." + } + ], + + "distribution": [ + { + "@type": "cr:FileObject", + "@id": "hf-repo", + "name": "hf-repo", + "contentUrl": "https://huggingface.co/datasets/Anonymous648/zkml-audit-benchmark/tree/main", + "encodingFormat": "git+https", + "sha256": "https://github.com/mlcommons/croissant/issues/80" + }, + { + "@type": "cr:FileObject", + "@id": "artifacts-parquet", + "name": "artifacts.parquet", + "contentUrl": "data/artifacts.parquet", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/x-parquet", + "sha256": "c746590192794320019a11201332deb576a6070346088c6004c882ca335af368" + }, + { + "@type": "cr:FileObject", + "@id": "pairs-parquet", + "name": "pairs.parquet", + "contentUrl": "data/pairs.parquet", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/x-parquet", + "sha256": "b7e42d2154d4acc6f769b59f1b763e7db8be1212e3182a989cd8d6a37ad8486e" + }, + { + "@type": "cr:FileObject", + "@id": "baseline-findings", + "name": "baseline_findings.json", + "contentUrl": "data/baseline_findings.json", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/json", + "sha256": "631eb9a6234cd20fb0b90daf9b0edbe1e3fc20b1d99b0792b8d1898c5ba9febe" + }, + { + "@type": "cr:FileObject", + "@id": "zkgpt-zip", + "name": "zkgpt.zip", + "contentUrl": "codebases/zkgpt.zip", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/zip", + "sha256": "7d5c4fbd8a4825054bcc8be46590bcdc8a201406735a72004b944fadd933198e" + }, + { + "@type": "cr:FileObject", + "@id": "zkllm-zip", + "name": "zkllm.zip", + "contentUrl": "codebases/zkllm.zip", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/zip", + "sha256": "e8979bdf169bd6125257b721c968cc4fffc1feb521656880a85c09cbad9cce78" + }, + { + "@type": "cr:FileObject", + "@id": "zkml-zip", + "name": "zkml.zip", + "contentUrl": "codebases/zkml.zip", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/zip", + "sha256": "d872d402c164bba79e99fa47aadea827268a1f5754c1c550efcbe70ee9c48c51" + }, + { + "@type": "cr:FileObject", + "@id": "zktorch-zip", + "name": "zktorch.zip", + "contentUrl": "codebases/zktorch.zip", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/zip", + "sha256": "a7e8036d7598d80bdfa34da00bac0ba01e1f6e5f7e9437b021fd13925d2a0e26" + }, + { + "@type": "cr:FileObject", + "@id": "zkgpt-pdf", + "name": "zkgpt.pdf", + "contentUrl": "papers/zkgpt.pdf", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/pdf", + "sha256": "2acc64d6b27eaed48cd4895aaec1b5cca8acc7473e7ff8015c041c98b9b35ff2" + }, + { + "@type": "cr:FileObject", + "@id": "zkllm-pdf", + "name": "zkllm.pdf", + "contentUrl": "papers/zkllm.pdf", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/pdf", + "sha256": "39f2a2f29457072573574c21ca9da7e0bbca756bf7031dd877f3c366f1e2ad7d" + }, + { + "@type": "cr:FileObject", + "@id": "zkml-pdf", + "name": "zkml.pdf", + "contentUrl": "papers/zkml.pdf", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/pdf", + "sha256": "ac7b5e3fb44bafc445e0506cda8d4696ed2d8733bebe6d599897274d57740295" + }, + { + "@type": "cr:FileObject", + "@id": "zktorch-pdf", + "name": "zktorch.pdf", + "contentUrl": "papers/zktorch.pdf", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/pdf", + "sha256": "2fa9225c84c7905fe21d41a25971cc515aaf23c24623cf11fa179232303b35f7" + }, + { + "@type": "cr:FileSet", + "@id": "artifact-jsons", + "name": "Artifact JSON files", + "description": "Full artifact JSON files with edit instructions, conflict metadata, and presence probes", + "containedIn": { "@id": "hf-repo" }, + "includes": "artifacts/*/*.json", + "encodingFormat": "application/json" + }, + { + "@type": "cr:FileObject", + "@id": "artifact-schema", + "name": "artifact.v2.schema.json", + "contentUrl": "schema/artifact.v2.schema.json", + "containedIn": { "@id": "hf-repo" }, + "encodingFormat": "application/schema+json", + "sha256": "2b34e05c1666982763503e00859baa2db08af23814c7e4f778415ee5c2f50085" + } + ], + + "recordSet": [ + { + "@type": "cr:RecordSet", + "@id": "pairs", + "name": "pairs", + "description": "One row per (paper, codebase) pair. Contains metadata about the paper, codebase, and artifact counts.", + "field": [ + { + "@type": "cr:Field", + "@id": "pairs/pair_id", + "name": "pair_id", + "description": "Primary key: zkllm, zkml, zktorch, zkgpt", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "pair_id" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_title", + "name": "paper_title", + "description": "Full paper title", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_title" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_venue", + "name": "paper_venue", + "description": "Publication venue", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_venue" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_year", + "name": "paper_year", + "description": "Publication year", + "dataType": "sc:Integer", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_year" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_license", + "name": "paper_license", + "description": "Paper redistribution terms", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_license" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_url", + "name": "paper_url", + "description": "arXiv or publisher URL", + "dataType": "sc:URL", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_url" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_path", + "name": "paper_path", + "description": "Relative path to PDF: papers/{pair_id}.pdf", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_path" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/paper_sha256", + "name": "paper_sha256", + "description": "SHA-256 hash of the PDF", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "paper_sha256" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/codebase_path", + "name": "codebase_path", + "description": "Relative path to zip: codebases/{pair_id}.zip", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "codebase_path" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/codebase_dir", + "name": "codebase_dir", + "description": "Directory name after extraction", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "codebase_dir" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/codebase_sha256", + "name": "codebase_sha256", + "description": "SHA-256 hash of the zip", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "codebase_sha256" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/codebase_language", + "name": "codebase_language", + "description": "Primary implementation language", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "codebase_language" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/codebase_snapshot_note", + "name": "codebase_snapshot_note", + "description": "Commit hash or snapshot date", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "codebase_snapshot_note" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/artifact_count", + "name": "artifact_count", + "description": "Number of artifacts targeting this pair", + "dataType": "sc:Integer", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "artifact_count" } + } + }, + { + "@type": "cr:Field", + "@id": "pairs/notes", + "name": "notes", + "description": "Caveats or special build instructions", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "pairs-parquet" }, + "extract": { "column": "notes" } + } + } + ] + }, + { + "@type": "cr:RecordSet", + "@id": "artifacts", + "name": "artifacts", + "description": "One row per bug artifact. Contains flattened metadata for filtering and loading; full artifact JSONs with edit/probe structures are in artifacts/{pair_id}/.", + "field": [ + { + "@type": "cr:Field", + "@id": "artifacts/artifact_id", + "name": "artifact_id", + "description": "Primary key, e.g. zkLLM-001", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "artifact_id" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/pair_id", + "name": "pair_id", + "description": "Foreign key to pairs table", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "pair_id" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/source", + "name": "source", + "description": "real (from audit) or synthetic (authored for coverage)", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "source" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/finding_name", + "name": "finding_name", + "description": "Short vulnerability title", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "finding_name" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/finding_explanation", + "name": "finding_explanation", + "description": "Root cause and impact explanation", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "finding_explanation" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/relevant_code", + "name": "relevant_code", + "description": "Comma-separated file:line[-line] references", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "relevant_code" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/paper_reference", + "name": "paper_reference", + "description": "Section/theorem/protocol citation", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "paper_reference" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/edit_count", + "name": "edit_count", + "description": "Number of code edits to inject this bug", + "dataType": "sc:Integer", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "edit_count" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/artifact_path", + "name": "artifact_path", + "description": "Relative path to full artifact JSON", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "artifact_path" } + } + }, + { + "@type": "cr:Field", + "@id": "artifacts/artifact_sha256", + "name": "artifact_sha256", + "description": "SHA-256 hash of the artifact JSON", + "dataType": "sc:Text", + "source": { + "fileObject": { "@id": "artifacts-parquet" }, + "extract": { "column": "artifact_sha256" } + } + } + ] + } + ] +} diff --git a/data/artifacts.parquet b/data/artifacts.parquet new file mode 100644 index 0000000000000000000000000000000000000000..ddd4fcdcfb1e8f36e11c3db038b04c45f370619b Binary files /dev/null and b/data/artifacts.parquet differ diff --git a/data/baseline_findings.json b/data/baseline_findings.json new file mode 100644 index 0000000000000000000000000000000000000000..129b9847fdf83dc28ffd4e36af839c4e9eed0b81 --- /dev/null +++ b/data/baseline_findings.json @@ -0,0 +1,72 @@ +[ + { + "entry-id": "zkgpt", + "issue-name": "Deterministic Placeholder Model Weights", + "issue-explanation": "The readFconWeight() function generates synthetic weights using (co*channel_in+ci)%1024 instead of loading trained model parameters from the CSV file. Proofs attest to inference on deterministic placeholder data, not a real trained model.", + "relevant-code": "neuralNetwork.cpp:1528-1555", + "paper-reference": "Section 3: the protocol assumes a fixed, committed neural network model with real trained weights." + }, + { + "entry-id": "zkgpt", + "issue-name": "Fiat-Shamir Not Implemented", + "issue-explanation": "Verifier challenges are generated using setByCSPRNG() (fresh entropy) instead of being derived from the proof transcript via a hash function. The protocol is interactive rather than non-interactive, preventing offline verification.", + "relevant-code": "verifier.cpp:469, verifier.cpp:504, verifier.cpp:524", + "paper-reference": "Section 4: the non-interactive proof protocol requires Fiat-Shamir heuristic to derive challenges deterministically from commitments." + }, + { + "entry-id": "zkllm", + "issue-name": "Attention Output Projection W^O Unproved", + "issue-explanation": "The attention output is computed as Y @ V (raw attention heads) without the W^O output projection matrix. W^O is committed in llama-commit.py but never loaded or proved in self-attn.cu. The circuit proves softmax(QK^T)V but omits the final linear transformation required by the transformer architecture.", + "relevant-code": "self-attn.cu:140-173, llama-commit.py:30-42", + "paper-reference": "Section 4.1: self-attention computes Attn_out = softmax(QK^T/sqrt(d))V * W_O, with W_O committed and proved." + }, + { + "entry-id": "zkllm", + "issue-name": "RoPE Applied Outside ZK Circuit", + "issue-explanation": "Rotary Position Embeddings are applied in Python (llama-self-attn.py:48-51) between the linear and attention proof stages. Commitments are on pre-RoPE Q,K from the linear stage, but the attention proof operates on post-RoPE Q,K. No proof links pre-RoPE to post-RoPE values, allowing an adversary to substitute arbitrary Q',K'.", + "relevant-code": "llama-self-attn.py:48-51, self-attn.cu:139-140", + "paper-reference": "Section 4.1: Q and K include rotary position embeddings as part of the proved computation." + }, + { + "entry-id": "zkllm", + "issue-name": "Embedding and Unembedding Layers Not Proved", + "issue-explanation": "The proof pipeline covers RMSNorm, self-attention, FFN, and skip connections, but has no proof stage for the embedding layer (token → hidden) or the lm_head/unembedding layer (hidden → logits). Both weights are committed in llama-commit.py but no corresponding proof files exist.", + "relevant-code": "llama-commit.py:48-62", + "paper-reference": "Section 3: the end-to-end inference proof covers all layers from input tokens to output logits." + }, + { + "entry-id": "zkllm", + "issue-name": "ReLU Prove Function Not Implemented", + "issue-explanation": "zkReLU::prove() throws std::runtime_error with a message that it is not implemented. The LLaMA pipeline uses SwiGLU/SiLU (not ReLU), so this stub is not triggered in normal operation, but any model requiring ReLU proofs would fail.", + "relevant-code": "zkrelu.cu:57-89", + "paper-reference": "Section 5: non-linear activation functions are proved via lookup arguments." + }, + { + "entry-id": "zkllm", + "issue-name": "Sumcheck Transcripts Discarded In Memory", + "issue-explanation": "Sumcheck proofs for self-attention, FFN, and RMSNorm stages are computed in-memory but not persisted to disk. The verifier only checks cross-stage commitment binding (via the checksum chain) but cannot replay individual stage sumchecks. Only the skip-connection stage has full per-challenge opening verification.", + "relevant-code": "main.cu:31-35, stage_proof.cuh:37-38", + "paper-reference": "Section 4: each stage produces a sumcheck proof that the verifier replays independently." + }, + { + "entry-id": "zktorch", + "issue-name": "Non-Fold Verifier Uses Entropy-Based Randomness", + "issue-explanation": "In non-fold mode, the verifier's combine_pairing_checks() generates gamma via StdRng::from_entropy() instead of deriving it deterministically from the proof transcript (Fiat-Shamir). The fold mode correctly uses Keccak256 over proof pairings. The non-fold path breaks verification reproducibility and soundness.", + "relevant-code": "src/util/verifier.rs:37-41", + "paper-reference": "Section 3: verifier challenges are derived via Fiat-Shamir heuristic from the proof transcript." + }, + { + "entry-id": "zktorch", + "issue-name": "Debug Mode Skips Public Statement Verification", + "issue-explanation": "When compiled in debug mode, the verifier skips public statement path binding — it loads the statement from the prover's path (CONFIG.prover.public_statement_path) instead of the verifier's own path (CONFIG.verifier.public_statement_path), and may skip digest checks entirely.", + "relevant-code": "src/util/verifier.rs:244-257", + "paper-reference": "Section 3: the verifier independently loads and verifies the public statement against the proof." + }, + { + "entry-id": "zktorch", + "issue-name": "Weight Values Clamped to 15-Bit Range", + "issue-explanation": "All F32 model weights are clamped to [-32768, 32768] (15-bit signed range) after scaling, regardless of the scale factor configuration. The clamp is hardcoded with no configuration parameter and no constraint verifying weights were within range before clamping. Increasing scale_factor_log increases the risk of silent truncation.", + "relevant-code": "src/onnx.rs:78-79", + "paper-reference": "Section 2: model parameters are quantized and committed faithfully to the ZK circuit." + } +] diff --git a/data/pairs.parquet b/data/pairs.parquet new file mode 100644 index 0000000000000000000000000000000000000000..95e153665a0c0a7785995838b4c8c56b90254f12 Binary files /dev/null and b/data/pairs.parquet differ diff --git a/papers/zkgpt.pdf b/papers/zkgpt.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4f2f1be2de7c6f7b10adbd387e88edd82ecc49c8 --- /dev/null +++ b/papers/zkgpt.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2acc64d6b27eaed48cd4895aaec1b5cca8acc7473e7ff8015c041c98b9b35ff2 +size 561267 diff --git a/papers/zkllm.pdf b/papers/zkllm.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0490fd2b0e5da2c8167bbb48913028d44bd56fcf --- /dev/null +++ b/papers/zkllm.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39f2a2f29457072573574c21ca9da7e0bbca756bf7031dd877f3c366f1e2ad7d +size 1116955 diff --git a/papers/zkml.pdf b/papers/zkml.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a7c6cab1ef485e2dabd518156bd64308f08297fa --- /dev/null +++ b/papers/zkml.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac7b5e3fb44bafc445e0506cda8d4696ed2d8733bebe6d599897274d57740295 +size 973543 diff --git a/papers/zktorch.pdf b/papers/zktorch.pdf new file mode 100644 index 0000000000000000000000000000000000000000..cd2caae234744483d2cedd8fc70af5eb183c61b2 --- /dev/null +++ b/papers/zktorch.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2fa9225c84c7905fe21d41a25971cc515aaf23c24623cf11fa179232303b35f7 +size 860413 diff --git a/schema/artifact.v2.schema.json b/schema/artifact.v2.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..7f234e88278c1c1325a977676cc3ac2f832c3037 --- /dev/null +++ b/schema/artifact.v2.schema.json @@ -0,0 +1,269 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://zkpdb.local/schemas/artifact.v2.schema.json", + "title": "CTF Bug Artifact (v2)", + "description": "Schema for a single declarative bug artifact.", + "type": "object", + "required": [ + "artifact_id", + "codebase", + "source", + "finding", + "edits", + "conflict_keys", + "presence_probes" + ], + "additionalProperties": false, + "properties": { + "artifact_id": { + "type": "string", + "pattern": "^(zkML|zkTorch|zkLLM|zkGPT)-\\d{3}$", + "description": "Unique ID. Prefix encodes codebase: zkML, zkTorch, zkLLM, zkGPT." + }, + "codebase": { + "type": "string", + "enum": ["zkml-fixed", "zk-torch-fixed", "zkllm-ccs2024-fixed", "zkTransformer-main-fixed"], + "description": "Target codebase directory name under Codebases/." + }, + "source": { + "type": "string", + "enum": ["real", "synthetic"], + "description": "Whether this artifact is derived from a real audit finding or synthetically authored." + }, + "finding": { + "type": "object", + "required": ["name", "explanation", "labels"], + "additionalProperties": false, + "description": "Ground-truth finding for benchmark scoring.", + "properties": { + "name": { + "type": "string", + "minLength": 5, + "maxLength": 120, + "description": "Human-readable short name of the bug (3-7 words)." + }, + "explanation": { + "type": "string", + "minLength": 20, + "description": "One paragraph describing root cause and impact." + }, + "labels": { + "type": "object", + "required": ["relevant_code", "paper_reference"], + "additionalProperties": false, + "description": "Grader-aligned labels for benchmark scoring.", + "properties": { + "relevant_code": { + "type": "string", + "description": "Comma-separated file:line references (e.g., 'src/model.rs:210, src/gadgets/var_div.rs:62-82'). Empty string if no specific code location." + }, + "paper_reference": { + "type": "string", + "description": "Section/theorem/protocol citation from the paper with optional quoted claim, or '-' if none applies." + } + } + } + } + }, + "edits": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/edit" }, + "description": "Ordered list of code edits to inject this bug." + }, + "conflict_keys": { + "type": "object", + "required": ["files", "regions", "semantic_tags"], + "additionalProperties": false, + "properties": { + "files": { + "type": "array", + "items": { "type": "string" }, + "description": "All files touched by this artifact's edits." + }, + "regions": { + "type": "array", + "items": { "$ref": "#/$defs/region" }, + "description": "Expanded line-range regions for overlap detection." + }, + "semantic_tags": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true, + "description": "Semantic labels; two artifacts sharing a tag conflict." + }, + "requires": { + "type": "array", + "items": { "type": "string", "pattern": "^(zkML|zkTorch|zkLLM|zkGPT)-\\d{3}$" }, + "description": "Artifact IDs this artifact depends on (applied first)." + }, + "incompatible": { + "type": "array", + "items": { "type": "string", "pattern": "^(zkML|zkTorch|zkLLM|zkGPT)-\\d{3}$" }, + "description": "Artifact IDs explicitly incompatible with this one." + } + } + }, + "presence_probes": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/probe" }, + "description": "Assertions to verify the bug was correctly injected." + }, + "changelog": { + "type": "array", + "items": { + "type": "object", + "required": ["date", "reason"], + "properties": { + "date": { "type": "string", "format": "date" }, + "reason": { "type": "string" }, + "prev_sha256": { "type": "string" } + } + }, + "description": "Optional log of updates when the -fixed codebase drifts." + } + }, + "$defs": { + "edit": { + "type": "object", + "required": ["file", "op", "anchor"], + "properties": { + "file": { + "type": "string", + "description": "Path relative to the codebase root." + }, + "op": { + "type": "string", + "enum": [ + "replace_block", + "insert_after", + "insert_before", + "delete_block", + "replace_regex", + "create_file" + ] + }, + "anchor": { "$ref": "#/$defs/anchor" }, + "new_content": { + "type": "string", + "description": "Verbatim replacement/insertion text (not used for delete_block)." + }, + "regex_pattern": { + "type": "string", + "description": "Only for op=replace_regex. The regex to match." + }, + "expected_match_count": { + "type": "integer", + "minimum": 1, + "description": "Only for op=replace_regex. Expected number of matches." + } + }, + "allOf": [ + { + "if": { "properties": { "op": { "enum": ["replace_block", "insert_after", "insert_before", "create_file"] } } }, + "then": { "required": ["new_content"] } + }, + { + "if": { "properties": { "op": { "const": "replace_regex" } } }, + "then": { "required": ["regex_pattern", "new_content"] } + } + ] + }, + "anchor": { + "type": "object", + "required": ["kind"], + "properties": { + "kind": { + "type": "string", + "enum": ["line_range", "unique_string", "regex", "symbol"] + }, + "start": { + "type": "integer", + "minimum": 1, + "description": "Start line (1-based). Used with kind=line_range." + }, + "end": { + "type": "integer", + "minimum": 1, + "description": "End line (1-based, inclusive). Used with kind=line_range." + }, + "expect_sha256": { + "type": "string", + "pattern": "^[a-f0-9]{64}$", + "description": "SHA-256 of the line content in the clean codebase." + }, + "text": { + "type": "string", + "description": "Used with kind=unique_string. Must match exactly once in the file." + }, + "pattern": { + "type": "string", + "description": "Used with kind=regex." + }, + "match_index": { + "type": "integer", + "minimum": 0, + "description": "Used with kind=regex. 0-based index of which match to use." + }, + "symbol_name": { + "type": "string", + "description": "Used with kind=symbol. Documentation-only, not enforced." + } + }, + "allOf": [ + { + "if": { "properties": { "kind": { "const": "line_range" } } }, + "then": { "required": ["start", "end"] } + }, + { + "if": { "properties": { "kind": { "const": "unique_string" } } }, + "then": { "required": ["text"] } + }, + { + "if": { "properties": { "kind": { "const": "regex" } } }, + "then": { "required": ["pattern"] } + } + ] + }, + "region": { + "type": "object", + "required": ["file", "start", "end"], + "properties": { + "file": { "type": "string" }, + "start": { "type": "integer", "minimum": 1 }, + "end": { "type": "integer", "minimum": 1 } + } + }, + "probe": { + "type": "object", + "required": ["kind", "file"], + "properties": { + "kind": { + "type": "string", + "enum": ["contains", "not_contains", "line_equals"] + }, + "file": { "type": "string" }, + "text": { + "type": "string", + "description": "Substring to search for (contains/not_contains) or exact line content (line_equals)." + }, + "line": { + "type": "integer", + "minimum": 1, + "description": "1-based line number. Required for kind=line_equals." + } + }, + "allOf": [ + { + "if": { "properties": { "kind": { "enum": ["contains", "not_contains"] } } }, + "then": { "required": ["text"] } + }, + { + "if": { "properties": { "kind": { "const": "line_equals" } } }, + "then": { "required": ["line", "text"] } + } + ] + } + } +} diff --git a/scripts/build_parquet.py b/scripts/build_parquet.py new file mode 100644 index 0000000000000000000000000000000000000000..93ecdf2f751b5b5b90af1ad9a4ff828666bcfdb4 --- /dev/null +++ b/scripts/build_parquet.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +"""Rebuild data/artifacts.parquet, refresh artifact_count in data/pairs.parquet, +and regenerate MANIFEST.json from the in-place dataset files. + +Reads directly from artifacts/{pair_id}/*.json, codebases/*.zip, and papers/*.pdf +already in the repo. Static pair metadata (paper title, license, hashes, etc.) in +pairs.parquet is preserved; only artifact_count is recomputed. + +Usage (from the zkml-audit-benchmark/ directory): + python scripts/build_parquet.py +""" + +from __future__ import annotations + +import hashlib +import json +import sys +from pathlib import Path + +try: + import pyarrow as pa + import pyarrow.parquet as pq +except ImportError: + sys.exit("pyarrow is required: pip install pyarrow") + + +PAIR_IDS = ["zkgpt", "zkllm", "zkml", "zktorch"] + + +def sha256_file(path: Path) -> str: + h = hashlib.sha256() + with open(path, "rb") as f: + for chunk in iter(lambda: f.read(1 << 16), b""): + h.update(chunk) + return h.hexdigest() + + +def rebuild_artifacts_parquet(hf_root: Path) -> dict[str, int]: + """Rebuild data/artifacts.parquet. Returns per-pair artifact counts.""" + artifacts_root = hf_root / "artifacts" + data_dst = hf_root / "data" + + rows: list[dict] = [] + counts: dict[str, int] = {} + + for pid in PAIR_IDS: + art_dir = artifacts_root / pid + if not art_dir.exists(): + print(f" WARNING: {art_dir} not found, skipping") + counts[pid] = 0 + continue + + art_files = sorted(art_dir.glob("*.json")) + counts[pid] = len(art_files) + print(f"{pid}: {len(art_files)} artifacts") + + for af in art_files: + af_hash = sha256_file(af) + art = json.loads(af.read_text(encoding="utf-8")) + + finding = art.get("finding", {}) + labels = finding.get("labels", {}) + conflict = art.get("conflict_keys", {}) + + artifact_id = art["artifact_id"] + relevant_code = labels["relevant_code"] + paper_reference = labels["paper_reference"] + + rows.append({ + "artifact_id": artifact_id, + "pair_id": pid, + "source": art["source"], + "finding_name": finding["name"], + "finding_explanation": finding["explanation"], + "relevant_code": relevant_code, + "paper_reference": paper_reference, + "edit_count": len(art.get("edits", [])), + "files_touched": conflict.get("files", []), + "semantic_tags": conflict.get("semantic_tags", []), + "requires": conflict.get("requires", []), + "incompatible": conflict.get("incompatible", []), + "artifact_path": f"artifacts/{pid}/{af.name}", + "artifact_sha256": af_hash, + }) + + schema = pa.schema([ + ("artifact_id", pa.string()), + ("pair_id", pa.string()), + ("source", pa.string()), + ("finding_name", pa.string()), + ("finding_explanation", pa.string()), + ("relevant_code", pa.string()), + ("paper_reference", pa.string()), + ("edit_count", pa.int32()), + ("files_touched", pa.list_(pa.string())), + ("semantic_tags", pa.list_(pa.string())), + ("requires", pa.list_(pa.string())), + ("incompatible", pa.list_(pa.string())), + ("artifact_path", pa.string()), + ("artifact_sha256", pa.string()), + ]) + + table = pa.table( + {col: [r[col] for r in rows] for col in schema.names}, + schema=schema, + ) + out_path = data_dst / "artifacts.parquet" + pq.write_table(table, out_path) + print(f"✓ {out_path}: {len(rows)} rows written") + return counts + + +def refresh_pairs_parquet(hf_root: Path, counts: dict[str, int]) -> None: + """Update artifact_count in data/pairs.parquet. Preserve all other columns.""" + pairs_path = hf_root / "data" / "pairs.parquet" + if not pairs_path.exists(): + print(f" WARNING: {pairs_path} not found, skipping pairs refresh") + return + + table = pq.read_table(pairs_path) + rows = table.to_pylist() + changed = 0 + for r in rows: + pid = r["pair_id"] + new_count = counts.get(pid, r.get("artifact_count", 0)) + if r.get("artifact_count") != new_count: + r["artifact_count"] = new_count + changed += 1 + + new_table = pa.table( + {col: [r[col] for r in rows] for col in table.schema.names}, + schema=table.schema, + ) + pq.write_table(new_table, pairs_path) + print(f"✓ {pairs_path}: artifact_count updated for {changed} pair(s)") + + +def regenerate_manifest(hf_root: Path) -> None: + """Regenerate MANIFEST.json from on-disk artifacts, codebases, papers, and parquet files.""" + manifest_path = hf_root / "MANIFEST.json" + + paths: list[Path] = [] + for adir in sorted((hf_root / "artifacts").iterdir()): + if adir.is_dir(): + paths.extend(sorted(adir.glob("*.json"))) + for cb in sorted((hf_root / "codebases").glob("*.zip")): + paths.append(cb) + for pp in sorted((hf_root / "papers").glob("*.pdf")): + paths.append(pp) + + files = [] + for p in paths: + rel = p.relative_to(hf_root).as_posix() + files.append({ + "path": rel, + "sha256": sha256_file(p), + "size": p.stat().st_size, + }) + + manifest = { + "generated_by": "scripts/build_parquet.py", + "total_files": len(files), + "files": files, + } + manifest_path.write_text( + json.dumps(manifest, indent=2, ensure_ascii=False) + "\n", + encoding="utf-8", + ) + print(f"✓ {manifest_path}: {len(files)} entries") + + +def rebuild(hf_root: Path) -> None: + counts = rebuild_artifacts_parquet(hf_root) + refresh_pairs_parquet(hf_root, counts) + regenerate_manifest(hf_root) + print("\n✓ Build complete") + + +if __name__ == "__main__": + hf_root = Path(__file__).resolve().parent.parent + rebuild(hf_root) + diff --git a/scripts/verify_dataset.py b/scripts/verify_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..dda873008dc6b857ac261da570d9a881ce2be8ca --- /dev/null +++ b/scripts/verify_dataset.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +"""Verify the built zkml-audit-benchmark HF dataset. + +Checks: + 1. Every file in MANIFEST.json exists and has the recorded SHA256. + 2. Every artifact JSON validates against the v2 schema (if jsonschema installed). + 3. Every artifact's pair_id exists in pairs.parquet. + 4. Parquet files load correctly via pyarrow. + +Usage (from the hf-dataset/ directory): + python scripts/verify_dataset.py +""" + +from __future__ import annotations + +import hashlib +import json +import sys +from pathlib import Path + +try: + import pyarrow.parquet as pq +except ImportError: + sys.exit("pyarrow is required: pip install pyarrow") + + +def sha256_file(path: Path) -> str: + h = hashlib.sha256() + with open(path, "rb") as f: + for chunk in iter(lambda: f.read(1 << 16), b""): + h.update(chunk) + return h.hexdigest() + + +def verify(hf_root: Path) -> bool: + ok = True + + # --- 1. MANIFEST.json --- + manifest_path = hf_root / "MANIFEST.json" + if not manifest_path.exists(): + print("FAIL: MANIFEST.json not found") + return False + + with open(manifest_path, "r", encoding="utf-8") as f: + manifest = json.load(f) + + entries = manifest.get("files", []) + print(f"Checking {len(entries)} manifest entries...") + + for entry in entries: + fpath = hf_root / entry["path"] + if not fpath.exists(): + print(f" FAIL: missing {entry['path']}") + ok = False + continue + actual = sha256_file(fpath) + if actual != entry["sha256"]: + print(f" FAIL: sha256 mismatch for {entry['path']}") + print(f" expected: {entry['sha256']}") + print(f" actual: {actual}") + ok = False + else: + pass # silent on success + + if ok: + print(f" OK: all {len(entries)} files match") + + # --- 2. Schema validation (optional) --- + schema_path = hf_root / "schema" / "artifact.v2.schema.json" + try: + import jsonschema + with open(schema_path, "r", encoding="utf-8") as f: + schema = json.load(f) + + artifact_dirs = [d for d in (hf_root / "artifacts").iterdir() if d.is_dir()] + art_count = 0 + for adir in sorted(artifact_dirs): + for af in sorted(adir.glob("*.json")): + with open(af, "r", encoding="utf-8") as f: + art = json.load(f) + aid = art.get("artifact_id", af.stem) + try: + jsonschema.validate(art, schema) + except jsonschema.ValidationError as e: + print(f" FAIL: {aid} — {e.message}") + ok = False + art_count += 1 + + print(f" OK: {art_count} artifacts validated against v2 schema") + except ImportError: + print(" SKIP: jsonschema not installed; skipping artifact schema validation") + + # --- 3. Parquet integrity --- + pairs_path = hf_root / "data" / "pairs.parquet" + artifacts_path = hf_root / "data" / "artifacts.parquet" + + if not pairs_path.exists(): + print("FAIL: data/pairs.parquet not found") + ok = False + if not artifacts_path.exists(): + print("FAIL: data/artifacts.parquet not found") + ok = False + + if pairs_path.exists() and artifacts_path.exists(): + pairs_table = pq.read_table(pairs_path) + artifacts_table = pq.read_table(artifacts_path) + + pair_ids = set(pairs_table.column("pair_id").to_pylist()) + art_pair_ids = set(artifacts_table.column("pair_id").to_pylist()) + + orphan = art_pair_ids - pair_ids + if orphan: + print(f" FAIL: artifact pair_ids not in pairs table: {orphan}") + ok = False + else: + print(f" OK: {len(pairs_table)} pairs, {len(artifacts_table)} artifacts, all pair_ids valid") + + # Check per-pair artifact counts match + for pid in pair_ids: + expected = [ + r["artifact_count"] + for r in pairs_table.to_pylist() + if r["pair_id"] == pid + ][0] + actual = sum(1 for r in artifacts_table.to_pylist() if r["pair_id"] == pid) + if expected != actual: + print(f" FAIL: {pid} artifact_count={expected} but found {actual} artifact rows") + ok = False + + # --- Summary --- + if ok: + print("\n✓ All checks passed") + else: + print("\n✗ Some checks failed") + + return ok + + +if __name__ == "__main__": + hf_root = Path(__file__).resolve().parent.parent + sys.exit(0 if verify(hf_root) else 1)