Skip to content

fix(sdk): enforce response freshness anchors - #4167

Merged
QuantumExplorer merged 3 commits into
v4.1-devfrom
codex/fix-sdk-freshness-parsing
Jul 21, 2026
Merged

fix(sdk): enforce response freshness anchors#4167
QuantumExplorer merged 3 commits into
v4.1-devfrom
codex/fix-sdk-freshness-parsing

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Summary

  • enable a signed-metadata time freshness anchor by default for network SDK builders, with an explicit trusted-height alternative
  • validate time before advancing a monotonic, concurrency-aware height high-water mark
  • reject proof-enabled network configurations that disable every independent freshness anchor
  • parse every current-quorum hash through one checked 32-byte conversion, including nested validator sets

This addresses security review findings DS-CAND-232, 249, and 267.

Compatibility

Network builders now default to a 31-minute signed-time window. Deployments with intentionally unsynchronized clocks or longer network pauses should configure an appropriate time tolerance or seed a trusted initial Platform height. Mock builders retain their previous no-time-check default.

Validation

  • cargo check -p dash-sdk --lib
  • cargo check -p drive-proof-verifier --lib
  • cargo test -p dash-sdk --lib sdk::test:: (46 passed)
  • cargo test -p drive-proof-verifier --lib unproved::tests:: (7 passed)
  • cargo clippy -p dash-sdk -p drive-proof-verifier --lib --no-deps -- -D warnings
  • cargo fmt --all
  • git diff --check

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4760ae0-7862-4a08-ba31-2f65d90d5278

📥 Commits

Reviewing files that changed from the base of the PR and between c311c7e and 4585c42.

📒 Files selected for processing (4)
  • .github/workflows/swift-sdk-build.yml
  • packages/rs-drive-proof-verifier/src/unproved.rs
  • packages/rs-sdk/src/sdk.rs
  • packages/swift-sdk/build_ios.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-sdk-freshness-parsing

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

Comment @coderabbitai help to get the list of available commands.

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review July 21, 2026 02:04
@thepastaclaw

thepastaclaw commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 24 ahead in queue (commit 4585c42)
Queue position: 25/25

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Preliminary review — Codex only

The PR improves the default freshness policy and correctly prevents stale-time responses from mutating the height watermark, but the new trusted-height alternative does not provide the promised independent anchor in every accepted configuration. Address trunk responses bypass height validation entirely when time validation is disabled, and trusted heights at or below their rollback tolerance impose no effective lower bound.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (completed), gpt-5.6-sol — security-auditor (completed), gpt-5.6-sol — rust-quality (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 2 blocking

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-sdk/src/sdk.rs`:
- [BLOCKING] packages/rs-sdk/src/sdk.rs:278-282: Height-only mode leaves address trunk proofs without a freshness anchor
  The builder now accepts a proof-enabled network SDK with time validation disabled when a trusted initial height and height tolerance are configured, but `freshness_criteria` unconditionally disables height validation for `get_addresses_trunk_state`. This produces `(None, None)` for the signed trunk response in that supported configuration. The trunk proof and metadata describe the node's latest stored checkpoint, and the address scan uses its returned height and root to pin all subsequent branch requests. A stale node can therefore replay an old, correctly signed checkpoint without comparing it to the caller's trusted height. The incremental catch-up does not make this safe because its first query treats failures as non-fatal and can return the accepted stale trunk state. Apply a trusted-height check suitable for checkpoint responses or reject time-disabled configurations for operations that require address trunk synchronization.
- [BLOCKING] packages/rs-sdk/src/sdk.rs:1093-1094: Builder accepts trusted heights that impose no freshness floor
  `has_height_anchor` checks only that the height and tolerance options are present. A configuration such as `with_trusted_initial_height(0)` or any trusted height less than or equal to its tolerance therefore passes construction with time validation disabled. In `verify_metadata_height`, the stale-response comparison is skipped whenever `expected_height <= tolerance`, so every possible response height is accepted and the first historical response establishes the effective watermark. Require the trusted height to exceed the configured rollback tolerance and add builder tests for zero and `height <= tolerance`.

Comment thread packages/rs-sdk/src/sdk.rs
Comment thread packages/rs-sdk/src/sdk.rs Outdated
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.45%. Comparing base (c311c7e) to head (4585c42).
⚠️ Report is 4 commits behind head on v4.1-dev.

Additional details and impacted files
@@            Coverage Diff             @@
##           v4.1-dev    #4167    +/-   ##
==========================================
  Coverage     87.44%   87.45%            
==========================================
  Files          2648     2648            
  Lines        334178   334327   +149     
==========================================
+ Hits         292230   292372   +142     
- Misses        41948    41955     +7     
Components Coverage Δ
dpp 88.44% <ø> (ø)
drive 86.13% <ø> (+<0.01%) ⬆️
drive-abci 89.57% <ø> (+<0.01%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.90% <ø> (+0.01%) ⬆️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.66% <ø> (+0.11%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumExplorer

Copy link
Copy Markdown
Member Author

Reviewed

@QuantumExplorer
QuantumExplorer merged commit 6cabd2c into v4.1-dev Jul 21, 2026
23 of 24 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/fix-sdk-freshness-parsing branch July 21, 2026 13:34
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