Skip to content

Commit

Permalink
core/vm: handle error if authorized is a contract address
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed Apr 22, 2024
1 parent 7077d0c commit 0c16e6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...)
Expand Down
1 change: 1 addition & 0 deletions core/vm/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0c16e6d

Please sign in to comment.