Tracer contest - JMukesh's results

Build and trade with Tracer’s Perpetual Swaps and gain leveraged exposure to any market in the world.

General Information

Platform: Code4rena

Start Date: 24/06/2021

Pot Size: $80,000 USDC

Total HM: 18

Participants: 12

Period: 7 days

Judge: cemozer

Total Solo HM: 11

Id: 16

League: ETH

Tracer

Findings Distribution

Researcher Performance

Rank: 8/12

Findings: 3

Award: $2,191.84

🌟 Selected for report: 4

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: s1m0

Also found by: 0xRajeev, JMukesh, Lucius, cmichel, pauliax, shw

Labels

bug
duplicate
2 (Med Risk)

Awards

152.8313 USDC - $152.83

External Links

Handle

JMukesh

Vulnerability details

Impact

return value from transfer()/transferFrom ensure success of the call and if not , it describe the reason for. It is usually good to add a require-statement that checks the return value or to use something like safeTransfer; unless one is sure the given token reverts in case of a failure.

Proof of Concept

reference --> https://consensys.net/diligence/audits/2021/01/fei-protocol/#unchecked-return-value-for-iweth-transfer-call

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/TracerPerpetualSwaps.sol#L203

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/TracerPerpetualSwaps.sol#L151

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/Insurance.sol#L97

Tools Used

manual review

use safeTransfer()/SafeTransferFrom

#0 - raymogg

2021-07-05T03:25:21Z

Duplicate of #115

Findings Information

🌟 Selected for report: 0xRajeev

Also found by: JMukesh, cmichel, gpersoon, pauliax, shw

Labels

bug
duplicate
1 (Low Risk)

Awards

66.0382 USDC - $66.04

External Links

#0 - raymogg

2021-07-05T23:42:00Z

Duplicate of #136

Findings Information

🌟 Selected for report: shw

Also found by: JMukesh

Labels

bug
duplicate
1 (Low Risk)

Awards

301.9579 USDC - $301.96

External Links

Handle

JMukesh

Vulnerability details

Impact

https://swcregistry.io/docs/SWC-103

Tools Used

manual review

use fixed solidity version

#0 - raymogg

2021-07-05T23:17:47Z

Duplicate of #133

Findings Information

🌟 Selected for report: JMukesh

Labels

bug
1 (Low Risk)
sponsor confirmed

Awards

671.0176 USDC - $671.02

External Links

Handle

JMukesh

Vulnerability details

Impact

These array memory parameter can be problematic if not used properly , if the array is very large it may overlap over other part of memory.

Proof of Concept

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/Liquidation.sol#L274

This an example to show the exploit: // based on https://github.com/paradigm-operations/paradigm-ctf-2021/blob/master/swap/private/Exploit.sol pragma solidity ^0.4.24; // only works with low solidity version

contract test{ struct Overlap { uint field0; } event log(uint);

function mint(uint[] memory amounts) public returns (uint) { // this can be in any solidity version Overlap memory v; v.field0 = 1234; emit log(amounts[0]); // would expect to be 0 however is 1234 return 1; }

function go() public { // this part requires the low solidity version uint x=0x800000000000000000000000000000000000000000000000000000000000000; // 2^251 bytes memory payload = abi.encodeWithSelector(this.mint.selector, 0x20, x); bool success=address(this).call(payload); } }

Tools Used

manual review

check array length before using it

#0 - raymogg

2021-07-05T23:10:24Z

Duplicate of #79

#1 - sporejack

2021-07-07T00:42:51Z

So the provided PoC code works (under solc 0.4.24) subject to test case:

const { expect } = require("chai");

describe("Overlap", async () => {
    describe("go", async () => {
        let overlapFactory;
        let overlap;

        before(async () => {
            overlapFactory = await ethers.getContractFactory("Overlap");
            overlap = await overlapFactory.deploy();

            await overlap.deployed();
        });

        context("When called", async () => {
          it("Emits `log` event with correct value", async () => {
            var firstAmount = ethers.BigNumber.from("1234");
        
            await expect(overlap.go()).to.emit(overlap, "log").withArgs(firstAmount);
          });
        });
    });
});

#2 - sporejack

2021-07-07T00:45:28Z

My assessment is:

ImpactDifficultyOverall
LowLowLow

With rationale:

  • Unclear (a priori) exactly how PoC constitutes an exploit
  • PoC payload will likely cause unexpected behaviour in production codebase
  • Relatively easy for adversary to craft viable payload (simple overflow)

Findings Information

🌟 Selected for report: JMukesh

Labels

bug
G (Gas Optimization)
sponsor confirmed

Awards

333.3333 USDC - $333.33

External Links

Handle

JMukesh

Vulnerability details

Impact

Unused state variable will increase unnecessarily code size and use the memory

Proof of Concept

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/oracle/GasOracle.sol#L19

Tools Used

manual review

remove the variable which are unused

Findings Information

🌟 Selected for report: JMukesh

Labels

bug
G (Gas Optimization)
sponsor confirmed

Awards

333.3333 USDC - $333.33

External Links

Handle

JMukesh

Vulnerability details

Impact

public function which are not called within contract should be declared as external to save gas

Proof of Concept

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/TracerPerpetualSwaps.sol#L572

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/Liquidation.sol#L470

https://github.com/code-423n4/2021-06-tracer/blob/74e720ee100fd027c592ea44f272231ad4dfa2ab/src/contracts/InsurancePoolToken.sol#L14

Tools Used

manual review

Declare public function as external which are not called in the contract

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