Early user can break minting
The first user can manipulate the exchange rate factor to zero by burning all but one wei of their minted tokens, causing subsequent deposits to mint zero tokens. This allows the attacker to steal deposits and accrue future value.
Submitted by cmichel
The protocol computes a factor when minting (and burning) tokens, which is the exchange rate of rebase to base tokens (base supply / total assets value), see GToken.factor(). The first user can manipulate this factor such that it always returns 0.
Example:
- Attacker deposits 100.0 DAI and mints 100 * 1e18 PWRD:
DepositHandler.depositGTokenwithdollarAmount = 100.0 = 100 * 1e18, thenctrl.mintGToken(pwrd, msg.sender, 1e18)callsgt.mint(account, gt.factor(), amount=1e18)wheregt.factor()returnsgetInitialBase() = 1e18because the person is the first minter and it mintsamount * factor / _BASE = 1e18 - The
ctrl.mintGTokencall also increases total assets:pnl.increaseGTokenLastAmount(...) - The attacker now burns (withdraws) all minted tokens again except a single wei using one of the withdrawal functions in
WithdrawHandler. Because of the withdrawal fee the total assets are only decreased by the post-fee amount (IPnL(pnl).decreaseGTokenLastAmount(pwrd, amount=userBalance - 1, bonus=fee);), i.e., with a 2% withdrawal fee the total assets stay at 2% of 100$ = 2 * 1e18. - The result is that
GToken.factor()always returnstotalSupplyBase().mul(BASE).div(totalAssets) = 1 * 1e18 / (2 * 1e18) = 0
The resulting factor is 0 and thus any user-deposits by depositGToken will mint 0 base tokens to the depositor. This means all deposits and future value accrues to the attacker who holds the only base tokens.
An attacker could even front-run the first minter to steal their deposit this way.
Uniswap solves a similar problem by sending the first 1000 tokens to the zero address which makes the attack 1000x more expensive. The same should work here, i.e., on first mint (total base supply == 0), lock some of the first minter’s tokens by minting ~1% of the initial amount to the zero address instead of to the first minter.
kristian-gro (Gro) acknowledged but disagreed with severity:
Known issue which will be handled by ops - low risk as gro protocol is the first depositor
Even though it’s a known issue its consequences are significant. Only because it can be mitigated by ops quite easily, I’ll degrade it to medium level.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the exchange rate factor is calculated as base supply divided by total assets, and the first minter can make total assets large relative to supply by burning most tokens but leaving one wei, causing the factor to round down to zero.
Impact
Any user deposits will mint zero base tokens, so all deposits and future value accrue to the attacker; an attacker could even front-run the first minter to steal their deposit.
What the attacker needed
Attacker is first depositor or front-runs first minter; withdrawal fee exists
The fix
On first mint, lock some of the first minter's tokens by minting about 1% of the initial amount to the zero address, similar to Uniswap's approach.
How it was found
- Attacker deposits 100 DAI and mints 100e18 PWRD tokens.
- The minting increases total assets.
- Attacker burns all minted tokens except one wei using a withdrawal function.
- Due to withdrawal fee, total assets decrease only by the post-fee amount, leaving total assets at 2e18.
- The factor becomes 1e18 / 2e18 = 0, so future deposits mint zero tokens.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you deposit money, the system gives you tokens based on a rate. The first person to deposit can make that rate zero by leaving just a tiny amount of tokens, so later depositors get nothing and the attacker keeps all the value.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.