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-whitehatis a shipped community verification
CLI (v0.4.2) with a public track record (two completed pilots, 23 findings
— 21PROVENfired + 2STRUCTURALrepo-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
standaloneverifysubcommand, 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 runckb-whitehatlocally 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:
- Discord:
nghia.dang.391 - Email:
[email protected] - GitHub: https://github.com/nghiadang391
- Nervos Talk: this account
- Discord:
- Background: CKB ecosystem builder; author of the
ckb-whitehattool 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–F7PROVEN(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 indular/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, allPROVEN/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], orcodexCLIs in auto-detect order
claude → agy → codex, never asking for API keys), embedded methodology,
read-only AI-assistedinitwith per-command risk analysis and approval
(setup.jsonhandoff), 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_XUDTchannels
(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.
- Dular pilot (M-Pesa STK-push → RUSD on-ramp over Fiber; an approved
- 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:
- Read-only init & triage —
ckb-whitehat initinspects 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 runthen maps keygen/key storage, amount parsing (BigIntvs
Number), signing, vendor/network trust boundaries, balance/ledger
invariants, secrets-in-config, and on-chain interactions. - 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. - 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 asPROVENonly when its script actually ran against
unmodified source and printed its capturedFINDING <id> FIREDverdict. - On-chain evidence — for chain-interacting targets:
- Local deterministic devnet (
--chain): self-contained Docker CKB
devnet + 2 peered FNNv0.10.1nodes with pre-funded CKB &TEST_XUDT
channels (zero faucet flakiness; every reported tx/payment hash is
automatically re-verified against local RPC byckb-whitehatat the end
ofrun). - 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.
- Local deterministic devnet (
- 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. - 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.2static Go binary (go test -racegreen in
CI across Linux/macOS/Windowsamd64/arm64) driving localclaude,agy,
orcodexCLIs, plus the target’s own runtime toolchain (polyglot support:
Node.mjs, Rustcargo test/ckb-testtool, Go, Python). - Local devnet & DB harness (already shipped in
v0.3.x):ckb-whitehat chain upboots an isolated Docker network (172.29.0.0/24)
withnervos/ckb:v0.210.0(127.0.0.1:8114) + 2 peered
nervos/fiber:0.10.1nodes (127.0.0.1:8227/8327), SHA-256-verified
Fiber contracts, pre-minted genesis CKB &TEST_XUDT, and pre-opened
ChannelReadyCKB (1,000 CKB) +TEST_XUDT(100TEST_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-alpineon
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), hardenedgit 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 CKBget_blockchain_info
and FNNchain_hashbefore any--chainrun. - External third-party vendors (M-Pesa/Daraja, webhooks, external APIs) are
always mocked/stubbed locally; no live service is ever probed.
- Untrusted target isolation:
- 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.
- Keeping every PoC deterministic and one-command reproducible against
- 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.
- Milestone: Target 1 pack reproducible with one command per finding;
- 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:
- 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.mdwith 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. - 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 logrecovered-known-issue <sig>). Target: ≥ 40% token
reduction vs. baseline while still firing every finding on re-run. - 1-page quickstart + maintainer disclosure kit: a concise quickstart
for developers runningckb-whitehatpre-push on their own repo, plus
the exact public maintainer disclosure letter template and consent
checklist.
Cross-targetSUMMARY.md(finding taxonomy, recurring foot-guns,
recommended community fixes) drafted alongside.
- Standalone
- 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 frominit
through fired PoC and verified on-chain trace.- Milestone: final deliverable set live;
ckb-whitehat verifygreen in CI.
- Milestone: final deliverable set live;
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, standaloneverifysubcommand, 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 shippedv0.4.2CLI 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
- 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. - D2–D4 — Three target verification packs (Weeks 2–4): per-target
FINDINGS.md(severity-rankedPROVEN/STRUCTURAL/UNPROVENfindings,
captured PoC outputs, minimal patches, regression re-runs, verified on-chain
tx/payment hashes where applicable), reproduciblepoc/suite, and
disclosure record. Done when: everyPROVENPoC reproduces with one
command against unmodified source and passesckb-whitehat verify. - 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). - 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 runckb-whitehaton a fresh
target following only the 1-pager.
- Standalone
- 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.
- Check 1 (offline pilot PoCs): Linux/macOS/Windows with Node 18+ only
- Instant offline PoC verification (5 seconds, Node 18+ only):
Expected output: exitsgit clone https://github.com/nghiadang391/ckb-whitehat cd ckb-whitehat node tapfiber/poc/attack.mjs0and prints all 14 deterministicFINDING F1 FIRED
throughFINDING F14 FIREDverdict lines against unmodified vendored
tapfibersource. - Self-contained local CKB + Fiber devnet verification (~2 minutes, Docker):
Expected output: bootscurl -fsSL https://raw.githubusercontent.com/nghiadang391/ckb-whitehat/main/install.sh | sh ckb-whitehat chain up ckb-whitehat chain statusnervos/ckb:v0.210.0+ 2 peered
nervos/fiber:0.10.1nodes and reportsChannelReadypre-funded CKB and
TEST_XUDTchannels with zero faucet setup. (Clean up anytime with
ckb-whitehat chain down.) - Public on-chain hash verification (browser only): pick any recorded
Pudge testnet tx hash indular/FINDINGS.md(e.g. funding tx
0x72ed0d77…df27d3fromdular/poc/c4-record.json) or in any new D2–D4
report and verify block/channel amounts onpudge.explorer.nervos.org(and
once D6 ships, runckb-whitehat verify <target>/FINDINGS.mddirectly). - 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–F7PROVEN+F8–F9STRUCTURAL+
on-chainC4.1–C4.5) and tapfiber (F1–F14, allPROVEN), with
reproducible PoCs and recorded traces. - The
v0.4.2static Go CLI:claude/agy/codexdrivers, read-only
AI-assistedinit, 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-verifiedupdate, and green CI.
- Two completed pilots: Dular (
- 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.2CLI are proof of
execution at $0 grant cost — they are not double-counted as funded
deliverables.
- Three new CKB/Fiber target verification packs (D2–D4): full triage →
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/shannonBigIntoverflow, 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.
- This is not a new payment protocol, not a custody product, and not