Open code423n4 opened 2 years ago
The finding has merit and given the information the warden had I believe the Judge will have to have the final say.
From my more POV, the attack would require:
So this is actually doable but requires those pre-conditions
Additionally, notice how claimBribesFromHiddenHand
doesn't check for protectedTokens, even want
, that's because any of those tokens could be a bribe and as such we want to be able to process them properly.
In terms of impact, what would happen is that instead of immediately selling the auraBAL, the tokens would be in the bribesProcessor (implementation was linked although out of scope) and we would ragequit
the tokens back to the BadgerTree or alternatively the manager
could process them and re-emit them (autocompound with extra steps)
I want to comment the warden for the inquisitive nature, but I believe that impact as well as setup makes this a harvest with extra steps.
Open to any type of judging as some of the information I shared in the reply was most likely not available to the warden at the time of submission
Given the rather strict preconditions and minor impact, I'll downgrade this issue to QA
, but this still makes a great catch.
Lines of code
https://github.com/Badger-Finance/vested-aura/blob/d504684e4f9b56660a9e6c6dfb839dcebac3c174/contracts/MyStrategy.sol#L288-L343
Vulnerability details
Impact
Function
claimBribesFromHiddenHand
makes some external calls to token lists (which fetches fromhiddenHandDistributor.rewards
) ifauraBAL
was on of those tokens and also one of those tokens were malicious or made some external call then it's possible to callAuraLOCKER.getReward(MyStrategy)
and changeauraBAL
balance and that would cause thedifference
calculation ofauraBAL
to go wrong andauraBAL
tokens recieved fromLOCKER
would be transfer tobribeProcessor
even so they are not supposed to.Proof of Concept
This is
hiddenHandDistributor.rewards()
code:As you can see code saves the balance of contract in token lists and then make external calls to transfer rewards. if
auraBAL
was in the token list and one other token was malicious or made some external call to strategist controllable address then that person can callAuraLOCKER.getReward(MyStrategy)
which would change theauraBAL
balance of contract and when contract tries to find earnedauraBAL
tokens the value ofdifference
would be received values fromhiddenHand
andAuraLcoker
and it would be transferred tobribeProcessor
even soauraBAL
fromAuraLOCKER
should only supposed to be used in_harvest()
to swap and reinvest. these are the steps: 1 strategist would callclaimBribesFromHiddenHand()
withauraBAL
and some malicious token in the list of tokens.hiddenHandDistributor.claim()
to claim rewards and it would receive someauraBAL
balances.AuraLOCKER.getReward(MyStrategy)
andAuraLocker
would transferauraBAL
tokens toMyStrategy
address.difference
balance forauraBAL
token and it would be tokens received fromAuraLOCKER
andhiddenHand
.difference
amount ofauraBAL
tobribeProcessor
andAuraLOCKER
tokens would transfer tobribeProcessor
.So even so
auraBAL
is in protected tokens andauraBAL
tokens fromAuraLOCKER
is supposed to be used in_harvest()
and create compounding APR, but the tokens will transfer tobribeProcessor
Tools Used
VIM
Recommended Mitigation Steps
check for all the balance change of
protected tokens
inclaimBribesFromHiddenHand()