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

In depositFsGlp() function AMOUNT should be checked with caller or msg.sender wallet balance using REQUIRE statement . #134

Closed
code423n4 opened this issue Nov 25, 2022 · 2 comments
Labels
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 edited-by-warden unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Nov 25, 2022

Lines of code

https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L422-L465

Vulnerability details

Impact

Its possible attacker can call depositFsGlp() function recursively without having any fsGLP Token . Attacker can block the depositFsGlp() function inactive or Denial-of-Service (DoS) . Attacker can create flooding the target with traffic. Attacker can create artificial traffic for depositFsGlp() function.

Proof of Concept

2022-11-redactedcartel/src/PirexGmx.sol

   function depositFsGlp(uint256 amount, address receiver)
    external
    whenNotPaused
    nonReentrant
    returns (
        uint256,
        uint256,
        uint256
    )
   {
    if (amount == 0) revert ZeroAmount();
    if (receiver == address(0)) revert ZeroAddress();

    // Transfer the caller's fsGLP (unstaked for the user, staked for this contract)
    stakedGlp.transferFrom(msg.sender, address(this), amount);

    // Get the pxGLP amounts for the receiver and the protocol (fees)
    (uint256 postFeeAmount, uint256 feeAmount) = _computeAssetAmounts(
        Fees.Deposit,
        amount
    );
   // Mint pxGLP for the receiver (excludes fees)
    pxGlp.mint(receiver, postFeeAmount);

    // Mint pxGLP for fee distribution contract
    if (feeAmount != 0) {
        pxGlp.mint(address(pirexFees), feeAmount);
    }

    emit DepositGlp(
        msg.sender,
        receiver,
        address(stakedGlp),
        0,
        0,
        0,
        amount,
        postFeeAmount,
        feeAmount
    );

    return (amount, postFeeAmount, feeAmount);
    }

Solution:

           require(stakedGlp.balanceOf(msg.sender)>amount, " Not enough fsGLP In your wallet");

The above line should be added before the stakedGlp.safeTransferFrom call . Need to make sure msg.sender balance is greater than amount .

Manual finding with vscode

Recommended Mitigation Steps

Can use require statements to make sure the MSG.SENDER balance

@code423n4 code423n4 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 Nov 25, 2022
code423n4 added a commit that referenced this issue Nov 25, 2022
@Picodes
Copy link

Picodes commented Dec 4, 2022

Why would it lead to a DoS ?

@c4-judge
Copy link
Contributor

c4-judge commented Dec 4, 2022

Picodes marked the issue as unsatisfactory:
Insufficient proof

@c4-judge c4-judge closed this as completed Dec 4, 2022
@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 edited-by-warden unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants