Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withApproval is not checking if msg.sender is a ward, blocking wards to do actions in LiquidityPool.sol #41

Closed
c4-submissions opened this issue Sep 10, 2023 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue edited-by-warden grade-c low quality report This report is of especially low quality primary issue Highest quality submission among a set of duplicates QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

c4-submissions commented Sep 10, 2023

Lines of code

https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/LiquidityPool.sol#L97-L100

Vulnerability details

Impact

Contract wards are blocked from doing certain actions in LiquidityPool.sol. For example, withdraw, redeem, requestDeposit, ... This is because the withApproval modifier is not checking whether the message sender is a ward or not even though the @dev comments show that it should.

/// @dev Either msg.sender is the owner or a ward on the contract

Proof of Concept

Run the following test and verify the success

function testWardCantRequestDeposit(
    uint64 poolId,
    uint8 decimals,
    string memory tokenName,
    string memory tokenSymbol,
    bytes16 trancheId,
    uint128 price,
    uint128 currencyId,
    uint256 amount,
    uint64 validUntil
) public {
    vm.assume(currencyId > 0);
    vm.assume(amount < MAX_UINT128);
    vm.assume(amount > 1);
    vm.assume(validUntil >= block.timestamp);
    price = 2 * 10 ** 27;

    address lPool_ = deployLiquidityPool(poolId, erc20.decimals(), tokenName, tokenSymbol, trancheId, currencyId);
    LiquidityPool lPool = LiquidityPool(lPool_);

    address ward = address(0x69);
    vm.prank(address(root));
    lPool.rely(ward);

    assertEq(lPool.wards(ward), 1);

    homePools.updateTrancheTokenPrice(poolId, trancheId, currencyId, price);
    erc20.mint(self, amount);
    erc20.approve(address(investmentManager), amount);
    homePools.updateMember(poolId, trancheId, self, validUntil);

    vm.prank(ward);
    vm.expectRevert(bytes("LiquidityPool/no-approval"));
    lPool.requestDeposit(amount, self);
}

Tools Used

Manual review + vscode

Recommended Mitigation Steps

Replace require(msg.sender == owner, "LiquidityPool/no-approval"); with require(msg.sender == owner || wards[msg.sender] == 1, "LiquidityPool/no-approval");

Assessed type

Access Control

@c4-submissions c4-submissions added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Sep 10, 2023
c4-submissions added a commit that referenced this issue Sep 10, 2023
@raymondfam
Copy link

Wrong comments as confirmed by the sponsor in Discord. The code is correct.

@c4-pre-sort
Copy link

raymondfam marked the issue as low quality report

@c4-pre-sort c4-pre-sort added the low quality report This report is of especially low quality label Sep 14, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as primary issue

@c4-judge
Copy link

gzeon-c4 changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 25, 2023
@c4-judge
Copy link

gzeon-c4 marked the issue as grade-c

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue edited-by-warden grade-c low quality report This report is of especially low quality primary issue Highest quality submission among a set of duplicates QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants