Skip to content

fix(swift-sdk): cap the faucet captcha's aggregate proof-of-work#4100

Merged
QuantumExplorer merged 2 commits into
v4.1-devfrom
fix/faucet-captcha-pow-cap
Jul 12, 2026
Merged

fix(swift-sdk): cap the faucet captcha's aggregate proof-of-work#4100
QuantumExplorer merged 2 commits into
v4.1-devfrom
fix/faucet-captcha-pow-cap

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Hardening for the TestnetFaucet client that merged in #4098: its per-field challenge bounds (c ≤ 256, d ≤ 6) still admit an aggregate of ~4.3B expected SHA-256 attempts, so a misbehaving or compromised same-domain faucet endpoint can pin the device's cores across 256 parallel solver tasks until the 30-second timeout on every faucet tap. Add an aggregate bound (c × 16^d ≤ 64M, ~10× the live faucet's actual soft challenge of c=100, d=4 ≈ 6.6M) so oversized challenges throw and route to the web-faucet fallback instead of burning CPU/battery.

Split out of #4049 when that PR was narrowed to the send_payment fee fix — this commit was originally review hardening there (ad29deae05) and was deliberately parked for a standalone PR rather than dropped. One hunk, comment-documented; Swift parse-checked.

Note: the faucet client's placement in the SDK package is itself under review (it may move back app-side); if #4098 is reverted, this rides along with the file.

🤖 Generated with Claude Code

Review hardening on #4049: the per-field bounds still admitted
c=256, d=6 (~4.3B expected SHA-256 attempts) from a compromised or
misbehaving faucet endpoint — enough to pin the device CPU until the
30 s timeout on every faucet tap. Bound the aggregate expected work
(c x 16^d) at 64M attempts (~10x the live faucet's soft challenge);
costlier challenges throw and route to the web-faucet fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 12, 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: 38 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25c9c949-f9a0-44d3-a2e1-ee4fc47c69cf

📥 Commits

Reviewing files that changed from the base of the PR and between d6ba78a and 7ab9aa6.

📒 Files selected for processing (1)
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/TestnetFaucet.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/faucet-captcha-pow-cap

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.

@thepastaclaw

thepastaclaw commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit 7ab9aa6)

@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.

Code Review

This is a small, well-scoped hardening fix that adds an aggregate proof-of-work bound (c × 16^d ≤ 64M) after the existing per-field bounds check in TestnetFaucet.swift's solveCaptcha. Both agents verified the arithmetic against the stated live-faucet baseline (~6.6M) and worst-case (~4.3B) and confirmed the guard is correctly placed before any solver tasks spawn. Only one low-severity documentation nitpick was found; no correctness, security, or consensus-relevant issues.

Source (experiment sonnet-primary-opus-quarter-sample-20260710, cohort sonnet_primary, bucket 2, trigger new_pr, specialists none): reviewers codex/general=gpt-5.6-sol(completed); sonnet5/general=claude-sonnet-5(completed); verifier=verifier-sonnet5-4100-1783853670=claude-sonnet-5; orchestrator=openai/gpt-5.6-sol reasoning=high (orchestration-only, not a reviewer/verifier).

💬 1 nitpick(s)

Comment thread packages/swift-sdk/Sources/SwiftDashSDK/Utils/TestnetFaucet.swift Outdated
…p error

Review nitpick on #4100: the guard's message echoed only the raw c/d
inputs; surface expectedWork and the 64M threshold so production logs
show how close a drifting faucet endpoint is to the cap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@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.

Code Review

This new_push follow-up (b0f1ef17ab9aa6) makes exactly one change: the aggregate PoW-cap error message now reports the computed expectedWork value and the 64,000,000 threshold alongside c and d, directly resolving the sole prior nitpick. The guard's math and placement are unchanged and remain correct (c × 16^d ≤ 64M, checked before any solver tasks spawn). No new issues in this delta or across the cumulative PR.

Source (experiment sonnet-primary-opus-quarter-sample-20260710, cohort sonnet_primary, bucket 2, trigger new_push, specialists none): reviewers codex/general=gpt-5.6-sol(completed); sonnet5/general=claude-sonnet-5(completed); verifier=verifier-sonnet5-4100-1783854540=claude-sonnet-5; orchestrator=openai/gpt-5.6-sol reasoning=high (orchestration-only, not a reviewer/verifier).

@QuantumExplorer QuantumExplorer merged commit 74a37d3 into v4.1-dev Jul 12, 2026
16 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/faucet-captcha-pow-cap branch July 12, 2026 11:52
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