PrePO NFT holders will not be able to redeem collateral
The redeem function in PrePOMarket checks an account list that only includes certain users, so NFT holders who deposited funds cannot redeem their collateral and withdraw profits. This could lead to a loss of funds for those users.
Originally disclosed on Code4rena
Submitted by 0xdeadbeef0x
The protocol has set a limitation on who can participate in the protocol activities.
- Users who are included in an allowed list:
_accountList. - Users who own specific NFTs that are supported by NFTScoreRequirement. These NFTs are PrePO NFTs that were minted to accounts that historically participated in PrePO activities.
Users who are #2 that deposited funds into the protocol are not able to redeem collateral tokens and withdraw their profits/funds from the market. (Loss of funds).
Proof of Concept
When a user has deposited, the protocol checks if the user is permitted to participate in the protocol activities by checking #1 and #2 from the Impact section. The check is done in the hook function in DepositHook: https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/DepositHook.sol#L45
function hook(address _sender, uint256 _amountBeforeFee, uint256 _amountAfterFee) external override onlyCollateral {
-----
if (!_accountList.isIncluded(_sender)) require(_satisfiesScoreRequirement(_sender), "depositor not allowed");
-----
}
After a user has deposited and received collateral tokens, he will trade it in uniswap pools to receive Long/Short tokens either manually or through the depositAndTrade function.
When the user decided to redeem through the market in order to receive the collateral tokens and his funds/profits, the user will not be able to receive it because only users that are in the account list (#1) will pass the checks. Users who participated because they own NFT (#2) will get a revert when calling the function.
redeem in PrePOMarket: https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/PrePOMarket.sol#L96
function redeem(uint256 _longAmount, uint256 _shortAmount) external override nonReentrant {
-----
_redeemHook.hook(msg.sender, _collateralAmount, _collateralAmount - _expectedFee);
-----
}
hook function in RedeemHook: https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/RedeemHook.sol#L18
function hook(address sender, uint256 amountBeforeFee, uint256 amountAfterFee) external virtual override onlyAllowedMsgSenders {
require(_accountList.isIncluded(sender), "redeemer not allowed");
----
}
As you can see above, only users that are in the account list will be able to redeem. NFT holders will receive a revert of “redeemer not allowed”.
Hardhat POC
There is an already implemented test where hook will revert if the user is not in the allowed list: https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/test/RedeemHook.test.ts#L128
it('reverts if caller not allowed', async () => {
msgSendersAllowlist.isIncluded.returns(false)
expect(await msgSendersAllowlist.isIncluded(user.address)).to.be.false
await expect(redeemHook.connect(user).hook(user.address, 1, 1)).to.be.revertedWith(
'msg.sender not allowed'
)
})
Tools Used
VS Code, Hardhat
Recommended Mitigation Steps
Add an additional check in DepositHook to NFT holders through NFTScoreRequirement.
ramenforbreakfast (prePO) disputed and commented:
We should have been more clear with this, but when users
redeemtheir positions, we intend to simply deactivate theAccountList, since we only want to gate initial deposits in the system, the amount of underlying within the system. If someone has a position they’d like to redeem once AMM pools are closed, they will be able to viaredeemsince we would not have an ACL configured at that point in time.
@ramenforbreakfast I get your point, but the finding is valid for the codebase and documentation that was audited, right? Anyone obtaining the tokens through a transfer or by minting with a NFT would not be able to redeem with the audited hook.
ramenforbreakfast (prePO) commented:
I think another problem with this finding, is it assumes that the
AccountListused forDepositHook(for mintingCollateral) andRedeemHookforPrePOMarketwill be the same. In the diagram provided, eachAccountListis denoted with a number to clarify that these are differentAccountListinstances.The
RedeemHookAccountListis a separate list, that will essentially only allowgovernanceto redeem positions via the market contract directly, until the UniswapV3 pool is closed and final redemptions are allowed by all users.While I agree that this finding would have been valid given we did not document this well, I think the assumption that these lists would be the same and affect one another was documented and this issue is incorrectly assuming otherwise.
I don’t think this issue assumes that the two
AccountListare exactly the same, it just highlights that some users may be allowed to mint but not to redeem, which would lead to a loss of funds.They could still trade their tokens with someone whitelisted but the risk that they have to take a loss or are left unable to redeem is high.
However, you’re right to highlight that technically the governance could add every NFT holder in the redeem
AccountList, so could mitigate this.Also, to clarify @ramenforbreakfast, do you intend to deactivate the
AccountListby removing theredeemHook? Or is there a way inredeemHookto deactivate theAccountList?
ramenforbreakfast (prePO) commented:
For the
redeemHook, once trading on the UniswapV3Pool is closed, we would most likely replace theredeemHookwith one that does not have anAccountList, therefore allowing with existing positions to redeem them via thePrePOMarketcontract.I understand that this person is highlighting that some people would be allowed to mint, but not redeem, but users do not mint positions anyway. They buy them from UniswapV3 Pools with
Collateralthat they mint. Liquidity on the pools is provided by the team, who are the only ones allowed to mint positions for aPrePOMarket.
Picodes (judge) decreased severity to Medium and commented:
My decision will be to accept this finding but downgrade it to Medium, considering that:
- the audited scope didn’t contain a version of
redeemHookwithoutAccountList- if users don’t mint but buy using Uniswap, they still cannot redeem if there is some form of whitelisting required
- as highlighted by the sponsor the
AccountListisn’t supposed to be the same as themintone- funds aren’t lost but stuck until the governance updates the
AccountList
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
The redeem hook uses an account list that does not include NFT holders, while the deposit hook allows NFT holders, creating an inconsistency.
Impact
NFT holders who deposited funds cannot redeem their collateral, potentially leading to a loss of funds, though the funds may be stuck until governance updates the account list.
What the attacker needed
User owns a PrePO NFT; user deposits funds; user attempts to redeem
The fix
The redeem hook should be updated to allow NFT holders to redeem, for example by adding a check for NFT ownership or by removing the account list restriction when redemptions are allowed.
How it was found
- A user who owns a PrePO NFT deposits funds into the protocol.
- The user receives collateral tokens and trades them for Long/Short tokens.
- The user tries to redeem the Long/Short tokens through the market.
- The redeem function calls the RedeemHook, which checks if the user is in the account list.
- The user is not in the account list, so the transaction reverts with 'redeemer not allowed'.
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.
In this smart contract, some users are allowed to deposit money because they own a special NFT. But when they try to take their money back out, the contract checks a different list that doesn't include them, so they are blocked. This means their money gets stuck.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.