Core Contracts

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

Decimal Precision Mismatch in Auction's buy() Function Leads to Incorrect Price Calculations

Summary:

The Auction contract's buy() function fails to handle decimal precision differences between ZENO (18 decimals) and USDC (6 decimals) tokens, leading to incorrect price calculations and potential transaction failures due to arithmetic overflow.

Vulnerability Details:

In the Auction contract's buy() function:

function buy(uint256 amount) external whenActive {
// ... checks ...
uint256 price = getPrice();
// ❌ WRONG: No decimal normalization
uint256 cost = price * amount; // Potential overflow and incorrect calculation
require(usdc.transferFrom(msg.sender, businessAddress, cost), "Transfer failed");
// ... rest of function
}

Example:

Buying 5 ZENO at 3 USDC each:

Current implementation:

  • amount: 5e18 (5 ZENO)

  • price: 3e6 (3 USDC)

  • cost: 3e6 * 5e18 = 15e24 (incorrect)

Expected cost: 15e6 (15 USDC)

Impact:

  • Most transactions will revert due to exceeding user's USDC balance

  • If a transaction succeeds, users would be charged astronomical amounts

Tools Used:

Manual code review

Recommendations:

  • Normalize the decimal precision before multiplication:

function buy(uint256 amount) external {
// Adjust amount to match USDC decimals (6)
uint256 normalizedAmount = amount / 1e12; // Convert from 18 to 6 decimals
uint256 cost = price * normalizedAmount;
// ... transfer logic
}
  • Add decimal safety checks and tests to verify correct price calculations across different decimal combinations

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Auction.sol's buy() function multiplies ZENO amount (18 decimals) by price (6 decimals) without normalization, causing users to pay 1 trillion times the intended USDC amount

Support

FAQs

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