Platform: Code4rena
Start Date: 10/05/2022
Pot Size: $50,000 USDC
Total HM: 13
Participants: 100
Period: 5 days
Judge: HardlyDifficult
Total Solo HM: 1
Id: 122
League: ETH
Rank: 57/100
Findings: 2
Award: $84.98
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: hubble
Also found by: 0x1337, 0x1f8b, 0x4non, 0xDjango, 0xf15ers, 0xsanson, 242, Aits, AlleyCat, Bludya, BondiPestControl, BouSalman, BowTiedWardens, CertoraInc, Cityscape, Czar102, FSchmoede, Funen, Hawkeye, IllIllI, JDeryl, Kenshin, Kumpa, MaratCerby, MiloTruck, Picodes, Ruhum, TrungOre, VAD37, WatchPug, Waze, antonttc, bobirichman, catchup, cccz, cryptphi, csanuragjain, delfin454000, dipp, dirk_y, djxploit, eccentricexit, ellahi, fatherOfBlocks, hake, hansfriese, hickuphh3, horsefacts, hyh, jah, joestakey, mics, minhquanym, pedroais, pmerkleplant, radoslav11, reassor, rfa, robee, seanamani, shenwilly, shung, sikorico, sorrynotsorry, sseefried, z3s
54.892 USDC - $54.89
Low
token
addressesIn Cally.sol a user can call the createVault() function passing in a malicious attacker controlled token as the address token
. This will then create a vault setting the evil token address as in storage. Attacker controlled assets should never be allowed in a protocol as they can return arbitrary values when called upon performing other malicious tasks then whats expected.
##Tool Used Manual Review
##Recommended Mitigation
Consider adding a mapping of approved tokens that can be passed in as an token
address to the createVault() function to avoid malicious tokens.
safeMint()
rather than mint()
This POC It can be consider for dev if may necessary for better way
The `_safeMint` can be using if minting causes the recipient of the tokens, if it is a smart contract, to react upon receipt of the tokens. Here is a general consideration to help decide which one to use: If YOU are paying for the minting of tokens, use `_mint`. The `_safeMint` might cost you an arbitrary amount of money because of choices made by the recipient of the tokens. If THEY are paying for the minting of tokens and you expect buyers to be composing functionality with smart contracts, use _safeMint. There is some marginal benefit of allowing the extra features with smart contracts this allows. If THEY are paying and you expect INDIVIDUAL PEOPLE to buy tokens, then use _mint. The extra features in _safeMint are not expected. The extra cost from using _safeMint is non-zero. And cost is also always a concern.
since Cally.sol
was used to be main actor, it can be used safemint() instead of mint()
##Tool Used Manual Review
@return
was not setThis was not set information for @return, since other function() was set if @return was used so it can be added for good information to the others.
##Tool Used Manual Review
Non Critical
It should be an overrides function
but instead of overrides
, dev was used ovverides
. It can be remain the same, or it can be changed instead.
##Tool Used Manual Review
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xf15ers, 0xkatana, 0xsanson, Bludya, BowTiedWardens, CertoraInc, Cityscape, DavidGialdi, FSchmoede, Fitraldys, Funen, Hawkeye, Kenshin, MadWookie, MaratCerby, MiloTruck, Picodes, RagePit, Tadashi, TerrierLover, TomFrenchBlockchain, VAD37, WatchPug, Waze, _Adam, antonttc, bobirichman, catchup, defsec, delfin454000, djxploit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, ignacio, joestakey, jonatascm, mics, minhquanym, oyc_109, pmerkleplant, rfa, robee, rotcivegaf, samruna, shung, sikorico, simon135, z3s
30.0888 USDC - $30.09
This can be implemented for save gas cost
##Tool Used vsc, gas test
##Recommended Mitigation
Change to :
struct Vault { address token; uint8 premiumIndex; // indexes into `premiumOptions` uint8 durationDays; // days uint8 dutchAuctionStartingStrikeIndex; // indexes into `strikeOptions` uint32 currentExpiration; bool isExercised; bool isWithdrawing; TokenType tokenType; uint256 currentStrike; uint256 tokenIdOrAmount; uint256 dutchAuctionReserveStrike; }
= 0
This code can be saving more gas by removing = 0, it because If a variable was not set/initialized, it is assumed to have default value to 0
##TOOLS USED Manual Review
##Mitigation Step
Remove = 0
##Occurance Cally.sol#L94 Cally.sol#L95 Cally.sol#L126
This can be using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.
Manual Review
uint256 i = 0
into uint256 i
for saving more gasSince uint256 default was zero, so this implementation by removing = 0, can saving more gas for each loops.
##Tool Used Manual Review
##Recommended Mitigation Change it