Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: low
Invalid

toUint128() conversion can cause unexpected truncation

Summary

The _mint() and _burn() functions in both RToken and DebtToken convert amount from uint256 to uint128 using .toUint128().

If amount > uint128.max, this causes a silent truncation, potentially leading to incorrect balance tracking.

This happens in ReserveLibrary#updateInterestRatesAndLiquidity(), where liquidityAdded and liquidityTaken are converted.

While such large values are unlikely in normal use, it's still a potential overflow risk that could impact high-value protocols.

Vulnerability Details

Current _mint() and _burn() Implementation.

_mint(onBehalfOf, amountToMint.toUint128());
_burn(from, amount.toUint128());

If amountToMint > uint128.max, it gets silently reduced, meaning:

  • User receives a lower balance than expected.

  • Supply tracking becomes inaccurate.

If a large institution deposits a massive amount (e.g., 2^130 units), the amount overflows, leading to incorrectly minted RTokens.

If a massive repayment occurs using DebtToken#burn(), the burned amount may be lower than expected, leaving debt under-accounted.

Actually, the mint() and burn() are defined as follows:

function _mint(address account, uint256 value) internal {
...
function _burn(address account, uint256 value) internal {
...

Impact

User lose funds in deposit and get profit in withdraw.

Tools Used

manual

Recommendations

Don't use conversion.

- _mint(onBehalfOf, amountToMint.toUint128());
+ _mint(onBehalfOf, amountToMint);
- _burn(from, amount.toUint128());
+ _burn(from, amount);
- reserve.totalLiquidity = reserve.totalLiquidity + liquidityAdded.toUint128();
+ reserve.totalLiquidity = reserve.totalLiquidity + liquidityAdded.toUint128();
- reserve.totalLiquidity = reserve.totalLiquidity + liquidityTaken.toUint128();
+ reserve.totalLiquidity = reserve.totalLiquidity + liquidityTaken.toUint128();
Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.