Potential zero transfer issue in UStbMinting
contract's _transferCollateral
function due to small amountToTransfer
calculation
#9
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-11-ethena-labs/blob/main/contracts/ustb/UStbMinting.sol#L612
Vulnerability details
Impact
Incorrect Distribution: Small collateral amounts may result in zero transfers to some addresses in
route.addresses
, leaving only the last address with the full collateral.Operational Imbalance: Custody wallets expecting specific collateral shares may receive nothing, creating operational inconsistencies.
Trust and Compliance Risks: Unbalanced collateral routing could lead to trust issues and potential regulatory or contractual concerns, particularly for users relying on predictable distribution.
Proof of Concept
Setup and Conditions:
amount
to transfer is smaller thanROUTE_REQUIRED_RATIO
(10,000).amount
among several addresses, but becauseamount
is small, each calculatedamountToTransfer
will be zero due to integer division.Example Scenario:
amount = 5,000
ratios = [1, 1, 1, 9_997]
(for 4 addresses)ROUTE_REQUIRED_RATIO = 10,000
amountToTransfer
for each address:amountToTransfer[i] = 5_000 * 1 / 10,000 = 0
amount
going only to the last address.Demonstration Code:
Expected Outcome:
5,000
.Recommended Mitigation Steps
Minimum Transfer Check: Ensure
amountToTransfer
is > 0 before transferring; if zero, redistribute or adjust to ensure all addresses receive a non-zero share.The text was updated successfully, but these errors were encountered: