Anyone can call absorb to absorb excess underlying asset.
Summary
The function absorb can be called by both EOA and contracts instead of only contracts to absorb the surplusunderlying asset in the Ptokencontract, due to lack of checks.
Vulnerability Detail
In the codecomment, the function absorb should only be called by contracts, but there are no checks in the code to ensure that only contracts can call this function. so; anyone can drain the surplusunderlyingasset
*/@notice Absorb the surplus underlying asset to user.
// @dev This function should only be called by contracts.
// @param user The beneficiary to absorb the surplus underlying asset
*/
function absorb(address user) public {
uint256 balance = IERC20(underlying).balanceOf(address(this));
uint256 amount = balance - totalSupply();
_mint(user, amount);
}
oxchryston
medium
Anyone can call
absorb
to absorb excessunderlying
asset.Summary
The function
absorb
can be called by bothEOA
andcontracts
instead of onlycontracts
to absorb thesurplus
underlying asset
in thePtoken
contract
, due to lack of checks.Vulnerability Detail
In the
code
comment
, the function absorb should only be called by contracts, but there are nochecks
in the code to ensure that onlycontracts
can call thisfunction
. so; anyone can drain thesurplus
underlying
asset
Impact
https://github.com/sherlock-audit/2023-05-ironbank/blob/9ebf1702b2163b55479624794ab7999392367d2a/ib-v2/src/protocol/token/PToken.sol#L53
Code Snippet
Tool used
Manual Review
Recommendation
Add
require
andchecks
to make thefunction
onlycallable
bycontracts
.