HunnyFinance - earn Inflation & loyaltyRatio Manipulation
Affected Contract: HyperStaking
(Proxy at 0x31dd9Be51cC7A96359cAaE6Cb4f5583C89D81985 on BSC)
Summary
The HyperStaking contract contains at least two critical vulnerabilities.
- Principal Manipulation An attacker can manipulate the internal accounting of their principal investment to generate artificial "earned" tokens, allowing them to claim illegitimate bonuses.
- Epoch Manipulation An attacker can bypass the time-based loyalty mechanism by repeatedly calling the
rebase()function, granting them 100% loyalty instantly to maximize bonus theft.
Both vulnerabilities can be exploited independently to drain funds from the protocol.
Exploit 1 - Earn Manipulation
Description
The first flaw is located in the unstake() function, when called with a _bonus of 0, it enters a code block that recalculates the user principal, the logic incorrectly uses the user current KISS balance to determine the new principal.
|
|
An attacker can artificially reduce their visible KISS balance (by transferring tokens to another controlled address) before calling unstake(), the contract interprets this as a withdrawal and drastically reduces the attacker recorded principal, even though they still hold the tokens.
Execution flow - BlockSec Explorer
Vector
- Deposit Attacker stakes
NLOVE, receivesNKISS.principalisN. - Hide Attacker transfers most of their KISS tokens away.
- Manipulation Attacker calls
unstake()with a small amount and_bonus=0, the contract sees a low balance and reduces theirprincipalto a near-zero value. - Recover Attacker transfers the KISS tokens back.
- Inflated Earn The contract now calculates
earned = balance - principal, sinceprincipalis near-zero, almost the entire balance is considered "earned". - Claim The attacker waits for their
loyaltyRatioto increase, then claims a large bonus based on these artificial earnings.
Exploit 2 - loyaltyRatio Manipulation
Description
Vulnerability lies in how the contract manages time and loyalty, the rebase() function is public and can be called by anyone to advance the contract epoch, however, it only processes one epoch per call.
|
|
This allows an attacker to repeatedly call the function if a long time has passed, artificially inflating the epoch.number, the user loyalty is calculated based on the number of epochs passed since they staked:
|
|
By controlling epoch.number, the attacker controls epochPassed and can grant themselves maximum loyalty instantly.
With instant loyaltyRatio, the attacker therefore receives a 100% bonus based on their inflated earn from the previous manipulation.
BlockSec Explorer - Exploit TX
Vector
- Deposit The attacker stakes any amount of LOVE, their
bonusInfo.epochis recorded. - Rebase The attacker calls the
rebase()function 144 times in rapid succession, this advancesepoch.numberby 144. - Manipulation The
getLoyaltyRatio()function now calculatesepochPassedto be >= 144 and returns 100. - Claim The attacker can immediately call
unstake()and claim the maximum possible bonus, a privilege that should have taken 48 days to acquire.
Impact
- Drain Direct and critical threat to the $50,163 (10,114,087 LOVE) of TVL, an attacker can systematically drain funds from the contract.
- This attack completely nullifies the time-based staking incentive
loyalty, which is a core part of the protocol tokenomics, It allows an attacker to extract the maximum bonus immediately after staking. - When combined with the principal manipulation vulnerability, an attacker can first create a large amount of fake
earnedtokens, and then use this second exploit to claim a bonus on them immediately at a 100% ratio.
Profit & HUG Dependency
Nuance of this exploit lies in the final profit realization step, while the vulnerabilities allow an attacker to generate a massive illegitimate bonus claim, materializing this bonus as actual LOVE tokens is gated by another mechanism, the HUG token.
- HUG as a Claim Voucher The
unstake()function explicitly limits the claimable bonus amount (bonusAmount) to the attacker balance ofHUGtokens. - 1:1 Burn Ratio The
StakingVaultcontract, when paying out the bonus, burns an amount of HUG tokens exactly equal to the amount ofLOVEbonus paid out.
This creates a crucial economic condition for the attack profitability:
Price(LOVE) > Price(HUG)
Attacker must acquire HUG tokens on the open market, the exploit is only profitable if the cost of acquiring these HUG tokens is less than the value of the LOVE tokens they manage to drain.
This dependency on an external, low-liquidity token has two major consequences:
- Economic Bottleneck The profitability of the attack is not guaranteed and depends on market conditions and the price impact (slippage) of buying the scarce HUG supply.
- Harm to Legitimate Users It forces a competition for HUG between attackers and legitimate users, since an attacker can generate a much larger potential reward, they have a greater incentive to buy out the entire
HUG supply, effectively blocking legitimate users from ever claiming their own, patiently-earned bonuses.