Platform: Code4rena
Start Date: 14/04/2023
Pot Size: $90,500 USDC
Total HM: 7
Participants: 59
Period: 14 days
Judge: LSDan
Total Solo HM: 3
Id: 232
League: ETH
Rank: 39/59
Findings: 1
Award: $59.79
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Sathish9098
Also found by: 0x73696d616f, 0xAgro, 0xSmartContract, 0xTheC0der, ABA, ArbitraryExecution, Aymen0909, BRONZEDISC, Bauchibred, Dyear, Eurovickk, IceBear, Jerry0x, Jorgect, Josiah, MalfurionWhitehat, MohammedRizwan, RaymondFam, Recep, Rickard, SAAJ, Shubham, Udsen, auditor0517, brgltd, catellatech, chaduke, codeslide, eierina, favelanky, j4ld1na, lukris02, matrix_0wl, naman1778, pontifex, schrodinger, tnevler, urataps
59.7928 USDC - $59.79
Issue | Instances | |
---|---|---|
N-1 | Use of block.timestamp | 1 |
N-2 | Functions not used internally could be marked external | 5 |
N-3 | Adding a return statement when the function defines a named return variable, is redundant | 2 |
N-4 | File does not contain an SPDX | 10 |
N-5 | Assembly Codes Specific – Should Have Comments | 15 |
Block timestamps have historically been used for a variety of applications, such as entropy for random numbers (see the Entropy Illusion for further details), locking funds for periods of time, and various state-changing conditional statements that are time-dependent. Miners have the ability to adjust timestamps slightly, which can prove to be dangerous if block timestamps are used incorrectly in smart contracts.
Block timestamps should not be used for entropy or generating random numbers — i.e., they should not be the deciding factor (either directly or through some derivation) for winning a game or changing an important state.
Time-sensitive logic is sometimes required; e.g., for unlocking contracts (time-locking), completing an ICO after a few weeks, or enforcing expiry dates. It is sometimes recommended to use block.number and an average block time to estimate times; with a 10 second block time, 1 week equates to approximately, 60480 blocks. Thus, specifying a block number at which to change a contract state can be more secure, as miners are unable to easily manipulate the block number.
Instances where block.timestamp is used:
Find (1) instance(s) in contracts:
File: dnssec-oracle/DNSSECImpl.sol 96: return verifyRRSet(input, block.timestamp);
Find (5) instance(s) in contracts:
File: dnsregistrar/DNSRegistrar.sol 80: function setPublicSuffixList(PublicSuffixList _suffixes) public onlyOwner { 90: function proveAndClaim( 101: function proveAndClaimWithResolver(
File: dnssec-oracle/DNSSECImpl.sol 64: function setAlgorithm(uint8 id, Algorithm algo) public owner_only { 75: function setDigest(uint8 id, Digest digest) public owner_only {
similar finding: https://code4rena.com/reports/2022-04-phuture/#n-01-adding-a-return-statement-when-the-function-defines-a-named-return-variable-is-redundant Find (2) instance(s) in contracts:
File: dnssec-oracle/DNSSECImpl.sol 127: return (proof, inception); 173: return rrset;
similar finding: https://code4rena.com/reports/2022-05-cudos/#14-file-does-not-contain-an-spdx-identifier
Find (11) instance(s) in contracts:
File: dnssec-oracle/BytesUtils.sol 1: pragma solidity ^0.8.4;
File: dnssec-oracle/RRUtils.sol 1: pragma solidity ^0.8.4;
File: dnssec-oracle/SHA1.sol 1: pragma solidity >=0.8.4;
File: dnssec-oracle/algorithms/EllipticCurve.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/EllipticCurve.sol
File: dnssec-oracle/algorithms/ModexpPrecompile.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/ModexpPrecompile.sol
File: dnssec-oracle/algorithms/P256SHA256Algorithm.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/P256SHA256Algorithm.sol
File: dnssec-oracle/algorithms/RSASHA1Algorithm.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/RSASHA1Algorithm.sol
File: dnssec-oracle/algorithms/RSASHA256Algorithm.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/RSASHA256Algorithm.sol
File: dnssec-oracle/algorithms/RSAVerify.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/algorithms/RSAVerify.sol
File: dnssec-oracle/digests/SHA1Digest.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/digests/SHA1Digest.sol
File: dnssec-oracle/digests/SHA256Digest.sol 1: pragma solidity ^0.8.4;
dnssec-oracle/digests/SHA256Digest.sol
Since this is a low level language that is more difficult to parse by readers, include extensive documentation, comments on the rationale behind its use, clearly explaining what each assembly instruction does
This will make it easier for users to trust the code, for reviewers to validate the code, and for developers to build on or update the code.
Note that using Aseembly removes several important security features of Solidity, which can make the code more insecure and more error-prone.
Find (15) instance(s) in contracts:
File: dnssec-oracle/BytesUtils.sol 19: assembly { 73: assembly { 80: assembly { 197: assembly { 213: assembly { 229: assembly { 245: assembly { 267: assembly { 276: assembly { 286: assembly { 311: assembly {
File: dnssec-oracle/RRUtils.sol 386: assembly {
File: dnssec-oracle/SHA1.sol 7: assembly {
File: dnssec-oracle/algorithms/ModexpPrecompile.sol 23: assembly {
dnssec-oracle/algorithms/ModexpPrecompile.sol
File: utils/HexUtils.sol 17: assembly {
Initializers could be front-run, allowing an attacker to either set their own values, take ownership of the contract, and in the best case forcing a re-deployment
Find (2) instance(s) in contracts:
File: dnsregistrar/DNSClaimChecker.sol 25: buf.init(name.length + 5);
dnsregistrar/DNSClaimChecker.sol
File: dnssec-oracle/DNSSECImpl.sol 398: buf.init(keyname.length + keyrdata.length);
The Yul call return value on function modexp is not checked. similar finding: https://github.com/code-423n4/2022-11-non-fungible-findings/issues/90
File: dnssec-oracle/algorithms/ModexpPrecompile.sol 23: assembly { 24: success := staticcall( 25: gas(), 26: 5, 27: add(input, 32), 28: mload(input), 28: add(output, 32), 30: mload(modulus) 31: ) 32: }
dnssec-oracle/algorithms/ModexpPrecompile.sol
Add checks to ensure function calls succeed or fail. When the return value is false, strictly revert the transaction.
#0 - c4-pre-sort
2023-05-02T04:43:46Z
thereksfour marked the issue as low quality report
#1 - thereksfour
2023-05-02T04:44:12Z
L1/L2 Incorrect
#2 - c4-judge
2023-05-09T08:55:53Z
dmvt marked the issue as grade-b