Tronempire smart contract security audit report performed by Callisto Security Audit Department
This is a game on a smart contract. The user for the in-game currency tickets buys several types of transport and receives a profit for it.
In total, 3 issues were reported including:
-
1 medium severity issue.
-
1 note.
-
1 minor observation.
No critical security issues were found.
When the transport is joined, the values are summed. tto.count
and tfrom.count
are uint16
with a maximum value of 65535. But when summed, they can exceed this value. There is a check at line 403:
require(tto.count + tfrom.count <= 65535, "Too large count");
But it can also overflow.
Example:
// tto.count += tfrom.count;
tto.count = 30000 + 35550; // this equals 14
It is real case because 65535 Steam Engines (transport type #2) cost about $ 180,000. Or if someone today buys Steam Engines for $ 25,000, he will receive such a quantity of transport in about a year without additional investments.
Use condition require(tto.count + tfrom.count > tto.count, "Too large count");
When calculating the cost may overflow if some parameters(like tt.price
or maximum value of _count
) in the code will be updated.
This should be taken into account, for example, when updating the transport parameters.
function removeWithLength(), line 447
In fact, when using remove()
or removeWithLength()
functions the elements of the transport array is not deleted from the storage. Just changing the variable length
of m.units
structure. This means that if we directly call to the element m.units.items[i]
with the index of the removed item, we will be able to get the removed transport data, or change them.
In the code of the contract, there was not found the possibility of direct access by index, but it's better to clear data from storage.
There are some vulnerabilities were found that should be fixed.
https://gist.github.com/yuriy77k/4a6836cb71f924056a9b4727e02d78d8
https://gist.github.com/yuriy77k/c47b96bef121308cc905727a6cd6fded
https://gist.github.com/yuriy77k/ed9195212c45d480fbed8d66f2c1f72c