From 55dd2d5e69cb76805c1b91f526fd7ff9ad6ea8f2 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 15 Feb 2024 22:51:50 +0100 Subject: [PATCH] prevent sstore under accounts with no code --- core/vm/instructions.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 023aa0af00..ee0bce7c74 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -518,7 +518,8 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by } func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - if interpreter.readOnly { + // if scope is an account with no code (EOA delegation through EIP-5806) sstore is protected + if interpreter.readOnly || scope.Contract.CodeHash == (common.Hash{}) { return nil, ErrWriteProtection } loc := scope.Stack.pop()