Skip to content

docs(examples): vulnerable-vault example + product-first README#101

Closed
aktasbatuhan wants to merge 3 commits into
kai/clifrom
kai/examples
Closed

docs(examples): vulnerable-vault example + product-first README#101
aktasbatuhan wants to merge 3 commits into
kai/clifrom
kai/examples

Conversation

@aktasbatuhan

Copy link
Copy Markdown
Member

Stacked on #100 (kai/cli) — uses the kai audit/view/report commands. Retarget to master as the stack lands.

What this does

Makes the README a "run this in 60s" experience instead of "trust me," and gives newcomers something real to point Kai at.

examples/vulnerable-vault/

A tiny, self-contained, intentionally-vulnerable Solidity target:

  • src/Vault.sol — a reentrancy in withdraw() and an unchecked ERC-20 return in sweepToken().
  • threat_context.yaml — a ready-made threat context for the target.
  • README.md — documents the planted bugs, the exact kai audit command, and the expected findings.

Lets anyone run the full audit → view/report loop without a private repo or large API spend. Clearly marked intentionally-insecure / authorized-demo-only.

README reframe (product-first)

  • A top-of-file Quickstart: install → kai audit examples/vulnerable-vaultkai view / kai report.
  • An Examples section linking the directory.
  • A Benchmarking section that makes the evaluation/ harness discoverable but secondary ("most users don't need it") — it wasn't mentioned in the main README before.

The deep reference docs (model/env tables, threat-context schema, full Usage) are unchanged, just below the quickstart.

Verification

  • pytest 592 passed / 6 skipped (no code changed); ruff clean.
  • README links checked; example structure: src/Vault.sol, foundry.toml, threat_context.yaml, README.md.

Follow-up (asset, not code)

A short screencast/GIF of kai view would strengthen the README top — a design/asset task for whoever owns the repo's media.

@eren23

eren23 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

this one lgtm

- examples/vulnerable-vault: a tiny, self-contained, intentionally-vulnerable
  Solidity target (reentrancy + unchecked ERC-20 return) with a ready-made
  threat_context.yaml and a README documenting the planted bugs, the run
  command, and the expected findings. Lets anyone try the full
  audit -> view/report loop without a private repo or large spend.
- examples/README.md indexes the targets with a responsible-use note.
- README: add a top-of-file Quickstart (install -> audit the example ->
  view/report), an Examples section, and a Benchmarking pointer that makes the
  evaluation/ harness discoverable while keeping it secondary to the product.
…EADME

A real kai audit showed the original withdraw(amount) reentrancy was NOT
exploitable under Solidity 0.8.x: the checked '-= amount' underflows and
reverts during the reentrant unwind, and kai correctly disproved it. Switch
to the canonical drainable form (zero the balance with '= 0' AFTER the
external call) so the bug is real.

Rewrite the example README to match verified output instead of a fabricated
findings table: show the actual confirmed Critical (CVSS 9.8) reentrancy and
its Check-Effects-Interaction patch, and state plainly that kai is
non-deterministic — which bugs are confirmed and their scores vary by run and
model.
Follows the console-script rename (`kai` → `kai-security`, which avoids
shadowing kai-agent's `kai`). Updates the copy-pasteable example commands in the
walkthrough docs; the import package / module names are unchanged.
@aktasbatuhan

Copy link
Copy Markdown
Member Author

Rolled up into #102, now merged to master (7a630c1). Closing as redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants