fix(security): bound vault and asset decimals to MAX_DECIMALS (closes #84)#233
fix(security): bound vault and asset decimals to MAX_DECIMALS (closes #84)#233thedavidmeister wants to merge 7 commits into
Conversation
…ent overflow DoS Adds MAX_DECIMALS=36 constant and UnsupportedDecimals error to LibERC4626. _decode() now reverts if vault.decimals() or asset.decimals() exceeds the bound, closing the griefing vector where a malicious vault could trigger toFixedDecimalLossless overflow via an arbitrarily large decimals value. Regenerates ERC4626Words.pointers.sol with updated BYTECODE_HASH. Adds four mutation-validated tests for both conversion paths. Closes #84 Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Walkthrough
ChangesDecimals upper-bound enforcement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
…TP 429 rate-limit flake) Co-Authored-By: Claude <noreply@anthropic.com>
…TP 429 rate-limit transient) Co-Authored-By: Claude <noreply@anthropic.com>
…TP 429 rate-limit transient, 3rd)
Co-Authored-By: Claude <noreply@anthropic.com>
Summary
uint8 constant MAX_DECIMALS = 36anderror UnsupportedDecimals(address token, uint8 decimals)toLibERC4626.solat file scope._decode()now reverts withUnsupportedDecimalsifvault.decimals()orasset.decimals()exceedsMAX_DECIMALS, closing the griefing vector where a malicious vault could supply an arbitrarily large decimals value to causetoFixedDecimalLosslessto overflowuint256on any non-trivialFloatinput.src/generated/ERC4626Words.pointers.solwith updatedBYTECODE_HASH.testShareDecimalsAboveMaxRevertsConvertToAssets,testShareDecimalsAboveMaxRevertsConvertToShares,testAssetDecimalsAboveMaxRevertsConvertToAssets,testAssetDecimalsAboveMaxRevertsConvertToShares) — each asserts the exactUnsupportedDecimalsselector and address; removing either guard causes the corresponding expectRevert to fail.Closes #84
Test plan
forge test— 127 tests passed, 0 failed, 0 skipped.forge fmt— no changes.testBytecodeHashMatchesDeployedCodepasses.Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit
Bug Fixes
Tests