Swivel v3 contest - Soosh's results

The Capital-Efficient Protocol For Fixed-Rate Lending.

General Information

Platform: Code4rena

Start Date: 12/07/2022

Pot Size: $35,000 USDC

Total HM: 13

Participants: 78

Period: 3 days

Judge: 0xean

Total Solo HM: 6

Id: 135

League: ETH

Swivel

Findings Distribution

Researcher Performance

Rank: 42/78

Findings: 2

Award: $73.08

🌟 Selected for report: 0

šŸš€ Solo Findings: 0

Low

Wrong boolean logic

incorrect boolean logic in ERC20.sol permit function

if (recoveredAddress != address(0) && recoveredAddress != owner) {
	revert Invalid(msg.sender, owner);
}
  • Allows an attacker to set allowance[address(0)][attacker] = Any value.
  • Note that ecrecover() returns 0x0 if v is any other number than 27 or 28.
  • This allows a valid recovered address of address(0)

Impact:

  • If ERC20 tokens from this contract get sent to address(0) (maybe for burning/removing supply purposes), an attacker can use approve() and transferFrom() address(0) to their address and retrieve the tokens.
  • The Approval(owner, spender, value) event will also be emit even though in reality, the spender does not have approval of owner.

Affected:

Recommendations:

  • I believe the desired logic to be
require(recoveredAddress != address(0) && recoveredAddress == owner)

(from https://github.com/Uniswap/v2-core/blob/8b82b04a0b9e696c0e83f8b2f00e5d7be6888c79/contracts/UniswapV2ERC20.sol#L91)

  • If so, it should be recoveredAddress == address(0) || recoveredAddress != owner (DeMorgan's Law)

QA

Interface and Contract mismatch

In MarketPlace.sol:

ISwivel(swivel).authRedeem(p, u, market.cTokenAddr, t, a);

ISwivel in Interfaces.sol contains the interface:

interface ISwivel {
Ā  function authRedeem(uint8 p, address u, address c, address t, uint256 a) external returns (bool);
}

But Swivel.sol does not have such a function. (Closest to it) Only authRedeemZcToken().

Affected Code:

#0 - robrobbins

2022-08-31T00:05:13Z

demorgan's and interface issues addressed via other tickets

Awards

27.195 USDC - $27.20

Labels

bug
duplicate
G (Gas Optimization)
wontfix

External Links

GAS

Redundant if checks.
  • These are if checks identified to not change the logic of the contracts. Which means their existence will use more gas without providing value.
  • All the following checks are of the form:
if (!someFunction()) {revert Exception()}
  • And someFunction() will always only return True (or revert). Because these functions will never return False, the additional check will never evaluate to True, and the revert Exceptions will never occur. That is to say, the checks serve no purpose.

All instances of redundant if checks:

MarketPlace.sol

Swivel.sol:

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Ā© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter