Bound set-price-cap maxChangeE2bps to u64 on the number path - #2494
Bound set-price-cap maxChangeE2bps to u64 on the number path#24940x-SquidSol wants to merge 1 commit into
Conversation
…path The route rejects maxChangeE2bps > u64max only when it arrives as a string. On the `number` path it checked integer + non-negative but no upper bound, so a JS number like 1e21 (a non-negative integer that overflows u64) passed and was handed to encodeSetOraclePriceCap. Admin-only, so the impact is a malformed request rather than an attack — but it should 400, matching the string path. - set-price-cap: reject maxChangeE2bps > u64max on the number path too - add a regression test (1e21 rejected; legit values incl. MAX_SAFE_INTEGER pass) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@0x-SquidSol is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesPrice cap validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
dcccrypto
left a comment
There was a problem hiding this comment.
Correct. Suite: 2922 passed / 0 failed.
The natural worry with a u64 bound on a JS number is float precision — but the
check runs on maxChangeE2bps after BigInt(raw), so the comparison is exact
bigint-vs-bigint, not 1e21 > 1.8446744073709552e19 in double space. The
preceding Number.isInteger guard also means BigInt(raw) can't throw. Correct
by construction, and it now matches the string path exactly.
Merge check with #2493: both touch set-price-cap/route.ts (#2493 rewrites
isAuthorized at ~:83, this adds a check at ~:120). I merged them onto
playground in sequence — clean, and the combined file carries both changes.
Whichever lands second needs no rebase.
Test doesn't bind the fix. I deleted the new block — the bug fully restored —
and set-price-cap-u64-bound.test.ts stayed 3/3 green. Binding it means
importing the route and POSTing { maxChangeE2bps: 1e21 } with the admin header,
asserting 400. Reachable now that #2493 gives you checkAdminSecret to stub.
What
Reject
maxChangeE2bpsabove u64 max on the number input path of/api/oracle/set-price-cap(the string path already does this).Why
The number path validated integer + non-negative but had no upper bound, so a JS
number like
1e21(a non-negative integer that overflows u64) passed and was handedto
encodeSetOraclePriceCap. Admin-only, so the impact is a malformed requestrather than an attack — but it should return 400, consistent with the string path.
Changes
> 0xffff_ffff_ffff_ffffcheck on the number path.1e21rejected; legit values (incl.MAX_SAFE_INTEGER,0) pass;string-path parity documented.
Testing
npx tsc --noEmit— clean.oracle-set-price-cap— 2 files, 8 tests, all pass.Notes
Summary by CodeRabbit