From 0c16e6d219c27302226eb23346755a7615e5e9a2 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Mon, 22 Apr 2024 20:26:52 +0530 Subject: [PATCH] core/vm: handle error if authorized is a contract address --- core/vm/eips.go | 6 ++++++ core/vm/errors.go | 1 + 2 files changed, 7 insertions(+) diff --git a/core/vm/eips.go b/core/vm/eips.go index 6f96e86da5..b544075bde 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -371,6 +371,12 @@ func opAuth(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt copy(commit[:], data[65:]) } + // Verify if the provided authority address isn't a contract + if code := interpreter.evm.StateDB.GetCode(authority); len(code) != 0 { + scope.Stack.push(uint256.NewInt(0)) + return nil, ErrAuthorizedIsContract + } + // Build original auth message. msg := []byte{params.AuthMagic} msg = append(msg, common.LeftPadBytes(interpreter.evm.chainConfig.ChainID.Bytes(), 32)...) diff --git a/core/vm/errors.go b/core/vm/errors.go index c1e6174b74..5ed286d5c3 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -37,6 +37,7 @@ var ( ErrGasUintOverflow = errors.New("gas uint64 overflow") ErrInvalidCode = errors.New("invalid code: must not begin with 0xef") ErrNonceUintOverflow = errors.New("nonce uint64 overflow") + ErrAuthorizedIsContract = errors.New("authcall with authorized as a contract address") ErrAuthorizedNotSet = errors.New("authcall without setting authorized") // errStopToken is an internal token indicating interpreter loop termination,