The permitToken
function within the TokenFacet
, has the potential race condition issues associated with the permit system. Even though TokenFacet
is out of scope of this audit but the permit function allows users to create approvals prior to execution, which inherently introduces the risk of race conditions. And these approvals of tokens can be used in Beanstalk instances which are in scope. The implementation of the permit function does not include explicit safeguards against race conditions, leaving room for potential vulnerabilities.
Race Conditions: The permit function's design exposes it to race conditions, where multiple transactions may attempt to modify allowances concurrently, leading to inconsistencies or unexpected behavior. This could potentially allow attackers to exploit the system by manipulating allowances or gaining unauthorized access.
The LibTokenPermit
permit function is called by the TokenFacet
permitToken
function.
After the permit
function call, the permitToken
function invokes the approve
function from LibTokenApprove
.
The approve
function updates the approval for the specified spender and token to the provided amount. It updates the state variable s.a[account].tokenAllowances[spender][token]
with the new allowance amount.
The approve
function updates the allowance for the specified spender and token to the provided amount. Therefore, it will overwrite any previous approval for that spender and token with the new amount.
There is a potential for a race condition if multiple transactions are attempting to update the allowance for the same spender and token simultaneously. If two transactions read the allowance, modify it, and then attempt to write it back without awareness of each other, it could result in inconsistencies or unexpected behavior.
Permit systems in general have race conditions given the signature is created prior to execution. So generally it’s up to the implementor to properly implement the permit function such that a race condition doesn’t occur, this is why provide clear documentation and guidance to users regarding the risks associated with creating approvals and using the permit function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.