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

Bridge functionality disabled by default (setting _enabled to false) with no enabling mechanism

Summary

_enabled is set to false in the initialize() making it impossible to deposit tokens.

Vulnerability Details

The initialize function sets _enabled to false when the contract is initialized.

function initialize(
bytes calldata data
)
public
onlyInit
{
(
address owner,
IStarknetMessaging starknetCoreAddress,
uint256 starklaneL2Address,
uint256 starklaneL2Selector
) = abi.decode(
data,
(address, IStarknetMessaging, uint256, uint256)
);
_enabled = false;
_starknetCoreAddress = starknetCoreAddress;
_transferOwnership(owner);
setStarklaneL2Address(starklaneL2Address);
setStarklaneL2Selector(starklaneL2Selector);
}

https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L59

The depositTokens function checks if _enabled is true before allowing any token deposits. If _enabled is false, it reverts with a BridgeNotEnabledError.

function depositTokens(
uint256 salt,
address collectionL1,
snaddress ownerL2,
uint256[] calldata ids,
bool useAutoBurn
)
external
payable
{
if (!Cairo.isFelt252(snaddress.unwrap(ownerL2))) {
revert CairoWrapError();
}
if (!_enabled) {
revert BridgeNotEnabledError();
}

https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L91C8-L93C10

The Bridge contract is initialized with the _enabled flag set to false, effectively disabling all token deposit functionality. However, there is no public function to enable the bridge after initialization. This means that the core functionality of the contract (depositing tokens) is unusable after deployment.

Impact

Users will not be able to deposit any tokens using the depositTokens function, as it will always revert with a BridgeNotEnabledError. This renders the main purpose of the bridge contract non-functional.

Tools Used

Manual review

Recommendations

If the intention is to have the bridge enabled by default, modify the initialize function to set _enabled = true.

If the bridge should start disabled but be enableable later, include enableBridge function callable only by a privileged address.

Updates

Lead Judging Commences

n0kto Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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