RebateFi Hook

First Flight #53
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Severity: high
Valid

[H-1] - Hook deployment may revert because of improper validation

_beforeInitialize improper validation will cause impossibility to initialize

Description

  • When the RebatiFiHook is initialized, it does not check if ReFi token is not present in key.currency0. This will cause the hook to not deploy everytime when ReFi token is not in key.currency1

function _beforeInitialize(address, PoolKey calldata key, uint160) internal view override returns (bytes4) {
@>> if (Currency.unwrap(key.currency1) != ReFi &&
@>> Currency.unwrap(key.currency1) != ReFi) {
revert ReFiNotInPool();
}
return BaseHook.beforeInitialize.selector;
}

Risk

Likelihood: HIGH

  • Hook won't be initialized everytime ReFi token is not in PoolKey.currency1 .

Impact: HIGH

  • Improper validation logic will cause hook to not be deployed, setting users unable to trade through the hook.

Proof of Concept

Recommended Mitigation

  • Here is the recommended mitigation:

function _beforeInitialize(address, PoolKey calldata key, uint160) internal view override returns (bytes4) {
if (Currency.unwrap(key.currency1) != ReFi &&
- Currency.unwrap(key.currency1) != ReFi) {
+ Currency.unwrap(key.currency0) != ReFi) {
revert ReFiNotInPool();
}
return BaseHook.beforeInitialize.selector;
}
Updates

Lead Judging Commences

chaossr Lead Judge 12 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Faulty pool check; only checks currency1 twice, omitting currency0.

Support

FAQs

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

Give us feedback!