code-423n4 / 2023-10-opendollar-findings

10 stars 7 forks source link

Users can be tricked to buy safes with status different than advertized #358

Open c4-submissions opened 10 months ago

c4-submissions commented 10 months ago

Lines of code

https://github.com/open-dollar/od-contracts/blob/f4f0246bb26277249c1d5afe6201d4d9096e52e6/src/contracts/proxies/ODSafeManager.sol#L136-L152

Vulnerability details

Impact

Proof of Concept

ODSafeManager.transferSAFEOwnership function

  function transferSAFEOwnership(uint256 _safe, address _dst) external {
    require(msg.sender == address(vault721), 'SafeMngr: Only Vault721');

    if (_dst == address(0)) revert ZeroAddress();
    SAFEData memory _sData = _safeData[_safe];
    if (_dst == _sData.owner) revert AlreadySafeOwner();

    _usrSafes[_sData.owner].remove(_safe);
    _usrSafesPerCollat[_sData.owner][_sData.collateralType].remove(_safe);

    _usrSafes[_dst].add(_safe);
    _usrSafesPerCollat[_dst][_sData.collateralType].add(_safe);

    _safeData[_safe].owner = _dst;

    emit TransferSAFEOwnership(msg.sender, _safe, _dst);
  }

Tools Used

Manual Testing.

Recommended Mitigation Steps

Add a cool down period when the user generates a debt or quits the system (or any operation that decreases the SAFE health or frees its collateral), and this period to be checked if passed when the NFV is transferred to another user (bought by another user).

Assessed type

Context

c4-pre-sort commented 10 months ago

raymondfam marked the issue as sufficient quality report

c4-pre-sort commented 10 months ago

raymondfam marked the issue as duplicate of #20

c4-pre-sort commented 10 months ago

raymondfam marked the issue as duplicate of #63

c4-judge commented 10 months ago

MiloTruck changed the severity to 3 (High Risk)

c4-judge commented 10 months ago

MiloTruck marked the issue as satisfactory

c4-judge commented 10 months ago

MiloTruck changed the severity to QA (Quality Assurance)

c4-judge commented 10 months ago

MiloTruck marked the issue as grade-a