ENS contest - cRat1st0s's results

Decentralised naming for wallets, websites, & more.

General Information

Platform: Code4rena

Start Date: 12/07/2022

Pot Size: $75,000 USDC

Total HM: 16

Participants: 100

Period: 7 days

Judge: LSDan

Total Solo HM: 7

Id: 145

League: ETH

ENS

Findings Distribution

Researcher Performance

Rank: 57/100

Findings: 2

Award: $119.34

🌟 Selected for report: 0

🚀 Solo Findings: 0

2022-07-ens-code4rena Report

QA Report

Files Description Table

File NameSHA-1 Hash
2022-07-ens/contracts/dnssec-oracle/BytesUtils.sol08b2555ac9985aca02c219f6eda8faf6c9d3e0b2
2022-07-ens/contracts/dnssec-oracle/DNSSECImpl.sol2d5e0775a0cad79338b40f4217b5568f21578a00
2022-07-ens/contracts/dnssec-oracle/RRUtils.sol73e566eb8ea0ac6557ba23f566e36ab1fd12b830
2022-07-ens/contracts/dnssec-oracle/SHA1.sol4449a51d1f1b27374d725749a370dbb2f95608df
2022-07-ens/contracts/dnssec-oracle/Owned.sol9f09ce247e1d8e3f72550c139369cb717127918b
2022-07-ens/contracts/dnssec-oracle/DNSSEC.solfc32b531031113bf965c5170408ab3332d5ec24b
2022-07-ens/contracts/dnssec-oracle/algorithms/Algorithm.solf24be799629d960c085b880c8f9484cfa1a4e4e0
2022-07-ens/contracts/dnssec-oracle/digests/Digest.solf827dc3a7dafd1ead3b5f2385b7339a38d53e0a1
2022-07-ens/contracts/ethregistrar/ETHRegistrarController.sol176e5987c06673bee1123b139d11ff73c361f501
2022-07-ens/contracts/ethregistrar/IETHRegistrarController.sol0429622e73822e12b1d194044647782adf898088
2022-07-ens/contracts/ethregistrar/StringUtils.sol16a9a0ebaf547a3864fc4e615b3d7f23fa452095
2022-07-ens/contracts/registry/ReverseRegistrar.sol300665fd1fce3da7b3c96b8d94ccb0cd1e2bcdc8
2022-07-ens/contracts/registry/IReverseRegistrar.solb1adb404870c9079bc1f35d6c9ce5da855c04558
2022-07-ens/contracts/registry/ENS.sol1f3088ed0db49bedd380afe75f67f71ed361e82c
2022-07-ens/contracts/wrappers/BytesUtil.sol9f23ca1fba2f946e83f0cf6ac6afcf84ff04baa0
2022-07-ens/contracts/wrappers/ERC1155Fuse.sol12bba8a1fca817b5c48bb81898692a31f3c35290
2022-07-ens/contracts/wrappers/NameWrapper.solca6a2aa4d68aa373f09140b0649806c01800b845
2022-07-ens/contracts/wrappers/INameWrapper.sol11f9671414d746780888ee0988866be3a000b5ab
2022-07-ens/contracts/wrappers/Controllable.sol82b84e34556e8bad72209e37ef6c658c3a157cad
2022-07-ens/contracts/wrappers/IMetadataService.sol59b5f4d0cd4a2fe4f3af3e00fd571f9686833283
2022-07-ens/contracts/resolvers/Resolver.sol1e70307ba676992d47d0dae905c52d42d55dd29b

Issues found

[N-01]: Typos

Impact

None.

Code Affected and Mitigation
diff --git a/contracts/wrapper/NameWrapper.sol b/contracts/wrapper/NameWrapper.sol
index b652447..60854f0 100644
--- a/contracts/wrapper/NameWrapper.sol
+++ b/contracts/wrapper/NameWrapper.sol
@@ -367,7 +367,7 @@ contract NameWrapper is
     /**
      * @notice Sets fuses of a name
      * @param node namehash of the name
-     * @param fuses fuses to burn (cannot burn PARENT_CANOT_CONTROL)
+     * @param fuses fuses to burn (cannot burn PARENT_CANNOT_CONTROL)
      */
 
     function setFuses(bytes32 node, uint32 fuses)
@@ -531,7 +531,7 @@ contract NameWrapper is
      * @param label label of the subdomain as a string
      * @param newOwner newOwner in the registry
      * @param resolver resolver contract in the registry
-     * @param ttl ttl in the regsitry
+     * @param ttl ttl in the registry
      * @param fuses initial fuses for the wrapped subdomain
      * @param expiry expiry date for the domain
      */
Tools used

VS Code

[N-02]: Missing SPDX identifier

Impact

The need to identify the license for open source software is critical for both reporting purposes and license compliance.

Contracts Affected

2022-07-ens/contracts/wrapper/IMetadataService.sol 2022-07-ens/contracts/registry/ReverseRegistrar.sol 2022-07-ens/contracts/registry/IReverseRegistrar.sol 2022-07-ens/contracts/registry/ENS.sol 2022-07-ens/contracts/ethregistrar/StringUtils.sol 2022-07-ens/contracts/ethregistrar/IETHRegistrarController.sol 2022-07-ens/contracts/ethregistrar/ETHRegistrarController.sol 2022-07-ens/contracts/dnssec-oracle/Owned.sol 2022-07-ens/contracts/dnssec-oracle/digests/Digest.sol 2022-07-ens/contracts/dnssec-oracle/BytesUtils.sol 2022-07-ens/contracts/dnssec-oracle/algorithms/Algorithm.sol

Mitigation

Choose the appropriate license from the list.

Tools used

VS Code

2022-07-ens-code4rena Report

Gas Optimizations

Files Description Table

File NameSHA-1 Hash
2022-07-ens/contracts/dnssec-oracle/BytesUtils.sol08b2555ac9985aca02c219f6eda8faf6c9d3e0b2
2022-07-ens/contracts/dnssec-oracle/DNSSECImpl.sol2d5e0775a0cad79338b40f4217b5568f21578a00
2022-07-ens/contracts/dnssec-oracle/RRUtils.sol73e566eb8ea0ac6557ba23f566e36ab1fd12b830
2022-07-ens/contracts/dnssec-oracle/SHA1.sol4449a51d1f1b27374d725749a370dbb2f95608df
2022-07-ens/contracts/dnssec-oracle/Owned.sol9f09ce247e1d8e3f72550c139369cb717127918b
2022-07-ens/contracts/dnssec-oracle/DNSSEC.solfc32b531031113bf965c5170408ab3332d5ec24b
2022-07-ens/contracts/dnssec-oracle/algorithms/Algorithm.solf24be799629d960c085b880c8f9484cfa1a4e4e0
2022-07-ens/contracts/dnssec-oracle/digests/Digest.solf827dc3a7dafd1ead3b5f2385b7339a38d53e0a1
2022-07-ens/contracts/ethregistrar/ETHRegistrarController.sol176e5987c06673bee1123b139d11ff73c361f501
2022-07-ens/contracts/ethregistrar/IETHRegistrarController.sol0429622e73822e12b1d194044647782adf898088
2022-07-ens/contracts/ethregistrar/StringUtils.sol16a9a0ebaf547a3864fc4e615b3d7f23fa452095
2022-07-ens/contracts/registry/ReverseRegistrar.sol300665fd1fce3da7b3c96b8d94ccb0cd1e2bcdc8
2022-07-ens/contracts/registry/IReverseRegistrar.solb1adb404870c9079bc1f35d6c9ce5da855c04558
2022-07-ens/contracts/registry/ENS.sol1f3088ed0db49bedd380afe75f67f71ed361e82c
2022-07-ens/contracts/wrappers/BytesUtil.sol9f23ca1fba2f946e83f0cf6ac6afcf84ff04baa0
2022-07-ens/contracts/wrappers/ERC1155Fuse.sol12bba8a1fca817b5c48bb81898692a31f3c35290
2022-07-ens/contracts/wrappers/NameWrapper.solca6a2aa4d68aa373f09140b0649806c01800b845
2022-07-ens/contracts/wrappers/INameWrapper.sol11f9671414d746780888ee0988866be3a000b5ab
2022-07-ens/contracts/wrappers/Controllable.sol82b84e34556e8bad72209e37ef6c658c3a157cad
2022-07-ens/contracts/wrappers/IMetadataService.sol59b5f4d0cd4a2fe4f3af3e00fd571f9686833283
2022-07-ens/contracts/resolvers/Resolver.sol1e70307ba676992d47d0dae905c52d42d55dd29b

Issues found

[G-01]: For-Loops: Pre-increments cost less gas compared to post-increments

Impact

Pre-increments cost less gas compared to post-increments.

Code Affected:

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L266

for(uint i = 0; i < len; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L313

for(uint256 idx = off; idx < off + len; idx++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/DNSSECImpl.sol#L93

for(uint i = 0; i < input.length; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/ETHRegistrarController.sol#L256

for (uint256 i = 0; i < data.length; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L14

for(len = 0; i < bytelength; len++) {
Mitigation

Change i++ to ++i.

Tools used

VS Code

[G-02]: For-Loops: Increments can be unchecked

Impact

In Solidity 0.8+, there’s a default overflow check on unsigned integers.

Code Affected:

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L266

for(uint i = 0; i < len; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L313

for(uint256 idx = off; idx < off + len; idx++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/DNSSECImpl.sol#L93

for(uint i = 0; i < input.length; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/ETHRegistrarController.sol#L256

for (uint256 i = 0; i < data.length; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L14

for(len = 0; i < bytelength; len++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/wrapper/ERC1155Fuse.sol#L92

for (uint256 i = 0; i < accounts.length; ++i) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/wrapper/ERC1155Fuse.sol#L205

for (uint256 i = 0; i < ids.length; ++i) {
Mitigation

One example is the code would go from:

for (uint i = 0; i < _prices.length; i++) { priceAverageCumulative += _prices[i]; }

to:

for (uint i = 0; i < _prices.length;) { priceAverageCumulative += _prices[i]; unchecked { i++; } }
Tools used

VS Code

[G-03]: For-Loops: No need to explicitly initialize variables with default values

Impact

If a variable is not set/initialized, it is assumed to have the default value (0, false, 0x0 etc depending on the data type). If you explicitly initialize it with its default value, you are just wasting gas.

Code Affected:

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L56

for (uint idx = 0; idx < shortest; idx += 32) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L266

for(uint i = 0; i < len; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L313

for(uint256 idx = off; idx < off + len; idx++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/DNSSECImpl.sol#L93

for(uint i = 0; i < input.length; i++) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/ETHRegistrarController.sol#L257

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/wrapper/ERC1155Fuse.sol#L92

for (uint256 i = 0; i < accounts.length; ++i) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/wrapper/ERC1155Fuse.sol#L205

for (uint256 i = 0; i < ids.length; ++i) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L310

for(uint i = 0; i < data.length + 31; i += 32) {
Mitigation

Do not initialize variables with default values.

Tools used

VS Code

[G-04]: Variables: variable1 += variable2

Impact

variable1 += (-=) variable2 costs more gas than variable1 = variable1 +(-) variable2

Code Affected:

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L75

selfptr += 32;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L76

otherptr += 32;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L209

for (; len >= 32; len -= 32) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L213

dest += 32;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L214

src += 32;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L284

bitlen -= 2;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L288

bitlen -= 4;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L292

bitlen -= 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L296

bitlen -= 3;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L24

idx += labelLen + 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L54

offset += labelLen + 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L58

count += 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L150

off += 2;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L152

off += 2;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L154

off += 4;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L158

off += 2;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L250

counts -= 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L310

for(uint i = 0; i < data.length + 31; i += 32) {

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L319

ac1 += (word & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >> 8;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L320

ac2 += (word & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF);

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L333

ac1 += (ac1 >> 16) & 0xFFFF;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L17

i += 1;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L19

i += 2;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L21

i += 3;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L23

i += 4;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L25

i += 5;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L27

i += 6;
Mitigation

Use variable1 = variable1 +(-) variable2 instead.

Tools used

VS Code

[G-05]: Variables: No need to explicitly initialize variables with default values

Impact

If a variable is not set/initialized, it is assumed to have the default value (0, false, 0x0 etc depending on the data type). If you explicitly initialize it with its default value, you are just wasting gas.

Code Affected:

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/BytesUtils.sol#L264

uint ret = 0;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L50

uint count = 0;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L63

uint constant RRSIG_TYPE = 0;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L181

uint constant DNSKEY_FLAGS = 0;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/dnssec-oracle/RRUtils.sol#L200

uint constant DS_KEY_TAG = 0;

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/StringUtils.sol#L12

uint i = 0;
Mitigation

Do not initialize variables with default values.

Tools used

VS Code

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