Repository navigation
fix(notify): refuse requests signed by an expired identity key - #662
Conversation
forge-notify never checked a key's expiry, so a wallet-granted ECDSA_HASH160 key (App Connect v2, always time-limited) could keep signing notify requests after it expired, as long as nobody disabled it. Platform refuses such keys and the web client skips them. IdentityKeyInfo now carries the key's protocol-14 expires_at, and verify takes the service clock in ms and refuses a key whose expiry is at or before it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou'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 16 minutes. View limit details
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. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
Reviewed head 67bc41d. Locally, cargo test -p forge-notify -p forge-relay and cargo test -p forge-core --lib both pass (forge-core: 1225 passed, 3 ignored). The new an_expired_key_is_refused_for_either_key_type test passes.
Checked, no issues
- Units:
api::signedpassesnow_ms(), andverifyis its only production caller. The skew check usesnow_ms / 1000, which gives the same value the removednow_secs()gave. The nonce TTL ((req.time + 2·MAX_SKEW_SECS) * 1000) is still in ms and still matchesstore::use_nonce. The test helper multipliesnow * 1000, so the existing skew tests still exercise seconds. - Overflow: the expiry check only compares (
at <= now_ms), with no arithmetic.req.time * 1000is only reached after the skew check has boundedreq.timeto the current time ± 300s. - Boundary:
expires_at <= now_msmeans refused. That matches drive-abci (block_info.time_ms >= expires_atinvalidate_fees_of_event/v1andvalidate_identity_public_keys_limits) and forge-core's own pre-write check (platform/mod.rs,k.expires_at().filter(|e| *e <= now_ms)). - Key cache:
PlatformKeyscaches the rawIdentityKeyInfolist, includingexpires_at. Expiry is checked inverifyagainst thenow_msof each request, so a cached key stops working as soon as it expires, not up to 60s later. The doc line is accurate. - Producers / serde:
LoadedIdentity::public_keysis the only non-test producer and fillsk.expires_at()from the V1 getter.narrow.rs, the relay and the webhooks code all get their keys through it.IdentityKeyInfoderives no Serialize or Deserialize, and I found no persisted or cached JSON form, so there is no compatibility concern. - forge-relay: it doesn't need this check. It only reads writers'
ENCRYPTIONkeys (is_usable_encryption_key, for ECDH decryption of the webhook secret). Platform refuses limits on anything other thanAUTHENTICATIONkeys belowMASTER(IdentityPublicKeyLimitsNotAllowedError), so an encryption key can never carry an expiry. - Tests: they cover None, now+1, now (the boundary) and now−1, for both
ECDSA_SECP256K1andECDSA_HASH160, and assertUnauthorizedon refusal.
Nits (non-blocking)
- The service compares against its own wall clock, and Platform compares against block time. When the service clock runs ahead of the last block, a key is refused a little before Platform would refuse it. That errs on the safe side, so no change is needed.
LoadedIdentity::key_limitsandpublic_keysnow both readexpires_at().key_limitscould build onIdentityKeyInfo, but that's cosmetic.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
forge-notify never checked an identity key's
expiresAt. Since #659 it accepts wallet-grantedECDSA_HASH160keys (App Connect v2), and those always carry an expiry. So a grant that expired but was never disabled could still sign notify requests: read your email address, change prefs, export or delete your data. Platform refuses expired keys, and the web client skips them (forge-web/lib/sdk/write.ts).Fix
forge_core::platform::IdentityKeyInfonow carriesexpires_at: Option<u64>(ms), taken fromIdentityPublicKeyv1expires_at()inLoadedIdentity::public_keys().auth::verifynow takes the service clock in ms (it took seconds before; the skew check divides). It refuses a key whoseexpires_at <= now_mswithUnauthorized("key N has expired and cannot sign service requests"), the same style as the disabled-key refusal.docs/design/service-auth.mdnow lists "unexpired" among the key checks.The other forge-core and forge-relay changes add
expires_at: Noneto test fixtures.Tests
an_expired_key_is_refused_for_either_key_typecoversECDSA_SECP256K1andECDSA_HASH160keys four ways: no expiry (accepted), expiring 1 ms after now (accepted), expiring at now (refused) and expiring 1 ms before now (refused).cargo test -p forge-notify: 29 + 3 passedcargo clippy -p forge-notify -p forge-core -p forge-relay --all-targets -- -D warnings: cleancargo fmt --check: clean🤖 Generated with Claude Code