Skip to content

fix: resolve security-audit rand unsound error (exit 0)#668

Open
eval-exec wants to merge 1 commit into
nervosnetwork:developfrom
eval-exec:fix/security-audit-error-rand-unsound
Open

fix: resolve security-audit rand unsound error (exit 0)#668
eval-exec wants to merge 1 commit into
nervosnetwork:developfrom
eval-exec:fix/security-audit-error-rand-unsound

Conversation

@eval-exec

Copy link
Copy Markdown
Collaborator

Summary

Fixes the sole error-level finding from make security-audit on the develop branch.

Problem

make security-audit on develop fails with:

error[unsound]: Rand is unsound with a custom logger using rand::rng()
  -> rand 0.7.3 (RUSTSEC-2026-0097)

Why this is a false positive

The unsoundness requires ALL of these conditions:

  1. Calling rand::thread_rng() / rand::rng() from inside a custom log::Log implementation
  2. Trace-level logging active (or warn-level + getrandom seed failure)

ckb-cli uses rand::thread_rng() only in normal code paths:

  • ckb-signer/src/keystore — salt generation for key encryption
  • src/utils/mock_tx_helper.rs — random private key generation

None of these are inside a custom logger. The advisory is not exploitable.

Why not upgrade rand?

rand 0.7.3 is pinned by upstream dependencies that cannot be semver-bumped:

  • ckb-vm
  • jsonrpc-pubsub
  • numext-fixed-uint-core
  • phf_generator (build dep via includedir_codegen)

The fix requires rand >= 0.8.6, which is a semver-breaking change.

Changes

  • Add RUSTSEC-2026-0097 to deny.toml [advisories.ignore] with rationale

Verification

  • make security-audit exits 0, zero errors
  • Only warning[unmaintained] advisories remain (transitive deps)

The rand 0.7.3 unsoundness (RUSTSEC-2026-0097) requires ALL of:
- Calling rand::thread_rng() from inside a custom log::Log implementation
- Trace-level logging active (or warn-level + getrandom failure)

ckb-cli uses rand only in normal code paths (keystore salt generation,
mock tx helper) — never inside a custom logger. The advisory is not
exploitable here.

Cannot semver-bump rand to 0.8 due to upstream deps pinning 0.7:
ckb-vm, jsonrpc-pubsub, numext-fixed-uint-core.

make security-audit now exits 0 with zero errors.
@eval-exec eval-exec requested review from chenyukang and quake June 17, 2026 09:17
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.

1 participant