Skip to content

Commit c59b376

Browse files
committed
host: Reject DELEGATECALL crossing EOF<>legacy boundary
1 parent 31fd534 commit c59b376

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/state/host.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ evmc::Result Host::execute_message(const evmc_message& msg) noexcept
266266

267267
// Copy of the code. Revert will invalidate the account.
268268
const auto code = dst_acc != nullptr ? dst_acc->code : bytes{};
269+
270+
if (msg.kind == EVMC_DELEGATECALL)
271+
{
272+
// TODO: does the sender always have code here? or is this function used for EOAs too?
273+
const auto& sender = m_state.get(msg.sender);
274+
275+
// DELEGATECALL initiator and destination both must be either legacy or EOF
276+
if (is_eof_container(code) != is_eof_container(sender.code))
277+
return evmc::Result{EVMC_FAILURE};
278+
}
279+
269280
return m_vm.execute(*this, m_rev, msg, code.data(), code.size());
270281
}
271282

0 commit comments

Comments
 (0)