NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

All Tokens Are Whitelisted By Default Across Chains

Summary

The _whiteListEnabled variable on Ethereum and white_list_enabled variable on Starknet are intended to control whether the whitelist mechanism is activated. If these variables are set to false, the whitelist mechanism is disabled, allowing all tokens to be bridged across chains without any restrictions. Unfortunately, both variables are initialized to false by default, which means that, upon deployment, all tokens are automatically allowed for cross-chain activities. This default setting could pose a significant security risk.

Vulnerability Details

The variables _whiteListEnabled on Ethereum and white_list_enabled on Starknet serve as flags to indicate whether the whitelist mechanism is active.

// Ethereum
bool _whiteListEnabled;
// Stark
// White list enabled flag
white_list_enabled: bool,

If _whiteListEnabled or white_list_enabled is false, the whitelist check is bypassed, and all tokens are treated as if they are whitelisted by default:

function _isWhiteListed(
address collection
) internal view returns (bool) {
return !_whiteListEnabled || _whiteList[collection];
}
fn _is_white_listed(self: @ContractState, collection: ContractAddress) -> bool {
let enabled = self.white_list_enabled.read();
if (enabled) {
let (ret, _) = self.white_listed_list.read(collection);
return ret;
}
true
}

The issue arises because both _whiteListEnabled and white_list_enabled are initialized to false by default (they are not explicitly set to true during initialization or in the constructor). As a result, all tokens are automatically permitted to bridge across chains without any restrictions when the contract is first deployed.

A proof of concept (PoC) demonstrates this issue:

function testWhitelistCheck() public {
IStarklane(bridge).isWhiteListed(address(1));
}

The output log from the test shows that all collections are considered whitelisted by default:

[PASS] testWhitelistCheck() (gas: 12762)
Traces:
[12762] BridgeTest::testWhitelistCheck()
├─ [7498] ERC1967Proxy::isWhiteListed(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [2600] Starklane::isWhiteListed(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← [Return] true
│ └─ ← [Return] true
└─ ← [Stop]

Impact

The fact that all tokens are whitelisted by default can lead to unauthorized cross-chain activities immediately after the contract is deployed and initialized. This poses a severe security risk, as it could allow malicious or unintended tokens to be transferred across chains without any restrictions.

Tools Used

Manual, Foundry

Recommendations

To mitigate this issue, it is recommended to initialize the _whiteListEnabled and white_list_enabled variables to true by default.

Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Informational / Gas

Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.