You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ethsec@7d5131fcbad1:/share$ slither .
SlitherNotUnprotectedUpgrade.swapExactTokensForTokens(uint256,address,address,address) (contracts/SlitherNotUnprotectedUpgrade.sol#27-44) uses delegatecall to a input-controlled function id
- (success,returndata) = _router.delegatecall(abi.encodeCall(IUniswapV2.swapExactTokensForTokens,(amount,token0,token1,receiver))) (contracts/SlitherNotUnprotectedUpgrade.sol#34-36)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#controlled-delegatecall
It looks like OpenZeppelin introduced _disableInitializers specifically for EIP-1167 proxied contracts:
It is recommended to use this to lock implementation contracts that are designed to be called through proxies.
I unit tested and I cannot call initilizer on implementation after calling _disableInitializer, so I believe this detection is a false positive. Also I think the problem lies in this code
# to avoid future FPs in different modifier + function naming implementations, we can also implement a broader check for state var "_initialized" being written to in the constructor
# though this is still subject to naming false positives...
Describe the issue:
It seems
unprotected-upgrade
can be detected on contracts that have disabled initializers in their constructor. See the following example:And detection by
slither
:It looks like OpenZeppelin introduced
_disableInitializers
specifically for EIP-1167 proxied contracts:Ref. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/Initializable.sol#L136-L143
I unit tested and I cannot call initilizer on implementation after calling
_disableInitializer
, so I believe this detection is a false positive. Also I think the problem lies in this codeslither/slither/detectors/statements/unprotected_upgradeable.py
Lines 25 to 39 in d8e526e
I can fix if we confirm the issue.
Code example to reproduce the issue:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
interface IUniswapV2 {
function swapExactTokensForTokens(
uint256 amount,
address token0,
address token1,
address receiver
) external returns (uint256[] memory);
}
contract SlitherNotUnprotectedUpgrade is Initializable {
address private immutable _router;
}
Version:
0.8.3
Relevant log output:
No response
The text was updated successfully, but these errors were encountered: