Spark Program | ckb-whitehat

ckb-whitehat — Spark Program application

Status: ready to run (tool shipped at v0.4.2). The repository
(https://github.com/nghiadang391/ckb-whitehat)
already exists under my GitHub account (nghiadang391) and holds two completed
pilots plus a working Go CLI release (v0.4.2, CI green). This application
funds the first systematic whitehat verification of three more CKB-DAO-funded
CKB/Fiber money products, plus three net-new forward deliverables on the tool
itself. Code for each new target lands in this repo week by week, with its
FINDINGS.md, its deterministic PoC suite, and its patch packs.

License: MIT.


Title: Spark Program | ckb-whitehat: deterministic whitehat verification of CKB/Fiber money products — AI-assisted triage, replayable PoCs, patches, consent-based disclosure

Category: DAOs & Funding → Spark Program (posted directly in the Spark sub-section per the 2026-07-19 forum update)

1. Project overview

  • Project name: ckb-whitehat
  • Repository: https://github.com/nghiadang391/ckb-whitehat (latest release: v0.4.2, MIT)
  • One-sentence summary: ckb-whitehat is a shipped community verification
    CLI (v0.4.2) with a public track record (two completed pilots, 23 findings
    — 21 PROVEN fired + 2 STRUCTURAL repo-verified); this grant funds
    applying it to three more CKB-DAO-funded CKB/Fiber money products — each
    shipped as one-command deterministic PoCs, minimal patches, and a
    consent-based disclosure record — plus three net-new tool deliverables: a
    standalone verify subcommand, a measured AI-cost reduction pass, and a
    maintainer disclosure kit.
  • Type: developer security verification tooling (already built, MIT, single
    static Go binary, zero runtime dependencies, CI green) plus a public body of
    verified findings. Developers can also run ckb-whitehat locally as a
    pre-push defensive security verification gate before shipping their own
    CKB/Fiber apps. No changes to Fiber, CKB-VM, or any grantee’s codebase;
    findings ship as PoCs + patches, applied only with the maintainer’s written
    consent.

2. Team profile

  • Nghia Dang (GitHub: nghiadang391),
    solo, all roles.
  • Contact:
  • Background: CKB ecosystem builder; author of the ckb-whitehat tool and
    methodology (https://github.com/nghiadang391/ckb-whitehat,
    MIT). Relevant public work, all verifiable in-repo:
    • Dular pilot (M-Pesa STK-push → RUSD on-ramp over Fiber; an approved
      $2,000 Spark grant, M1 verified with 3 production 1-KES deposits): 9
      findings
      — F1–F7 PROVEN (fired, including 1 CRITICAL) + F8–F9
      STRUCTURAL
      (verified repo inventory / pre-release lockfile pin). F1
      (“forged STK callback = free RUSD”) ends in a real CKB Pudge testnet trace
      where a fabricated KES receipt moved RUSD between two of our own local FNN
      nodes (tx hashes recorded in dular/FINDINGS.md, C4.1–C4.5). The F2
      ledger double-spend race ships with a 3-line fix and a harness that fails
      on unmodified source and passes on the fix.
    • tapfiber pilot (Fiber order/receipt library, vendored in-tree): 14
      findings (F1–F14, all PROVEN/fired)
      , one-command zero-dependency
      offline PoC suite (node tapfiber/poc/attack.mjs).
    • The tool itself (v0.4.2): single static Go binary (zero runtime
      dependencies — no Node/npm needed to install; drives local authenticated
      claude, agy [Antigravity CLI], or codex CLIs in auto-detect order
      claude → agy → codex, never asking for API keys), embedded methodology,
      read-only AI-assisted init with per-command risk analysis and approval
      (setup.json handoff), live responsive 2-column TUI with one-key human
      checkpoint gates (triage / permission / publish), self-contained
      local Docker CKB devnet (nervos/ckb:v0.210.0) + 2 peered Fiber
      (nervos/fiber:0.10.1) nodes with pre-funded CKB & TEST_XUDT channels
      (ckb-whitehat chain up|status|down), mainnet refusal guard + strict
      post-run RPC hash verification, isolated Docker scratch Postgres
      (127.0.0.1:5439), 5 embedded CKB/Fiber invariant packs, broad-allow +
      strict high-risk denylist, polyglot stack support (Node, Rust/Cargo
      ckb-testtool, Go, Python), install.sh + GitHub Releases (sha256-verified
      self-update), and green CI.
  • Weekly sync: text updates in this thread, every Saturday at a fixed time
    (UTC), with the week’s findings table and repro commands.

3. Project background

The grant cycle has produced a wave of CKB/Fiber money products —
stablecoin wallets, RUSD on-ramps, Fiber-based order/receipt systems, and
CKB-script apps. Where money moves, an unauthenticated callback, a ledger
double-spend race, or an unsafe config default is directly exploitable for
asset theft. Two lanes of verification already exist:

  • Protocol-core: the CKB-VM Sail Validation Sprint and the
    ckb-verify / spark-verify acceptance-check tool cover the shared chain
    assets and the author’s own declared flows.
  • Author-side regression: a project re-running its own acceptance
    commands on a devnet.

What is missing is the adversarial, community-owned middle lane: an outside
verifier testing the default code paths of funded apps — and giving builders
a reusable pre-push verification CLI they can run locally before shipping —
with deterministic evidence a maintainer can run and trust rather than a
report of opinions. The committee has shown it values concrete, verifiable
proof: the Dular approval turned on working multi-hop RUSD payment traces plus
a clear “How to Verify” section. This application funds that same shape — a
shipped tool (v0.4.2) with public evidence, applied to three new CKB/Fiber
targets.

4. Solution

For each target, ckb-whitehat executes a fixed, reproducible pipeline:

  1. Read-only init & triage — ckb-whitehat init inspects the repo in
    strictly read-only mode to map stack dependencies and host prerequisites
    (with explicit per-command human approval for any target dependency install).
    ckb-whitehat run then maps keygen/key storage, amount parsing (BigInt vs
    Number), signing, vendor/network trust boundaries, balance/ledger
    invariants, secrets-in-config, and on-chain interactions.
  2. Named security invariant hypotheses — each names a code region, threat
    class, and the money/safety invariant it violates (no double-credit,
    non-negative balance under concurrency, callback authenticity, fail-closed
    production defaults). Ranked and scoped to what is provable locally.
  3. Deterministic PoCs — one replayable verification script per hypothesis:
    unauthenticated-webhook test, concurrent DB race harness (against isolated
    Docker scratch Postgres), config-matrix test, or boundary fuzz corpus. A
    finding ships as PROVEN only when its script actually ran against
    unmodified source and printed its captured FINDING <id> FIRED verdict.
  4. On-chain evidence — for chain-interacting targets:
    • Local deterministic devnet (--chain): self-contained Docker CKB
      devnet + 2 peered FNN v0.10.1 nodes with pre-funded CKB & TEST_XUDT
      channels (zero faucet flakiness; every reported tx/payment hash is
      automatically re-verified against local RPC by ckb-whitehat at the end
      of run).
    • Public CKB Pudge testnet (when explorer-checkable public traces add
      value):
      our own 2-node FNN stack, our own addresses, faucet assets —
      impact confined strictly to our own addresses and local services. Mainnet
      is hard-refused by the CLI.
  5. Patch guidance — minimal defensive fix per finding; for races/config
    bugs, a working fixed module plus the same harness re-run proving it fails
    before and passes after.
  6. Consent-based disclosure — private report to the maintainer, patch
    window, publication only on written consent. The dated disclosure log ships
    as a deliverable so the community sees the pipeline end to end.

How the AI cost enters: steps 1–3 use the local agent CLI (claude, agy,
or codex); LLM tokens for triage, PoC engineering, and report drafting are a
real, auditable cost item budgeted explicitly in §7 (capped at $150 across all
3 targets, with per-target session logs and token counts).

5. Technical approach

  • Stack: ckb-whitehat v0.4.2 static Go binary (go test -race green in
    CI across Linux/macOS/Windows amd64/arm64) driving local claude, agy,
    or codex CLIs, plus the target’s own runtime toolchain (polyglot support:
    Node .mjs, Rust cargo test / ckb-testtool, Go, Python).
  • Local devnet & DB harness (already shipped in v0.3.x):
    • ckb-whitehat chain up boots an isolated Docker network (172.29.0.0/24)
      with nervos/ckb:v0.210.0 (127.0.0.1:8114) + 2 peered
      nervos/fiber:0.10.1 nodes (127.0.0.1:8227 / 8327), SHA-256-verified
      Fiber contracts, pre-minted genesis CKB & TEST_XUDT, and pre-opened
      ChannelReady CKB (1,000 CKB) + TEST_XUDT (100 TEST_XUDT) channels.
    • Five embedded reusable CKB/Fiber invariant packs materialized into every
      workspace (chain-client.mjs, pack-payment-idempotency.mjs,
      pack-hold-invoice-htlc.mjs, pack-udt-decimals.mjs,
      pack-self-custody.mjs).
    • Auto-provisioned isolated Docker scratch Postgres (postgres:16-alpine on
      127.0.0.1:5439, throwaway credentials) whenever a target uses Postgres.
  • Trust & safety boundaries:
    • Untrusted target isolation: --setting-sources user (Claude), no
      --add-dir <target> (agy, blocking untrusted .agents/hooks.json),
      project_doc_max_bytes=0 (Codex), hardened git clone (hooksPath=/dev/null,
      fsmonitor=false, symlinks=false), and workspace-confined cwd.
    • Broad safe tool allowlist paired with a strict high-risk denylist blocking
      rm -rf, git push, git reset --hard, sudo, curl, wget, ssh,
      psql, env, live web fetches, MCP, and target-repo writes.
    • Mainnet refusal guard (VerifyMainnetSafe) checks CKB get_blockchain_info
      and FNN chain_hash before any --chain run.
    • External third-party vendors (M-Pesa/Daraja, webhooks, external APIs) are
      always mocked/stubbed locally; no live service is ever probed.
  • Hard parts:
    • Keeping every PoC deterministic and one-command reproducible against
      unmodified source across heterogeneous stacks (JS/TS, Rust CKB-scripts,
      Go).
    • Separating app-layer bugs from chain/FNN behavior in every recorded
      on-chain state transition (linking upstream protocol issues rather than
      claiming them as app findings).
    • Managing responsible disclosure timelines while keeping pre-consent
      details private and still giving the committee an auditable dated log.
  • Language: English.

6. To-Do list (6 weeks)

The CLI (v0.4.2) and local CKB/Fiber devnet + scratch Postgres harness are
already built and proven on two pilots. The funded work is: (a) applying
ckb-whitehat to three new CKB-DAO-funded CKB/Fiber money products, and (b)
three net-new forward deliverables on the tool itself.

  • Week 1: D1 target selection posted in-thread (3 CKB-DAO-funded CKB/Fiber
    projects from the active Spark/CKB registry, at least one a money product:
    wallet / on-ramp / exchange / payment tool), with rationale and overlap check
    against Sail-validation and author-side regression lanes. Verify local
    devnet (ckb-whitehat chain up) + baseline green trace for Target 1 (and
    optional Pudge testnet trace if public explorer verification applies).
    • Milestone: targets named and unchallenged for 7 days.
  • Week 2: Target 1, complete pack: offline findings + PoC suite + patch
    guidance, local devnet / on-chain evidence (recorded hashes verified against
    RPC), first private disclosure contact sent.
    • Milestone: Target 1 pack reproducible with one command per finding;
      disclosure #1 sent.
  • Week 3: Target 2, complete pack + disclosure #2 sent.
  • Week 4: Target 3, complete pack + disclosure #3 sent.
    • Milestone: all three target packs merged to the repo, CI green.
  • Week 5: Net-new forward work (D6), three shippable PRs:
    1. Standalone ckb-whitehat verify <FINDINGS.md> subcommand: unlike
      v0.4.2’s in-run post-check, this standalone subcommand lets any
      committee reviewer or maintainer re-audit an already published
      FINDINGS.md with zero LLM calls — re-running its PoC suite and
      re-verifying recorded tx/payment hashes against local devnet or Pudge
      testnet RPC. Turns “How to Verify” into a single binary command.
    2. Measured AI-cost reduction pass: establish a logged Week-1 token/cost
      baseline per target, then cut total token spend via structured per-run
      usage telemetry, prompt caching of the triage pass, tiered/smaller models
      for mechanical checks, tighter gate-loop budgeting, and a hashed
      known-issue catalog
      (recording deterministic (step, exit_code, error_class) hashes — never raw untrusted target output — mapped to
      curated remedies so repeated environment failures short-circuit with zero
      LLM turns and log recovered-known-issue <sig>). Target: ≥ 40% token
      reduction
      vs. baseline while still firing every finding on re-run.
    3. 1-page quickstart + maintainer disclosure kit: a concise quickstart
      for developers running ckb-whitehat pre-push on their own repo, plus
      the exact public maintainer disclosure letter template and consent
      checklist.
      Cross-target SUMMARY.md (finding taxonomy, recurring foot-guns,
      recommended community fixes) drafted alongside.
  • Week 6: Full regression re-run of every PoC against unmodified source;
    secret-material sweep (confirming zero real provider keys, OTPs, phone PII,
    or CKB hex keys in PoCs/reports); completion report with funds-usage vs. §7;
    captioned 3-minute walkthrough demo of one full target run from init
    through fired PoC and verified on-chain trace.
    • Milestone: final deliverable set live; ckb-whitehat verify green in CI.

7. Required funding & funding breakdown

Total: $950 USD, paid in CKB (within the standard $1,000 single-category
budget tier).

  • Technical vs. Community allocation: $850 technical (AI verification
    compute, PoC/patch engineering, standalone verify subcommand, AI-cost
    reduction pass) / $100 community (1-page developer quickstart, public
    maintainer disclosure kit, weekly forum updates & maintainer disclosure
    coordination).
Item Category Amount What it pays for
AI / LLM analysis + agent compute Technical $150 Triage passes, PoC development, report drafting, and checkpoint sessions across all 3 targets (audited via per-target session logs & token counts).
Target packs (D2–D4): PoC + patch engineering Technical $600 ~30 h per target pack: triage, deterministic offline + on-chain PoCs, minimal patches & regression harnesses, and private disclosure prep.
Forward tooling (D6a–b): verify subcommand + AI-cost reduction Technical $100 Standalone ckb-whitehat verify CLI command, token telemetry, prompt-caching/tiering, and hashed known-issue recovery catalog.
Community docs, disclosure kit & coordination (D5, D6c) Community $100 Cross-target SUMMARY.md, 1-page developer pre-push quickstart, public maintainer disclosure letter template, weekly updates, and maintainer follow-ups.
  • What costs nothing here and why: local Docker CKB devnet + 2-node FNN
    v0.10.1 + Docker scratch Postgres run locally ($0); optional Pudge testnet
    assets come from public faucets ($0).
  • What it does not cover: mainnet replay (hard-refused by the CLI; if ever
    requested separately, it would be explicitly scoped and budgeted).
  • Why this amount: deliberately compact and fully deliverable within 6
    weeks; the shipped v0.4.2 CLI and two completed pilots already exist in the
    repo at $0 grant cost.
  • Disbursement: standard Spark milestone disbursement (e.g., 20% at
    kickoff, 80% upon final deliverable verification).

8. Deliverables + how to verify

A. Deliverables

  1. D1 — Target selection post (Week 1, in-thread): 3 targets, selection
    rationale, overlap check against Sail-validation and author-side regression
    lanes. Done when: posted and unchallenged for 7 days.
  2. D2–D4 — Three target verification packs (Weeks 2–4): per-target
    FINDINGS.md (severity-ranked PROVEN/STRUCTURAL/UNPROVEN findings,
    captured PoC outputs, minimal patches, regression re-runs, verified on-chain
    tx/payment hashes where applicable), reproducible poc/ suite, and
    disclosure record. Done when: every PROVEN PoC reproduces with one
    command against unmodified source and passes ckb-whitehat verify.
  3. D5 — SUMMARY.md + dated disclosure log (Weeks 5–6): cross-target
    finding taxonomy, recurring CKB/Fiber foot-guns, recommended fixes, and
    dated record of every maintainer contact, patch-window status, and consent
    state (public / consented-private / pending).
  4. D6 — Three net-new forward PRs (Week 5):
    • Standalone ckb-whitehat verify <FINDINGS.md> subcommand — done when:
      re-audits all 3 new reports and the 2 pilots in one command each with zero
      LLM calls, green in CI.
    • AI-cost reduction pass + hashed known-issue catalog — done when:
      before/after table in-repo shows ≥ 40% token reduction vs. Week-1 baseline
      with identical findings fired, and a reproducing re-run logs
      recovered-known-issue <sig>.
    • 1-page developer quickstart + maintainer disclosure letter template —
      done when: a developer can install and run ckb-whitehat on a fresh
      target following only the 1-pager.
  5. Completion report & 3-minute captioned demo (Week 6): funds usage vs.
    §7 plus full run walkthrough video.

B. How to verify (no code review needed; low reviewer cost)

  • Environment & cost control:
    • Check 1 (offline pilot PoCs): Linux/macOS/Windows with Node 18+ only
      — zero Docker, zero Postgres, zero network, ~5 seconds.
    • Check 2 (local CKB/Fiber devnet harness): Linux/macOS with Docker —
      zero faucets, zero testnet keys, ~2 minutes.
    • Check 3 & 4 (on-chain hashes & disclosure log): browser only, ~2
      minutes.
  1. Instant offline PoC verification (5 seconds, Node 18+ only):
    git clone https://github.com/nghiadang391/ckb-whitehat
    cd ckb-whitehat
    node tapfiber/poc/attack.mjs
    
    Expected output: exits 0 and prints all 14 deterministic FINDING F1 FIRED
    through FINDING F14 FIRED verdict lines against unmodified vendored
    tapfiber source.
  2. Self-contained local CKB + Fiber devnet verification (~2 minutes, Docker):
    curl -fsSL https://raw.githubusercontent.com/nghiadang391/ckb-whitehat/main/install.sh | sh
    ckb-whitehat chain up
    ckb-whitehat chain status
    
    Expected output: boots nervos/ckb:v0.210.0 + 2 peered
    nervos/fiber:0.10.1 nodes and reports ChannelReady pre-funded CKB and
    TEST_XUDT channels with zero faucet setup. (Clean up anytime with
    ckb-whitehat chain down.)
  3. Public on-chain hash verification (browser only): pick any recorded
    Pudge testnet tx hash in dular/FINDINGS.md (e.g. funding tx
    0x72ed0d77…df27d3 from dular/poc/c4-record.json) or in any new D2–D4
    report and verify block/channel amounts on pudge.explorer.nervos.org (and
    once D6 ships, run ckb-whitehat verify <target>/FINDINGS.md directly).
  4. Disclosure audit (browser only): inspect the dated disclosure log in
    SUMMARY.md — every contact carries a date, response status, and
    publication consent state.

9. Current state vs. funded work

  • Already exists (in nghiadang391/ckb-whitehat v0.4.2, uncosted by any grant):
    • Two completed pilots: Dular (F1–F7 PROVEN + F8–F9 STRUCTURAL +
      on-chain C4.1–C4.5) and tapfiber (F1–F14, all PROVEN), with
      reproducible PoCs and recorded traces.
    • The v0.4.2 static Go CLI: claude/agy/codex drivers, read-only
      AI-assisted init, responsive live TUI + checkpoint gates, self-contained
      Docker CKB/Fiber devnet (chain up|status|down), isolated Docker scratch
      Postgres, 5 embedded CKB/Fiber invariant packs, mainnet refusal guard,
      in-run completeness & RPC hash verification, broad-allow + strict denylist,
      install.sh, sha256-verified update, and green CI.
  • Funded work (net-new under this $950 grant):
    • Three new CKB/Fiber target verification packs (D2–D4): full triage →
      deterministic offline + on-chain PoCs → minimal patches & regression tests
      → consent-based disclosure.
    • Cross-target SUMMARY.md + dated disclosure log (D5).
    • Three net-new forward tool PRs (D6): standalone ckb-whitehat verify
      subcommand (zero-LLM reviewer re-audit), measured ≥ 40% AI-cost reduction
      pass with hashed known-issue recovery catalog, and 1-page developer
      quickstart + maintainer disclosure letter template.
    • Auditable AI/LLM token compute across all 3 targets (§7).
    • Boundary: the two existing pilots and v0.4.2 CLI are proof of
      execution at $0 grant cost — they are not double-counted as funded
      deliverables.

10. CKB alignment

  • CKB Cell Model, xUDT/sUDT & Fiber Network (FNN v0.10.1): every funded
    target is a CKB/Fiber ecosystem project. The CLI ships dedicated local
    devnet CKB + 2-node Fiber infrastructure and 5 reusable invariant packs
    specifically targeting CKB/Fiber failure modes (Fiber payment idempotency,
    hold-invoice/HTLC boundaries, UDT decimal/shannon BigInt overflow, and
    browser/server self-custody key wrapping) plus Rust CKB-script (cargo test
    / ckb-testtool) support.
  • Publicly re-checkable evidence: local devnet harnesses let anyone
    re-verify deterministically in ~2 minutes with zero faucet dependency, and
    public Pudge testnet traces remain explorer-verifiable. Mainnet is never
    touched and is hard-refused in code.
  • Honest statements:
    • This is not a new payment protocol, not a custody product, and not
      protocol-core work: Fiber’s and CKB-VM’s roadmaps stay with the core teams,
      and any upstream issue tripped is linked rather than claimed.
    • Its value to CKB is concrete, one-command reproducible security evidence
      for DAO-funded money apps — plus MIT-licensed pre-push verification tooling
      that CKB/Fiber builders and reviewers can keep reusing after this grant.
5 Likes