Arbitrary User won't be able to stake on Behalf of Staker despite correct User Signature Intent #109
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_24_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/main/src/UniStaker.sol#L660
Vulnerability details
Proof of Concept
The
UniStaker
contract facilitates staking in multiple ways:stake
: Directly used by the staker to stake UNI tokens into the UniStaker Contract.permitAndStake
: Enables the staker to sign an ECDSA signature permitting the contract to transfer and stake tokens.stakeOnBehalf
: Intended for staking UNI tokens on behalf of another user, utilizing a provided user intent signature.However, look at Natspec of
stakeOnBehalf
function which reveals an important point:Here, it's clearly written that
caller must pre-approve the staking contract to spend at least the would-be staked amount of the token.
.Consider the following scenario:
X
UNI
tokens on behalf of Bob.stakeOnBehalf
, ensuring pre-approval ofX
tokens to the contract._stake
function, funds transfer occurs from Bob to the designated_surrogate
address, rather than from Alice to_surrogate
, resulting in failure to stake funds on behalf of Bob because of following line.Link to Code
This way, Alice fails to stake funds on behalf of Bob.
Impact
Inability to allow others to stake funds on behalf of user, despite possessing the correct signature (user intent).
Tools Used
VS Code
Recommended Mitigation Steps
Update the
_stake
function as follows to permit any entity to stake on behalf of a user, provided they possess the user's intent:Assessed type
Context
The text was updated successfully, but these errors were encountered: