Skip to content

fix(notify): refuse requests signed by an expired identity key - #662

Merged
PastaPastaPasta merged 1 commit into
masterfrom
fix/notify-key-expiry
Nov 22, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
fix/notify-key-expiry

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

forge-notify never checked an identity key's expiresAt. Since #659 it accepts wallet-granted ECDSA_HASH160 keys (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::IdentityKeyInfo now carries expires_at: Option<u64> (ms), taken from IdentityPublicKey v1 expires_at() in LoadedIdentity::public_keys().
  • auth::verify now takes the service clock in ms (it took seconds before; the skew check divides). It refuses a key whose expires_at <= now_ms with Unauthorized("key N has expired and cannot sign service requests"), the same style as the disabled-key refusal.
  • The check uses the clock at request time, not the cache time, so the 60 s key cache doesn't delay it.
  • docs/design/service-auth.md now lists "unexpired" among the key checks.

The other forge-core and forge-relay changes add expires_at: None to test fixtures.

Tests
an_expired_key_is_refused_for_either_key_type covers ECDSA_SECP256K1 and ECDSA_HASH160 keys 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 passed
  • cargo clippy -p forge-notify -p forge-core -p forge-relay --all-targets -- -D warnings: clean
  • cargo fmt --check: clean

🤖 Generated with Claude Code

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]>
@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 16 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: 7d21e2ee-267e-4a66-b20c-b9469e65d627
Commits

Reviewing files that changed from the base of the PR and between 3f93dce and 67bc41d.

Files selected for processing: 9

  • crates/forge-core/src/keyring.rs
  • crates/forge-core/src/platform/identity_keys.rs
  • crates/forge-core/src/platform/mod.rs
  • crates/forge-core/src/webhooks.rs
  • crates/forge-relay/src/subscriptions.rs
  • docs/design/service-auth.md
  • services/forge-notify/src/api.rs
  • services/forge-notify/src/auth.rs
  • services/forge-notify/tests/notify.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

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::signed passes now_ms(), and verify is its only production caller. The skew check uses now_ms / 1000, which gives the same value the removed now_secs() gave. The nonce TTL ((req.time + 2·MAX_SKEW_SECS) * 1000) is still in ms and still matches store::use_nonce. The test helper multiplies now * 1000, so the existing skew tests still exercise seconds.
  • Overflow: the expiry check only compares (at <= now_ms), with no arithmetic. req.time * 1000 is only reached after the skew check has bounded req.time to the current time ± 300s.
  • Boundary: expires_at <= now_ms means refused. That matches drive-abci (block_info.time_ms >= expires_at in validate_fees_of_event/v1 and validate_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: PlatformKeys caches the raw IdentityKeyInfo list, including expires_at. Expiry is checked in verify against the now_ms of 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_keys is the only non-test producer and fills k.expires_at() from the V1 getter. narrow.rs, the relay and the webhooks code all get their keys through it. IdentityKeyInfo derives 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' ENCRYPTION keys (is_usable_encryption_key, for ECDH decryption of the webhook secret). Platform refuses limits on anything other than AUTHENTICATION keys below MASTER (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_SECP256K1 and ECDSA_HASH160, and assert Unauthorized on 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_limits and public_keys now both read expires_at(). key_limits could build on IdentityKeyInfo, but that's cosmetic.

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

@PastaPastaPasta
PastaPastaPasta merged commit 9453ba4 into master Nov 22, 2026
20 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