setPosMode function doesn’t check if wLp is whitelisted
The setPosMode function allows a position owner to change the position's mode without checking whether the wLp token used as collateral is still whitelisted. An attacker could move blacklisted collateral into a new mode, breaking the invariant that only whitelisted tokens can be used as collateral.
rvierdiiev Follow with sashik_eth
Originally disclosed on Code4rena
Submitted by rvierdiiev, also found by sashik_eth
Using setPosMode function owner of position can change it’s mode. When the function is called, then there are a lot of checks, like if current mode allows to decollateralize and if new mode allows to collateralize.
Also it’s checked, that all position collateral is used by the new mode. It’s done for the pools and for the wLp tokens.
In order to be able to use wLp tokens as collateral, then wLp should be whitelisted. It is checked in several places in the code, like here. It’s also possible that after some time wLp token will be blacklisted. In this case it should not be allowed to migrate blacklisted wLp token to the new mode, however there is no such check in the setPosMode function.
As result user can provide blacklisted collateral to the new mode. I understand that borrowing factor for such collateral will be likely about 0, however if you would try to collateralize such token, then it will be denied, thus setMode function breaks this invariant.
Impact
Non whitelisted collateral can be moved to the new mode.
Tools Used
VsCode
Recommended Mitigation Steps
Do not allow user to move blacklisted collateral to the new mode.
fez-init (INIT) confirmed and commented:
Will add whitelist check.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the setPosMode function omits a whitelist check for wLp tokens that is present elsewhere in the code.
Impact
A user could move blacklisted collateral to a new mode, breaking the invariant that only whitelisted tokens can be used as collateral; the borrowing factor for such collateral would likely be about zero.
What the attacker needed
A position with wLp collateral; wLp token becomes blacklisted
The fix
The team said they will add a whitelist check to prevent moving blacklisted collateral to the new mode.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract lets users change how their loan is set up. It checks many things but forgets to check that the token they use as security is still on an approved list. So someone could move a banned token into a new loan setup, even though the system normally blocks that token.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.