proofs.rs

Checksum-only data can pass a requested version check

Checksum-only data can pass a requested version check

Found in Report #19 v1 · Updated 2026-11-03 23:44 UTC

Description

A requested version can be accepted when the decoded payload is empty. This affects DecodeBuilder::with_check and DecodeBuilder::as_cb58.

Steps to Reproduce

With bs58 0.5.1 and the check and cb58 features enabled, run these assertions. Their success reproduces the discrepancy:

assert_eq!(bs58::decode("3QJmnh").with_check(Some(93)).into_vec(), Ok(vec![]));
assert_eq!(bs58::decode("45PJLL").as_cb58(Some(120)).into_vec(), Ok(vec![]));
Expected Behavior

The API promises to use the supplied version in verification. A requested version requires a nonempty payload whose first byte is that version, so these checksum-only inputs should be rejected.

Actual Behavior

Each input contains only the four checksum bytes of an empty unversioned payload. When the payload is empty, the decoder compares the first checksum byte to the requested version and returns an empty payload if they match. Consequently, success with a requested version does not guarantee that the returned data contains that version; callers relying on that property can accept malformed versioned input.

Environment

bs58 0.5.1 with check and cb58.

Additional Context

See upstream issue #132.

Change history
  1. v1 · created · 2026-11-03 23:44 UTC
    {
      "title": "Checksum-only data can pass a requested version check",
      "body": "## Description\n\nA requested version can be accepted when the decoded payload is empty. This affects `DecodeBuilder::with_check` and `DecodeBuilder::as_cb58`.\n\n## Steps to Reproduce\n\nWith bs58 0.5.1 and the `check` and `cb58` features enabled, run these assertions. Their success reproduces the discrepancy:\n\n```rust\nassert_eq!(bs58::decode(\"3QJmnh\").with_check(Some(93)).into_vec(), Ok(vec![]));\nassert_eq!(bs58::decode(\"45PJLL\").as_cb58(Some(120)).into_vec(), Ok(vec![]));\n```\n\n## Expected Behavior\n\nThe API promises to use the supplied version in verification. A requested version requires a nonempty payload whose first byte is that version, so these checksum-only inputs should be rejected.\n\n## Actual Behavior\n\nEach input contains only the four checksum bytes of an empty unversioned payload. When the payload is empty, the decoder compares the first checksum byte to the requested version and returns an empty payload if they match. Consequently, success with a requested version does not guarantee that the returned data contains that version; callers relying on that property can accept malformed versioned input.\n\n## Environment\n\nbs58 0.5.1 with `check` and `cb58`.\n\n## Additional Context\n\nSee [upstream issue #132](https://github.com/Nullus157/bs58-rs/issues/132).",
      "validity": "reported",
      "upstream_status": "not_reported"
    }

Read and join the discussion on the report →