Skip to main content
Menu
Advisories

Security check bypass

GHSA-5VMP-9HJC-RFWPPublished Updated GitHub

Description

An authorized review of TS Stack wallet and payment components at source commit 76760e9fe69efe38dbb7b09175adfea79b657aa1, followed by a focused continuation against public main at c42233af7cfd, found multiple authorization, payment-validation, cryptographic-verification, and credential-boundary failures.

The most serious flaws allow a malicious dApp to reuse or share one spending approval across multiple operations, undercount prior spending, or mix an existing BTMS asset spend into an action classified as issuance. A separate BRC-121 subject-confusion flaw permits an attacker to satisfy a paid route with a one-satoshi payment while the server prices an unrelated high-value transaction. Cryptographic-verification results were also ignored in global KV and identity-certificate paths, allowing forged controller state or identity credentials to be returned, stored, published, or trusted. Wallet Relay accepted unsigned or insecure pairing metadata and implicitly approved privileged methods when no approval callback was configured.

Additional affected surfaces exposed wallet credentials through non-TLS transport, dependency debug/error logging, or process arguments. Origin-policy findings are intentionally excluded. No active exploitation has been observed. All reproductions and regression tests use synthetic keys, transactions, and fixtures.

The coordinated remediation passed exact-head CI, CodeQL, conformance, and container checks on the advisory's private fork, then merged through PR #527 as public main commit 99f5f5faa171c0a8782724afe494338a07845cf4. Patched npm packages, signed container images, and the staged WAB vault rollout are complete.

Affected and patched releases

ComponentLatest confirmed affected versionPatched version
@bsv/wallet-toolbox2.11.02.12.0
@bsv/wallet-toolbox-client2.11.02.12.0
@bsv/wallet-toolbox-mobile2.11.02.12.0
@bsv/btms-permission-module1.1.41.2.0
@bsv/wallet-relay0.3.60.4.0
@bsv/fund-wallet1.4.41.5.0
@bsv/402-pay0.2.50.3.0
@bsv/sdk2.4.22.5.0
private WAB server1.7.01.8.1

The 2.11.0 Wallet Toolbox family was checked and retains the certificate-verification failure and earlier wallet findings. Every listed npm patch is published on its package's latest tag. All coordinated public packages remain within their existing major lines; valid API, wire, snapshot, and token contracts remain unchanged. The same protected cascade also published the newly created @bsv/lch 0.1.0 and @bsv/ecpm-permission-module 0.1.0 packages after establishing their npm trusted publishers.

Finding 1: spending approval reuse, coalescing, and incomplete accounting

WalletPermissionsManager cached a successful spending authorization under an amount-scoped key. Repeating the same amount within the cache window could bypass a fresh accounting check. Concurrent equal-value requests also shared one pending prompt, so one grant, including an ephemeral grant, resolved every waiter. Finally, querySpentSince did not paginate listActions; its default page omitted older matching monthly actions.

This chain can cause the wallet to sign transactions beyond the amount the user approved, producing direct BSV loss.

The fix never caches or recent-grant-bypasses spending, gives every spending prompt a distinct monotonic request ID, and reads all action pages before authorizing. Regression tests cover repeated equal-value spends, concurrent ephemeral prompts, complete pagination, and an empty-page fail-safe.

Finding 2: mixed BTMS issuance and spend bypasses approval

BasicTokenModule auto-approved the complete action when any output had an exact issuance marker, without first excluding caller-supplied inputs. A malicious action could therefore spend an existing BTMS input while adding an issuance-tagged output and proceed into transaction-bound signing without the expected prompt.

The fix permits automatic issuance only when inputs are absent or an empty array and an exact issuance marker is present. Non-array, nonempty, mixed, malformed, or unmarked actions follow the normal approval path.

Finding 3: Wallet Relay pairing and approval fail open

WalletPairingSession dispatched implemented privileged methods when onApprovalRequired was absent. Pairing accepted remote HTTP origins, signature verification treated a missing signature as valid, and relay resolution did not enforce verification first. A directly configured WalletRelayClient.apiUrl also accepted remote HTTP.

Chaining attacker-controlled or altered pairing data with implicit privileged approval could lead to unauthorized asset-moving wallet calls.

The fix rejects every non-auto-approved method unless an explicit callback approves it, requires a valid pairing signature before any origin request, requires HTTPS outside explicit loopback development for pairing origins and absolute relay API URLs, and rejects ambiguous URL credentials, queries, fragments, protocol-relative forms, and backslash paths. Root-relative same-origin APIs and loopback HTTP remain supported.

Finding 4: wallet storage and mobile event credentials cross insecure or loggable boundaries

The shared remote storage constructor used by Node, browser, and mobile accepted remote HTTP endpoints. BRC-100 authentication and wallet storage traffic could therefore cross a network without TLS. ArcSSEClient likewise accepted remote HTTP while carrying a stable wallet callback token and optional ARC API key. It also enabled third-party EventSource debug output and serialized error objects that can contain the credential-bearing URL or headers.

The fix requires absolute, credential-free HTTPS for remote storage and Arcade SSE, with HTTP allowed only on explicit loopback hosts. It rejects query and fragment ambiguity, disables EventSource dependency debugging, and logs only a generic SSE connection error rather than serializing transport objects.

Finding 5: funding CLI exposes a wallet private key

fund-metanet required a private key in --private-key, exposing it to shell history, process inspection, telemetry, and support captures. Its interactive readline prompt echoed the key.

The fix rejects both separate and = private-key argument forms, uses a raw-mode non-echoing TTY prompt even when stdout is redirected, and retains unattended operation through a protected stdin file descriptor or secret-mounted file. Non-secret options are validated before the secret is requested.

Finding 6: BRC-121 Atomic BEEF subject confusion permits payment bypass

@bsv/402-pay parsed the supplied Atomic BEEF but selected beefObj.txs.at(-1) for the transaction ID and output-value check. Wallet Toolbox correctly selected the transaction declared by the BRC-95 atomicTxid and reduced over-inclusive envelopes to that subject's dependency closure before internalization. The server and wallet therefore authenticated different transactions from the same byte string.

A synthetic proof supplied a correctly formed one-satoshi payment as the declared atomic subject and placed an unrelated 1,000-satoshi transaction last. For a route priced at 100 satoshis, the vulnerable server returned { accepted: true, satoshisPaid: 1000 } and served the route while the wallet internalized only the one-satoshi subject. This is a complete, repeatable underpayment of a real payment gate; it does not rely on invalid cryptography or an origin-policy bypass.

The fix requires strict BRC-95 framing, requires a resolvable atomic subject, canonicalizes the envelope to that subject and its recursive dependencies, checks the selected output on the subject transaction, gives only the canonical bytes to the wallet, and requires internalizeAction.accepted === true. Plain BEEF, trailing bytes, insufficient subject outputs, replay merges, and non-affirmative wallet results fail closed. Legacy over-inclusive Atomic BEEF remains compatible but unrelated branches cannot influence price or internalization.

Finding 7: GlobalKVStore accepts forged controller-signed state

GlobalKVStore.hasValidOverlaySignature awaited ProtoWallet.verifySignature but ignored its { valid: false } result and returned true unless the verifier threw. Overlay lookup responses are untrusted, so a malicious or compromised lookup host could fabricate a value naming any controller and have applications consume it as controller-authenticated global state. Configuration, service discovery, feature controls, or other authorization-sensitive data stored in GlobalKVStore could consequently be replaced without the controller's key.

The fix returns the verifier's affirmative valid result and rejects both false verdicts and errors. A regression test distinguishes a normal false signature verdict from an exception and confirms the forged entry is omitted.

Finding 8: certificate signature failures can become stored, published, or trusted identities

Four certificate boundaries called Certificate.verify() or VerifiableCertificate.verify() but ignored the returned boolean:

  • Wallet Toolbox direct acquisition could store a supplied certificate after verify() returned false.
  • Issuer-mediated acquisition could store a response certificate after verify() returned false even though other nonce and response fields were checked.
  • SDK IdentityClient.publiclyRevealAttributes could publish a signature-invalid certificate.
  • Wallet Toolbox identity discovery decrypted and trust-scored an untrusted overlay certificate after verify() returned false. A forged certificate could claim a configured trusted certifier and contribute that certifier's trust to an attacker-selected subject.

Together these paths allow forged identity credentials to enter a wallet, be made public, or be returned to applications as trusted identity evidence. A malicious dApp or untrusted/compromised overlay response can exploit the direct and discovery paths without possessing the claimed certifier's private key.

The fix requires an affirmative verification result before storage or publication, and verifies discovered certificates before decrypting fields or assigning trust. Regression tests prove false verdicts leave wallet storage empty, prevent publication, and omit forged discovery results.

WAB defense in depth and compatible rollout

The WAB server must ultimately be able to return a presentation key after successful authentication. Runtime access to the server and its vault key therefore remains inside the trusted boundary; this mitigation protects against database-only disclosure and does not claim to protect keys from a fully compromised WAB process.

Version 1.8.1 adds nullable keyed-lookup and AES-256-GCM ciphertext sidecars through a schema-only migration. With no new configuration it remains in legacy plaintext mode. A staged rollout is supported without changing the HTTP API or values returned to legacy clients:

  1. Apply the additive schema and deploy the new binary in legacy mode.
  2. Configure a separately backed-up 32-byte key and use dual-write; startup idempotently backfills sidecars while plaintext remains available to old replicas.
  3. Drain every old replica, complete one final dual-write reconciliation, then explicitly switch all replicas to encrypted; startup redacts plaintext before listening.

Reads and lookups remain compatible with rows written by an old replica during dual-write. Reconciliation uses row locks, batches of 500, and restart-safe updates. Do not start an old binary after encrypted cutover. Rollback to one requires a controlled plaintext restoration using the same vault key.

Snapshot boundary

Wallet snapshots are intentionally self-contained and include the key needed to restore their sensitive wallet state. The format and APIs are unchanged. This is not treated as a breaking-format vulnerability: access to a snapshot is access to the wallet. Documentation now directs browser, mobile, and Node consumers to store the complete snapshot only in an OS Keychain, hardware-backed keystore, or comparably trusted secret store, never ordinary local/AsyncStorage, logs, analytics, crash reports, clipboards, unprotected sync, or unprotected backups.

Validation

  • @bsv/402-pay: 112 tests across four files passed with 98% branch and 100% line/function coverage. Build, strict typecheck, zero-warning lint, formatting, package artifact, ESM/CJS clean-consumer, and exact-tarball Vite/esbuild browser gates passed.
  • @bsv/sdk: 5,943 tests across 157 suites passed. Build, strict typecheck, zero-warning lint, formatting, package artifact, ESM/CJS clean-consumer, UMD, Vite, and esbuild browser gates passed.
  • Wallet Toolbox: 226 suites passed; 2,171 tests passed and one intentional test skipped. Build, strict typecheck, zero-warning lint, package artifact, clean CJS consumer, and formatting gates passed.
  • Browser client: 19 tests plus build, typecheck, lint, exact-tarball Vite/esbuild browser, ESM/CJS clean-consumer, package, and governed size gates passed.
  • Mobile client: 42 tests plus build, typecheck, lint, exact-tarball Metro/Hermes, ESM/CJS clean-consumer, package, and governed size gates passed.
  • BTMS permission module: 42 tests plus build, typecheck, lint, package, and clean-consumer gates passed.
  • Wallet Relay: 150 tests plus build, typecheck, lint, exact-tarball browser, Express 4/5 clean-consumer, and package gates passed.
  • Fund Wallet: 17 tests plus build, typecheck, lint, installed-CLI, and package gates passed.
  • WAB: 132 tests across 18 suites plus build and zero-warning lint passed, including schema-only migration, legacy behavior, idempotent dual-write, old-replica compatibility, encrypted cutover, ciphertext tampering, and plaintext-redaction tests.
  • Repository-wide build, strict typecheck, zero-warning lint, formatting, documentation policy, cross-package versions, generated package documentation, generated stack facts, service-operations facts, and package formatting checks passed.

Coordinated release and rollout

  • Protected release run 34513195518 published and independently reconciled @bsv/sdk 2.5.0, @bsv/402-pay 0.3.0, the Wallet Toolbox family 2.12.0, BTMS 1.2.0, Wallet Relay 0.4.0, Fund Wallet 1.5.0, and the other changed public packages with npm provenance. All exact versions were independently verified on their latest tags.
  • Generated dependency-sync PR #502 passed its exact-head audit, CI, CodeQL, conformance, and container checks and merged as 8c76b356e8ac4ecfd55cfa238041fe3c83b9b262.
  • Protected infrastructure release run 34520913354 built Linux/amd64 ChainTracks 1.1.17, Message Box 1.1.41, Overlay 2.1.35, UHRP Basic 0.1.36, UHRP Cloud Bucket 0.2.38, WAB 1.8.1, and Wallet Infra 2.0.39. Every image passed the zero-HIGH/CRITICAL Trivy gate and has an SPDX SBOM, GitHub provenance, a keyless Cosign signature, and post-release digest reconciliation.
  • WAB was backed up, then rolled through legacy, dual-write, an all-new idempotent reconciliation, and encrypted in staging before production. The second dual-write pass updated zero rows. Encrypted startup redacted two staging and 1,033 production user keys plus two production history rows before listening. Aggregate database checks found no eligible 64-hex plaintext keys or missing encrypted sidecars. Both environments finished 2/2 Ready on the signed 1.8.1 digest with zero restarts.
  • The released ChainTracks, Message Box, Overlay, WAB, and Wallet Infra images were promoted through managed staging before production where applicable. Final production monitoring completed 910 of 910 successful endpoint probes, and the closing fleet safety gate had no blocker.

Operators should upgrade payment-gated services, wallet applications, and SDK consumers to the patched versions. Custom BRC-121 clients must send strict Atomic BEEF rather than plain non-atomic BEEF. Do not run an older WAB binary after encrypted cutover; rollback requires controlled plaintext restoration using the retained vault key.

Affected versions

References

GitHub · bsv-blockchain/ts-stack