# ALP: public internal _swap mints redeemable ALP tokens

ALP's public internal _swap function let attacker mint ALP tokens to the VUN contract then redeem them for ~10K USDT on BSC.

- Payout: Real-world hack
- Severity: high
- Program: ALP
- Analysis by: DeFiHackLabs
- Disclosed: 2024-03-06
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-03/ALP_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20240306-alp
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** BSC smart contract (ALP token / VUN aggregator)
**Root cause:** The _swap function intended as internal was externally callable, and its swap path credited ALP tokens to the VUN contract without proper accounting, letting an attacker inflate ALP balance held by VUN.
**Steps:**
1. Fork BSC at block 36727073
2. Read ALP balance held by VUN contract
3. Call `VUN._swap(ALP_APO, abi.encodeWithSignature("unoswapTo(address,address,uint256,uint256,uint256[])", attacker, ALP_APO, VUN_balance, 0, pools))` with crafted pool id encoding attacker address
4. Call `ALP_APO.maxRedeem(address(this))` and approve ALP to itself
5. Build RedeemData with amount=VUN_balance, receiver=attacker, tokenOut=USDT, minOut=0, empty aggregatorData
6. Call `ALP_APO.redeem(VUN_balance, r)` to receive USDT
**How found:** Likely spotted that _swap was declared without internal/private visibility, making it callable by anyone, and that the pool id parameter was attacker-controllable to redirect swap output.
**Exploitation:** Attacker invoked the publicly exposed _swap on the VUN contract, passing a crafted unoswapTo payload whose pool id encoded the attacker address, causing ALP tokens to be credited/moved to attacker control; then redeemed those ALP shares through redeem() for USDT (~10K profit).
**Insight:** Check visibility of functions named with leading underscore in deployed contracts; a 'internal' helper left public plus an attacker-controlled pool/recipient parameter can let you mint or redirect protocol-held tokens that are then redeemable.
