Trader Joe contest - UncleGrandpa925's results

One-stop-shop decentralized trading on Avalanche.

General Information

Platform: Code4rena

Start Date: 25/01/2022

Pot Size: $50,000 USDT

Total HM: 17

Participants: 39

Period: 3 days

Judge: LSDan

Total Solo HM: 9

Id: 79

League: ETH

Trader Joe

Findings Distribution

Researcher Performance

Rank: 23/39

Findings: 3

Award: $375.10

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

Labels

bug
duplicate
2 (Med Risk)

Awards

60.3184 USDT - $60.32

External Links

Handle

UncleGrandpa925

Vulnerability details

Impact

Users' tokens can be stuck inside LaunchEvent if the token doesn't revert on failed transfers.

Issue

When users call withdrawIncentives, if for any reasons the token transfer fails & the token doesn't revert but only returns a boolean, the user's incentives will be stuck. This is because once withdrawIncentives is called, user.hasWithdrawnIncentives will be set to true & therefore prevents the user from calling the function a second time.

Only 2 solutions are possible: either the issurer trigger emergency (which will crash the event), or the issurer can call skim & get back the tokens from the PenaltyCollector to manually distribute it to the user.

Use OZ's SafeTransfer

#0 - cryptofish7

2022-02-10T20:31:43Z

Duplicate of #12

#1 - dmvt

2022-02-22T10:50:21Z

This could result in a loss of funds given the right external conditions.

2 β€” Med (M): vulns have a risk of 2 and are considered β€œMedium” severity when assets are not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

Findings Information

🌟 Selected for report: cmichel

Also found by: UncleGrandpa925, WatchPug, harleythedog

Labels

bug
duplicate
2 (Med Risk)

Awards

283.7493 USDT - $283.75

External Links

Handle

UncleGrandpa925

Vulnerability details

Impact

This issue impacts all LaunchEvent, forcing the issuer to write additional contracts to be able to createPair in LaunchEvent else it will always revert.

Issue & Proof of Concept

In LaunchEvent.sol, the function createPair is supposed to be called by anyone at the start of Phase 3 to create the pair & add all the liquidity inside the LaunchEvent to the pool, getting LP back.

On line 411, the action of adding liquidity set the amountAMin & amountBMin to be the equal to wavaxAddress and tokenAllocated respectively. In other words, this forces add all the liquidity inside LaunchEvent to the pool, and will revert if it can't be done.

An attacker can just transfer a non-zero amount of WAVAX (even 1 wei) to the pool preemptively (as the address of the pool is known before Phase 1, long before Phase 3 where createPair is actually called). The attacker then calls sync to force the wavax reserve to be non-zero.

Now that the reserves are non-zero, the router can't simply use the expected path in the Joe Router02's _addLiquidity: if (reserveA == 0 && reserveB == 0) { to dump all the liquidity in, but will have to go with the else part, where it will certainly fail because of the error JoeLibrary: INSUFFICIENT_LIQUIDITY in the quote function.

To prevent this & totally eliminate the chances of front-running, the issuer will have to write an additional contract to call the pool's skim before calling createPair.

  • In the createPair function, check if the pool has existed, if yes, call skim before calling addLiquidity

Note

Proposing this as Medium Risk since it's trivial to exploit and cause troubles for the issurer. Not High risk since the fix is reasonably easy even without modifiying the contract.

#0 - cryptofish7

2022-02-10T20:33:15Z

Duplicate of #281

Findings Information

🌟 Selected for report: sirhashalot

Also found by: 0v3rf10w, 0x1f8b, Dravee, UncleGrandpa925, cccz, defsec, gzeon

Labels

bug
duplicate
1 (Low Risk)
disagree with severity

Awards

31.028 USDT - $31.03

External Links

Handle

UncleGrandpa925

Vulnerability details

Issue

Lack of checks for data passed into onlyOwner functions.

For example:

  • No zero checks on setPenaltyCollector. This may lead to penalty being silently transferred to address zero in LaunchEvent.
  • No zero checks on setRouter. This may lead to LaunchEvent's interaction with router (in createPool) to permanently revert, forcing emergency.
  • Similarly, there are no bounds checks on setPhaseDuration, setPhaseOneNoFeeDuration & setRJoePerAvax, opening up the possibility of erroneous values being set in LaunchEvents, possibly causing these events to be aborted & tokens to be redeployed (since there can only be one LaunchEvent for one token).

In conclusion, the lack of checks for these important functions may seriously affect the launch of protocols.

  • Add more stringent checks to all onlyOwner functions

Note

Proposing this as Medium after reffering to a few past reports where there weren't sufficient checks for onlyOwner functions may disrupt the availability of the protocol. Considering the fact that the launch of any protocols is a very important event for them, these issues shouldn't happen.

#0 - cryptofish7

2022-02-10T14:10:42Z

Duplicate of #263

#1 - dmvt

2022-02-22T19:53:07Z

While this could impact availability and potential cause some small fund loss, the likelihood of it occurring is very low given that these are all admin level functions. I agree with the sponsor and other wardens who ranked this low risk.

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