Skip to content

rs-sdk: verify a fetched quorum key without reading it back from the provider's cache #5693

Open

Description

@PastaPastaPasta

After a context provider fetches a quorum key (fetch_quorum_public_key), Sdk::verify_fetching_quorum_key drops the returned key (Ok(Some(_)), packages/rs-sdk/src/sdk/quorum_key.rs) and verifies the response again. That second verification reads the key back from the provider through get_quorum_public_key.

So the second check passes only if the provider still holds the key. A provider with a bounded cache can evict it in between: a concurrent fetch of another quorum completes and pushes it out. The SDK then reports QuorumSourceUnavailable for a fetch that succeeded. No node is banned and no wrong key is accepted, but the request fails over and the key is fetched again.

#5523 rules this out for VerifiedHttpContextProvider by refusing a cache smaller than the number of active Platform quorums. That leaves the SDK depending on each provider's caching. Any other provider with a small cache, now or later, can hit the same race.

Proposed fix: run the second verification against a wrapper around the provider that answers the fetched quorum (type, hash) from the returned key, and delegates everything else to the provider. The key is used for exactly the proof it was fetched for, so caching no longer affects correctness.

Raised in review of #5523: #5523 (review)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions