# transferredAmount on mainnet can be drained if a malicious account can mint more tokens on Schain

Schain ERC20 clone with self-granted MINTER_ROLE lets attacker mint tokens and exit to drain mainnet DepositBoxERC20 transferredAmount.

- Payout: Audit contest
- Severity: medium
- Program: SKALE
- Found by: kyliek
- Disclosed: 2022-11-11
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-02-skale-findings/issues/38
- Library page: https://bugbountylibrary.com/r/c4%3A2022-02-skale%3AM-07
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** ERC20 bridge (DepositBoxERC20 / TokenManagerERC20 / ERC20OnChain)
**Root cause:** ERC20OnChain grants MINTER_ROLE to the deployer in its constructor, so any registered Schain token deployer can mint arbitrary supply; exitToMainERC20 releases mainnet funds based solely on Schain token balance without verifying the mint came from bridging.
**Steps:**
1. Deploy an ERC20OnChain clone on Schain; constructor assigns MINTER_ROLE to deployer via `_setupRole(MINTER_ROLE, _msgSender())`.
2. Register it on TokenManagerERC20 via `addERC20TokenByOwner(targetChainName, erc20OnMainChain, erc20OnSchain)`.
3. Wait for users to deposit via `depositERC20`, growing `transferredAmount[schainHash][token]` on mainnet.
4. Call `mint(attacker, transferredAmount)` on the clone (attacker holds MINTER_ROLE).
5. Call `exitToMainERC20(contractOnMainnet, amount)` to release locked mainnet tokens to attacker.
**How found:** Code review of ERC20OnChain constructor and mint function alongside DepositBoxERC20's transferredAmount accounting, noting mint is callable by any MINTER_ROLE holder rather than only the bridge.
**Exploitation:** Attacker controls a registered Schain token's minter role, mints tokens equal to the locked mainnet deposit balance, then exits via TokenManagerERC20 to withdraw real mainnet tokens, stranding victims' funds on Schain.
**Insight:** On bridge audits, check whether the Schain-side token's mint authority is restricted to the bridge contract itself; if the token deployer retains mint rights, exit accounting based on Schain balances becomes forgeable.
