Repository navigation
feat(ckb): add malformed-witness and type-script fuzz corpus - #285
Merged
truthixify merged 2 commits intoNov 23, 2026
Conversation
Add deterministic fuzz targets, minimized regression seeds, and RISC-V CKB VM integration coverage for `wraith-stealth-lock` and `wraith-names-type`, hardening both scripts against panics, duplicate `.wraith` name cells, and malformed args/witnesses. Closes wraith-protocol#281
|
@khoap1220-hue Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Wire cargo-fuzz 0.12.0 (--locked) into the ckb CI job (-seed=281 -runs=512 across all five CKB targets) and add the scheduled/manual fuzz-ckb workflow job (180s per target with crash artifact upload).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
ckb/contracts/wraith-names-type/src/main.rs(validate(),validate_output_data(),count_cells_with_type_hash()) andckb/contracts/wraith-stealth-lock/src/main.rs(auth(),From<SysError>), malformed transactions and duplicate.wraithname cells previously had three unguarded paths discovered while building the fuzz corpus:.wraithName Outputs/Inputs (wraith-names-type):has_cell_with_type_hash()collapsed matching cell counts to booleans(has_input, has_output), allowing a single transaction to mint duplicate.wraithname cells (0 -> 2,1 -> 2) or coalesce duplicate inputs (2 -> 1). Replaced withcount_cells_with_type_hash()enforcing singleton cell uniqueness (<= 1matching input and<= 1matching output) and returningError::DuplicateNameCell(7).wraith-names-typeArgs Length & Non-Matching Invocation Trap: AddedNAME_ARGS_LEN = 32validation (Error::InvalidArgsLength = 6), replacedQueryIter::new(load_cell_data, Source::Output)withload_cell_type_hashpre-filtering so unrelated outputs are not loaded into heap memory, and replaced(false, false) => panic!(...)withError::NoMatchingCells(8).From<SysError>&CStringConstruction: Replacedpanic!arms inFrom<SysError>and.unwrap()calls inckb/contracts/wraith-stealth-lock/src/main.rsandckb/contracts/wraith-names-type/src/main.rswith deterministic exit codes (Error::UnexpectedSysError,Error::Encoding) while keeping existing exit codes (1..=7onwraith-stealth-lock,1..=5onwraith-names-type) unchanged. UpdatedAUTHORIZATION_MATRIX.mdwith the new error codes.Fuzz Targets & Retained Corpus (
ckb/fuzz/)Added a standalone host fuzz crate at
ckb/fuzz/([workspace], detached fromckb/Cargo.tomlsockb/Cargo.lockremains untouched forsupply-chain.yml) with 5 targets and 40 minimized seed/regression inputs underckb/fuzz/corpus/<target>/:lock_witness_and_argsWitnessArgstotal-size header, 3-field monotonic offsets,BytesOptinner length prefix, field-boundary truncation, trailing excess bytes,u32::MAXoffset overflow, and 53-bytewraith-stealth-lockargs (ephemeral_pubkey[33] || pubkey_hash[20]).names_type_scriptblake2b(name)type args, 66-byte output cell data (spending_pk[33] || viewing_pk[33]), singleton cell uniqueness (0 -> 2,1 -> 2,2 -> 1regressions), and zero-match lock invocation (NoMatchingCells).ckb_auth_inputsckb-authIPC argv slices (algorithm_id,signature,message,pubkey_hash), rejecting unsupported algorithm IDs (0x01..=0xFF), interior NUL bytes, non-hex/odd-length strings, recovery IDs>= 4, and zeror/sscalars.cell_deps_and_announcementCellDepresolution (CKB_AUTH_CODE_HASH,Data2vsType, unresolvedDepGroup, wrong dep/type hashes, duplicate out-points) and canonical 61-byte + metadata stealth announcement args wire codec with round-trip fixed-point checks.ckb_tx_layoutu64::checked_addcapacity overflow guards (u64::MAX), 61-CKB occupied-capacity floor,output_indexbounds, duplicated outputs, lock-group witness mapping, and cross-script dispatch.RISC-V CKB VM Integration Suite & CI (
ckb/integration-tests/,ckb/Makefile,.github/workflows/ci.yml)ckb/integration-tests/src/lib.rswithNamesTypeHarnessandLockHarness::build_unlock_with_raw_witnesses().ckb/integration-tests/tests/fuzz_corpus_regressions.rsexecuting both compiledriscv64imac-unknown-none-elfbinaries insideckb-testtoolacross all 6 corpus categories plus a bounded deterministic SplitMix64 VM fuzz loop (WRAITH_CKB_VM_FUZZ_ITERS=256).ckb/Makefilesomake test-cibuilds bothwraith-stealth-lockandwraith-names-type, runs the RISC-V VM regression suite (WRAITH_CKB_VM_FUZZ_ITERS=256), and replays all 40 corpus seeds plus a bounded deterministic sample (WRAITH_CKB_FUZZ_CASES=4096) in CI, alongsidemake fuzz-sampleandmake fuzz-scheduled(FUZZ_SCHEDULED_SECONDS=180) targets for scheduledcargo-fuzzsweeps..github/workflows/ci.ymlso theckbPR job installs pinnedcargo-fuzz(=0.12.0 --locked) and runs a bounded deterministiccargo-fuzzsample (-seed=281 -runs=512) across all 5 targets, and added the scheduled/manualfuzz-ckbworkflow job (-max_total_time=180per target with crash artifact upload).Closes #281