From 1a54d0d325e78288eeaf5c2978ec25dc00c6974e Mon Sep 17 00:00:00 2001 From: webthethird Date: Fri, 17 Mar 2023 10:01:54 -0500 Subject: [PATCH] Handle hardcoded slot sloaded in delegatecall in `extract_delegate_from_asm` --- slither/utils/upgradeability.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slither/utils/upgradeability.py b/slither/utils/upgradeability.py index cefc0868c..20759cb18 100644 --- a/slither/utils/upgradeability.py +++ b/slither/utils/upgradeability.py @@ -428,10 +428,17 @@ def extract_delegate_from_asm(contract: Contract, node: Node) -> Optional[Variab asm = next(line for line in asm_split if "delegatecall" in line) params = asm.split("call(")[1].split(", ") dest = params[1] - if dest.endswith(")"): + if dest.endswith(")") and not dest.startswith("sload("): dest = params[2] if dest.startswith("sload("): dest = dest.replace(")", "(").split("(")[1] + if len(dest) == 66 and dest.startswith("0x"): + v = StateVariable() + v.is_constant = True + v.expression = Literal(dest, ElementaryType("bytes32")) + v.name = dest + v.type = ElementaryType("bytes32") + return v for v in node.function.variables_read_or_written: if v.name == dest: if isinstance(v, LocalVariable) and v.expression is not None: