Skip to content

fix(notify): accept wallet ECDSA_HASH160 keys on signed requests - #659

Merged
PastaPastaPasta merged 1 commit into
masterfrom
fix/notify-hash160-keys
Nov 22, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
fix/notify-hash160-keys

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Problem

Released Dash wallets (for example DashPay Android 11.9.2 over App Connect v2) give the browser an AUTHENTICATION/HIGH key of type ECDSA_HASH160. On chain, that key stores only hash160(compressed pubkey). forge-notify accepted only ECDSA_SECP256K1 keys and checked signatures against the on-chain data as if it were a full public key. So anyone signed in with a wallet got "key N cannot sign service requests" in the notify panel and couldn't set up email or push. This blocks making wallet sign-in the primary sign-in (docs/design/wallet-primary.md).

Fix

  • forge-notify (src/auth.rs): SignedEnvelope takes an optional public_key field (base64, 33-byte compressed key), and deny_unknown_fields stays.
    • An ECDSA_HASH160 AUTHENTICATION key verifies only if public_key is present, parses as a compressed secp256k1 key, and hashes to the key's data. The signature is then checked against that key.
    • An ECDSA_SECP256K1 key works as before. If it sends public_key, the value must equal the key's data or the request is refused.
    • Level, disabled and bounds rules are unchanged, and so is domain separation.
    • A malformed public_key is refused before the Platform key read.
  • CLI example (examples/request.rs): sends public_key when the identity-file entry's keyType is ECDSA_HASH160.
  • forge-web:
    • AuthSession now records the signing key's keyType, read from the on-chain key when the session opens.
    • serviceKey() returns that key type only while the session is still on the stored key.
    • The new signEnvelope adds public_key only for an ECDSA_HASH160 key.
    • serviceKey() also used to send a pasted raw key's id as -1. It now uses the key id found on chain.
  • Docs: docs/design/service-auth.md documents the new field. docs/design/wallet-primary.md no longer says notify already accepts wallet keys.

Deploy notes

  • The notify server has to be redeployed before wallet users can use notifications.
  • Old servers are unaffected: the client sends public_key only for HASH160 keys, and old servers never accepted those. Every key that works on an old server today keeps working, with the same envelope as before.

Follow-up (not in this PR)

forge-notify doesn't check key expiry. IdentityKeyInfo has no expires_at, so a key that expired on Platform but was never disabled can still sign service requests. This was already true for limited SECP keys. It matters more now that wallet grants, which always expire, go through this path. The fix would be to expose expires_at (key_limits already reads it) and refuse expired keys.

Tests

  • cargo test -p forge-notify: new auth tests cover a HASH160 key with the right pubkey, and refusal with a missing pubkey, a pubkey whose hash doesn't match, a pubkey the signature doesn't verify against, an uncompressed or non-base64 pubkey, and a MASTER-level key. Also covered: a SECP256K1 key with a mismatching public_key, serde (public_key accepted, publicKey refused), and a hash160 vector. cargo clippy -p forge-notify --all-targets -D warnings is clean.
  • forge-web:
    • lib/notify/client.test.ts checks that a SECP256K1 envelope stays exactly {request, signature}, and that a HASH160 envelope carries a pubkey that verifies.
    • lib/auth/service-key.test.ts checks that the key type is carried, that a pasted key gets its on-chain id, and that the type is dropped after a renewal stores a new key.
    • vitest lib/auth lib/notify components/notify: 537 passed. tsc --noEmit, eslint and lint:copy are clean.

🤖 Generated with Claude Code

Dash wallets grant the browser an AUTHENTICATION/HIGH ECDSA_HASH160 key
through App Connect, whose on-chain data is only the hash160 of the public
key. forge-notify accepted ECDSA_SECP256K1 keys only, so a user signed in
with a wallet could not change email or push settings.

The envelope takes an optional public_key (base64, 33-byte compressed).
An ECDSA_HASH160 key verifies only when it is sent and hashes to the key's
data; an ECDSA_SECP256K1 key keeps working without it and refuses one that
is not its data. The web client records the session key's type and sends
public_key only for an ECDSA_HASH160 key, so services from before this
change, which refuse unknown fields, keep accepting every key they did.
serviceKey() also names a pasted key by its on-chain id instead of -1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8cb85e35-62f5-458e-83e3-855aba6e844c
Commits

Reviewing files that changed from the base of the PR and between 2728289 and 9b2eacf.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 9

  • docs/design/service-auth.md
  • docs/design/wallet-primary.md
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/auth/service-key.test.ts
  • forge-web/lib/notify/client.test.ts
  • forge-web/lib/notify/client.ts
  • services/forge-notify/Cargo.toml
  • services/forge-notify/examples/request.rs
  • services/forge-notify/src/auth.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve

Security review of head 9b2eacf (services/forge-notify/src/auth.rs, forge-web/lib/notify/client.ts, forge-web/lib/auth/controller.ts, docs).

Key binding: sound. public_key sits outside the signed bytes, and that is fine here. To be accepted it must hash160 to the key data read from Platform with proofs, and the signature must verify under it. If an attacker could choose a public_key for someone else's HASH160 key, they would need a RIPEMD160(SHA256) second preimage plus a valid signature under that key. ECDSA public-key recovery only yields keys tied to some signature, not keys that hash to a chosen value. Only 33-byte input is accepted, and a secp256k1 point has exactly one compressed encoding, so there is no alternate encoding of the same point that hashes differently. Stripping or swapping the field in transit makes the request fail and nothing worse. Putting it inside the signed bytes would add nothing.

Key validity and type: sound.

  • usable_signing_key still requires the key to be enabled, AUTHENTICATION, HIGH/CRITICAL and Forge-bounded, now for both types. MASTER HASH160 is refused (tested).
  • Other types are refused before signing_public_key runs: BLS, EDDSA_25519_HASH160, BIP13_SCRIPT_HASH.
  • A SECP256K1 key with a public_key must byte-equal the key data, so a SECP key plus a bogus key is refused (tested).
  • A HASH160 key with no public_key is refused (tested).
  • The "ECDSA_HASH160" string matches forge-core's KeyType mapping (platform/mod.rs:412).

Compatibility and replay: unchanged.

  • #[serde(default)] keeps old two-field envelopes parsing, and deny_unknown_fields is kept (tested).
  • The web client sends public_key only for type 2, so SECP sessions send the exact same body to pre-change services.
  • The nonce is still consumed in api.rs after verify, keyed by identity:nonce. A replay with a different public_key hits the same nonce.

Parsing: sound.

  • Base64 is strict STANDARD.
  • PublicKey::from_slice plus the explicit len == 33 check refuse uncompressed and hybrid encodings (uncompressed is tested).
  • The input is parsed before any Platform read, so garbage costs no network work.

Findings (non-blocking):

  1. Pre-existing, now more exposed: key expiry. The service still does not check a key's expiresAt, even though consensus refuses expired keys and the web's findSigningKey skips them (forge-web/lib/sdk/write.ts:130). Wallet App Connect grants are exactly the keys that tend to carry an expiry. So this PR widens the existing gap: an expired wallet grant that is still enabled could keep signing notify requests until someone disables it. This doesn't block the PR, but the expiry follow-up should land soon. IdentityKeyInfo would need to carry expires_at from the proof read.
  2. Nit: a HASH160 key is only accepted when its hash is of the compressed public key. That matches DashPay wallets and fails closed otherwise, so it's fine. It could get one line in service-auth.md, which already says "33-byte compressed".
  3. Nit, web: serviceKey() now names a pasted key (keyId: -1) by the id found on chain. That is a real fix bundled in, and service-key.test.ts covers it.

Tests run locally

  • cargo test -p forge-notify: 31/31 pass (28 lib, including the 4 new auth tests, plus 3 integration).
  • vitest run lib/notify/client.test.ts lib/auth/service-key.test.ts: 9/9 pass.

Negative cases covered: wrong public key, right public key with someone else's signature, missing public key, uncompressed, non-base64, MASTER level, SECP plus a foreign key, and an unknown publicKey field.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit 57089cd into master Nov 22, 2026
39 checks passed
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