Polyfox.finance Rug Pull
What happened
Polyfox.finance was a yield-farming project on Polygon: a MasterChef staking contract that paid out the FOX token ("PolyFox Token"). De.Fi's REKT database lists FOX as an exit scam / rug pull dated 2021-08-26 and gives no loss figure. The verified farm contract has no function that lets the owner pull staked tokens out directly.
Its weak point is the deposit fee: the owner can set any pool's depositFeeBP as high as 10000 (100%) with no delay, so new deposits can be sent in full to feeAddress while the depositor is credited with nothing.
How it happened
- The
MasterChefconstructor makes the deployer the owner and sets both recipients:devAddress = msg.sender;andfeeAddress = msg.sender;. Only the currentfeeAddresscan reassign the fee recipient (setFeeAddressrequiresmsg.sender == feeAddress). - The owner can create or edit pools with
add(...)orset(...). The only limit on the fee isrequire(_depositFeeBP <= 10000, "set: invalid deposit fee basis points");, so a 100% fee is allowed, andsetapplies to a live pool immediately. - In
deposit, the LP tokens are first pulled from the user (pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);), then the fee is computed and sent out:uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000); pool.lpToken.safeTransfer(feeAddress, depositFee);. - The depositor is credited
user.amount = user.amount.add(_amount).sub(depositFee);. WithdepositFeeBP == 10000the fee equals the deposit, so that deposit is credited as zero andwithdraw(require(user.amount >= _amount, "withdraw: not good");) cannot return it. Stakers who deposited earlier keep their recordeduser.amountand can still usewithdraworemergencyWithdraw. - Rewards are also owner-steerable.
setcan drop a pool'sallocPointto 0, andupdatePoolmints an extra tenth of every reward to the dev address:fox.mint(devAddress, foxReward.div(10));.FoxToken.mintisonlyOwner, so this works only while the farm is the token's owner, which the supplied source does not show. - What happened: De.Fi's REKT database lists FOX as an exit scam / rug pull dated 2021-08-26 with no funds-lost value. No transaction was opened showing a 100% fee being set or fees being collected, so the steps above describe what the code allowed, not a confirmed sequence.
Protocol details
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.