hats-finance / Kintsu-0x7d70f9442af3a9a0a734fa6a1b4857f25518e9d2

Smart contracts for Kintsu
Other
0 stars 0 forks source link

`nomination_agent` might be deactivated after calling `nomination_agent.compound` #58

Open hats-bug-reporter[bot] opened 1 month ago

hats-bug-reporter[bot] commented 1 month ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0x66652de8b8dec5d65c22a0679b1a2fe44ab9057f01c9dc3f35195db821221812 Severity: high

Description: Description\ According to nomination_agent.compound, the function will split the GasToken(AZERO) into incentive and compound based on current balance, then bond the compound and transfer the incentive to vault

After the function, there will be ZERO GasToken(AZERO) left in nomination_agent

But according to Existential Deposit's defination

On most Substrate-based chains, an account is only active when it holds a minimum amount, currently set at 1 DOT on Polkadot and 0.000333333 KSM on Kusama. This minimum amount is called the Existential Deposit (ED).

If an account drops below the ED, the account is reaped ("deactivated"), and any remaining funds are destroyed. The address can be reactivated with a new deposit larger than the existential deposit at any time. This will not restore the destroyed funds.

If you send funds lower than the ED to an empty account, the transaction will fail (nominators need to pay attention to this when collecting staking rewards, see below).

Attack Scenario\ Because nomination_agent.compound is called by valut.compound, and valut.compound can be called by anyone, nomination_agent's balance might be empty at any time.

And this issue might be happen to nomination_agent.deposit too.

bgibers commented 1 month ago

Self::env().balance() excludes the Existential Deposit when called within compound method, therefore the nomination agent does indeed have enough