# Loans of tokens with >18 decimals can result in incorrect collateral calculation

LoanLib assumed collateral tokens have ≤18 decimals; a >18-decimal token underflows the exponent, yielding zero required collateral and enabling an uncollateralized loan.

- Payout: Audit contest
- Severity: medium
- Program: Maple Finance
- Disclosed: 2021-05-03
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-04-maple-findings/issues/4
- Library page: https://bugbountylibrary.com/r/c4%3A2021-04-maple%3AM-01
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** LoanLib.collateralRequiredForDrawdown in maple-core
**Root cause:** The final collateral calculation raises 10 to (18 - collateralDecimals); with collateralDecimals > 18 this underflows, the division yields 0, and required collateral computes to 0. No sanitization of token decimals occurs at Loan creation via the factory.
**Steps:**
1. Create a Loan via the factory using a collateral token with more than 18 decimals (no decimals check exists).
2. Call `collateralRequiredForDrawdown` in `LoanLib`; the `10 ** (18 - collateralDecimals)` term underflows.
3. Division yields 0, so the loan reports 0 collateral required.
4. Draw down the loan with no collateral posted and default.
**How found:** Code review of the final calculation in LoanLib.collateralRequiredForDrawdown revealed the implicit assumption that collateral decimals < 18, combined with the absence of decimal sanitization at Loan factory creation.
**Exploitation:** A user presents a Pool Delegate a seemingly innocuous loan using a >18-decimal collateral token with lucrative terms; once approved, the underflow makes collateralRequiredForDrawdown return 0, allowing drawdown with no collateral and subsequent default.
**Insight:** When a library computes `10 ** (18 - tokenDecimals)`, check whether tokenDecimals is bounded; tokens with >18 decimals (or unbounded factory inputs) turn the subtraction into an underflow that silently zeroes required collateral.

