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: 48/100
Findings: 2
Award: $85.62
🌟 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.8976 USDC - $54.90
rederSvg
method is vulnerable to json and XML injections, and could facilitate an XSS attack. Sanitize user inputs is mandatory because the user can inject into SVG's javascript logic.This is one example of XSS inside a SVG
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" style="background:#000"> <script type="text/javascript"> alert("Ghostlulz XSS"); </script> </svg>
Reference:
Source affected:
It is important to issue an event when features are changed that imply changes in the economics or ecosystem of the project, so that users and dapps can react accordingly.
Source affected:
Because is not possible to call withdraw when vault.isExercised == true, the method initiateWithdraw should check that isExercised == false
🌟 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.72 USDC - $30.72
function _forceTransfer(address to, uint256 id) internal { require(to != address(0), "INVALID_RECIPIENT"); emit Transfer(_ownerOf[id], to, id); _ownerOf[id] = to; delete getApproved[id]; }
++i
costs less gas compared to i++
or i += 1
++i
costs less gas compared to i++
or i += 1
for unsigned integer, as pre-increment is cheaper (about 5 gas per iteration). This statement is true even with the optimizer enabled.
i++
increments i
and returns the initial value of i
. Which means:
uint i = 1; i++; // == 1 but i == 2
But ++i
returns the actual incremented value:
uint i = 1; ++i; // == 2 and i == 2 too, so no need for a temporary variable
In the first case, the compiler has to create a temporary variable (when used) for returning 1
instead of 2
Instances include:
LendTicket.sol:39: balanceOf[from]--; LendTicket.sol:41: balanceOf[to]++;
I suggest using ++i
instead of i++
to increment the value of an uint variable. Same thing for --i
and i--
Affected source:
Solidity version 0.8+ comes with implicit overflow and underflow checks on unsigned integers. When an overflow or an underflow isn't possible (as an example, when a comparison is made before the arithmetic operation), some gas can be saved by using an unchecked block: https://docs.soliditylang.org/en/v0.8.10/control-structures.html#checked-or-unchecked-arithmetic
Source affected:
Moving the line 208 to 216 it's possible to save gas under specific circumstances because the variable vault is not used before.
It's compared a boolean value using == false
, instead of using the boolean value, or NOT
opcode, it's cheaper to use NOT
when the value it's false, or just the value without == true
, when it's true, because it will use less opcode inside the VM.