Skip to content

Commit 000c8c0

Browse files
authored
Merge pull request #855 from crytic/dev-isprotected
Relax is_protected heuristic
2 parents ab70871 + ea0261c commit 000c8c0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

slither/core/declarations/function.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,11 @@ def is_protected(self) -> bool:
14051405
"""
14061406
Determine if the function is protected using a check on msg.sender
14071407
1408-
Only detects if msg.sender is directly used in a condition
1408+
Consider onlyOwner as a safe modifier.
1409+
If the owner functionality is incorrectly implemented, this will lead to incorrectly
1410+
classify the function as protected
1411+
1412+
Otherwise only detects if msg.sender is directly used in a condition
14091413
For example, it wont work for:
14101414
address a = msg.sender
14111415
require(a == owner)
@@ -1417,6 +1421,9 @@ def is_protected(self) -> bool:
14171421
if self.is_constructor:
14181422
self._is_protected = True
14191423
return True
1424+
if "onlyOwner" in [m.name for m in self.modifiers]:
1425+
self._is_protected = True
1426+
return True
14201427
conditional_vars = self.all_conditional_solidity_variables_read(include_loop=False)
14211428
args_vars = self.all_solidity_variables_used_as_args()
14221429
self._is_protected = (

0 commit comments

Comments
 (0)