The implementation of LibEth#refundEth()
does not account for the new Tractor
logic, leading to issues in refunding ETH to the correct user, since refundEth()
always uses msg.sender
directly instead of querying the user via LibTractor_user()
. As a result, ETH refunds might be sent to the wrong address when executed through the Tractor.
Take a look at https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/8c8710df547f7d7c5dd82c5381eb6b34532e4484/protocol/contracts/beanstalk/migration/L1Libraries/LibEth.sol#L15-L23
This library ends up being queried in multiple instances and it's use is to refund Eth in the case where there is a need to do so, see instances where it's being used:
Evidently, this functionality is rampant accross different facets, but the latest update with Beanstalk, includes the Tractor
logic.
Now, from the walkthrough videos and the documentation, we can see that the intended functionality is to have the Tractor
be able to be substituted by users for any of their logic, the previous sentence is probably not worded correctly, but the idea is that users can now pass most of their operations via the tractor.
Which is why if you go to the PR with the changes from the previous version to the current one here: https://github.com/BeanstalkFarms/Beanstalk/pull/909/files?file-filters%5B%5D=.md&file-filters%5B%5D=.sol&show-deleted-files=true&show-viewed-files=true, we'd notice most instances of msg.sender
being implemented previously have now been changed to query the user via LibTractor_user()
i.e https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/8c8710df547f7d7c5dd82c5381eb6b34532e4484/protocol/contracts/libraries/LibTractor.sol#L116-L122
However this has not been considered in LibEth
as shown above in it's refundETH()
implementation, which then causes that in instances where LibEth#refundETH()
in all the facets where it's being used if the execution is via the Tractor, then the attempt to refund the ETH would be done on the wrong address.
NB: This bug case is somewhat applicable in different context to other instances where after the
Tractor
update,msg.sender
is still being implemented instead of theLibTractor_user()
.
When using the new tractor feature and there is a need to refund Eth, end users lose out on their tokens cause the refund is not done to the correct end user address.
Manual review
Consider refactoring LibEth#refundETH()
to take into account the fact that it could be called in the context where the execution is from the Tractor
specification.
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.