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

FixedPricePassThruGate: Excess ether lock in the contract #49

Closed
code423n4 opened this issue May 6, 2022 · 4 comments
Closed

FixedPricePassThruGate: Excess ether lock in the contract #49

code423n4 opened this issue May 6, 2022 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-05-factorydao/blob/e22a562c01c533b8765229387894cc0cb9bed116/contracts/FixedPricePassThruGate.sol#L46-L56

Vulnerability details

Impact

The passThruGate function of the FixedPricePassThruGate contract is used to charge NFT purchase fees.
When msg.value> gate.ethcost, the excess ether did not return to the user, but was locked in the contract.

Proof of Concept

https://github.com/code-423n4/2022-05-factorydao/blob/e22a562c01c533b8765229387894cc0cb9bed116/contracts/FixedPricePassThruGate.sol#L46-L56

Tools Used

None

Recommended Mitigation Steps

-   function passThruGate(uint index, address) override external payable {
+  function passThruGate(uint index, address payer) override external payable {
        Gate memory gate = gates[index];
        require(msg.value >= gate.ethCost, 'Please send more ETH');

        // pass thru ether
        if (msg.value > 0) {
            // use .call so we can send to contracts, for example gnosis safe, re-entrance is not a threat here
            (bool sent, bytes memory data) = gate.beneficiary.call{value: gate.ethCost}("");
            require(sent, 'ETH transfer failed');
        }
+      if (msg.value - gate.ethCost > 0){
+         (bool sent, bytes memory data) = payer.call{value: msg.value - gate.ethCost}("");
+          require(sent, 'ETH transfer failed');}
    }
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels May 6, 2022
code423n4 added a commit that referenced this issue May 6, 2022
@illuzen
Copy link
Collaborator

illuzen commented May 10, 2022

Valid

@illuzen
Copy link
Collaborator

illuzen commented Jun 3, 2022

@gititGoro gititGoro added the duplicate This issue or pull request already exists label Jun 14, 2022
@gititGoro
Copy link
Collaborator

gititGoro commented Jun 14, 2022

Duplicate of #48

@gititGoro gititGoro marked this as a duplicate of #48 Jun 14, 2022
@gititGoro
Copy link
Collaborator

The duplicate link is changed as the issue is the same but for a different sub contract. Wardens who group similar contracts would be penalized if these were recognized as distinct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

5 participants