-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UniStaker.sol#permitAndStake()
and UniStaker.sol#permitAndStakeMore()
functions are allowed to be called by permit creator only (incorrect implementation of EIP-2612
)
#219
Comments
UniStaker.sol#permitAndStake()
and UniStaker.sol#permitAndStakeMore()
functions are allowed to be called by permit creator only (Incorrect implementation of EIP-2612)UniStaker.sol#permitAndStake()
and UniStaker.sol#permitAndStakeMore()
functions are allowed to be called by permit creator only (incorrect implementation of EIP-2612
)
MarioPoneder marked the issue as duplicate of #4 |
MarioPoneder marked the issue as unsatisfactory: |
Hi, @MarioPoneder. Thank you for the quick judging! Before I start with my escalation, I think the selected `primary issue" (#4) of this bug doesn't explain the whole bug well. First, it's essential to clarify the nature of
As noted in my report:
My response: While the validation of the permit is indeed handled within the This comment from @LyuboslavVeliev also outlines the whole idea of the issue very well. So, I think that the bug is valid because it restricts the potential of EIP-2612's permit functionality within the UniStaker. The current implementation limits these functions to be called only by the permit creator, contrary to the intended flexibility of EIP-2612, which aims to enhance user experience and interaction efficiency with smart contracts. I respectfully request a reassessment of the issue, considering its significant impact, as I feel its severity has been underestimated and believe it should be reclassified as a Medium Severity Issue. Have a good one! 🙂 |
Hi and thank you for your comment! First of all, the discussed methods are not part of the ERC-2612 spec and therefore do not need to comply. Furtmore, those methods are working as intended, see also this comment. The on-behalf methods, which exhibit the behavior your are looking for, are already implemented in the codebase. Therefore, leaving this as it is. |
Hi @MarioPoneder! Please see my report and my comment again because I think you are misunderstanding my point and the whole issue.
Incorrect, the all permit actions should comply with ERC-2612.
Incorrect, work as the developers intended, but it's a problem and needs to be fixed.
Incorrect, the on-behalf functions doesn't exhibit the behavior for that I am looking. The purpose of permit is to allow someone to sign off-chain approve signature, so that this signature can be used by another contract to call some function on behalf of signer. In this case, anyone should be able to sign permit for the staking and staking more actions. The correct implementation of permit functions aims to improve user experience within the staking process by integrating EIP-2612's permit standard/feature, which allows for gas-less approvals through signed messages. I'll also note here that you chose #205 as a valid medium severity issue because if depositors want to invalidate their signatures, they have to do 1 extra transaction. |
Could you review this report and my comments again. I will really appreciate it! |
Lines of code
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/main/src/UniStaker.sol#L292-L303
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/main/src/UniStaker.sol#L360-L373
Vulnerability details
Impact
UniStaker.sol#permitAndStake()
andUniStaker.sol#permitAndStakeMore()
functions are allowed to be called by permit creator only. No any other contracts will be able to execute these function on behalf of depositor (initial depositor in permit and stake situation). (incorrect implementation ofEIP-2612
)permitAndStake()
functionpermitAndStakeMore()
functionProof of Concept
The UniStaker.sol contract in the
UniStaker Infrastructure
is designed to manage the staking of governance tokens (including and delegation) and distribution of rewards (including and beneficiaries). Among its features, theUniStaker.sol
contract implementspermitAndStake()
andpermitAndStakeMore()
functions, which leverage theERC-2612
standard to allow token holders to give permission to the contract tostake tokens on their behalf using a signed message, instead of requiring a separate transaction for approval
. This mechanism aims to improve interactions byreducing the number of transactions and the associated gas costs
.permitAndStake()
: Allows a user to stake tokens by providing a signed message, granting permission to the contract to move tokens on their behalf.permitAndStakeMore()
: Enables a user to add more tokens to an existing stake using a similar permissioning approach.The implementation of these functions aims to improve user experience within the staking process by integrating
EIP-2612's permit standard/feature
, which allows forgas-less approvals through signed messages
.But, what is the problem?
The problem is that the current implementation restricts the
permitAndStake()
andpermitAndStakeMore()
functions to be called by thepermit creator only
, which differs from the intended flexibility ofEIP-2612 Standard
.The purpose of
permit
is to allow someone tosign approve signature, so that this signature can be used by another contract to call some function on behalf of signer
. In this case, anyone should be able to sign permit for the staking and staking more actions.Also
permitAndStakeMore()
functions inUniStaker.sol
contract check if the_depositor
is same who signed permit.As a result, users cannot delegate staking actions (staking and staking more) to a third party or smart contract, which can make possible batch transactions or integrations with other DeFi protocols.
permitAndStake()
function function:permitAndStakeMore()
function function:Tools Used
Manual Review
Recommended Mitigation Steps
To align with the intended use of EIP-2612, I recommend the following mitigation: Adjust the
permitAndStake()
andpermitAndStakeMore()
functions to remove the requirement that themsg.sender
must be the permit creator. Instead, validate the permit against the intended staker's address provided in the signed message (signer of the permit, not themsg.sender
).Assessed type
Context
The text was updated successfully, but these errors were encountered: