Skip to content

fix(web-bot-auth): fail closed on future created timestamps in Rust verify - #127

Open
SashaMIT wants to merge 2 commits into
cloudflare:mainfrom
SashaMIT:fix/rust-verify-fail-closed-on-future-created
Open

fix(web-bot-auth): fail closed on future created timestamps in Rust verify#127
SashaMIT wants to merge 2 commits into
cloudflare:mainfrom
SashaMIT:fix/rust-verify-fail-closed-on-future-created

Conversation

@SashaMIT

Copy link
Copy Markdown
Contributor

Summary

WebBotAuthVerifier::verify still accepted cryptographically valid signatures when created is in the future, even after #125 started failing closed on expires. The TypeScript web-bot-auth verifier already rejects those inputs (created in the future) before crypto verify.

This makes the Rust Web Bot Auth verifier fail closed on a future (or unparsable) created window, then on expiry, then proceeds to cryptographic verification only when the window is valid. That matches TypeScript packages/web-bot-auth/src/index.ts. Generic MessageVerifier::verify is unchanged. verify_ignore_expiry still runs crypto and now reports is_created_in_future on the advisory.

Threat model: an attacker who can mint a valid Ed25519 web-bot-auth signature (stolen bot key, or the bot itself) can set created=now+skew with expires still in the future. Rust currently treats that as valid; TypeScript rejects it. Same authority assumption as #125 for expiry.

Test plan

  • cargo +stable test --all --all-features (including new test_verify_rejects_created_in_the_future)
  • cargo +stable clippy --all-features --all-targets -- -D warnings
  • cargo +stable fmt --all -- --check
  • Revert-test: removing the created guard makes test_verify_rejects_created_in_the_future fail (Ok(SignatureTiming) instead of SignatureCreatedInFuture)
  • CI green on this PR

Made with Cursor

…erify

WebBotAuthVerifier::verify already rejects expired signatures after cloudflare#125,
but still accepted cryptographically valid signatures with created in the
future. The TypeScript web-bot-auth verifier rejects those before crypto
verify. Enforce the created window the same way, before expires, and
surface SignatureCreatedInFuture. verify_ignore_expiry still runs crypto
and reports the new advisory flag.
/// the message expired in the past.
pub is_expired: Option<bool>,
/// If the `created` tag was present on the message, whether or not
/// `created` is still in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove the word "still"

@SashaMIT

Copy link
Copy Markdown
Contributor Author

Dropped "still" from the created comment.

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.

2 participants