diff --git a/onchain/ProvethVerifier.sol b/onchain/ProvethVerifier.sol index 5af77db..e75ee18 100644 --- a/onchain/ProvethVerifier.sol +++ b/onchain/ProvethVerifier.sol @@ -406,6 +406,12 @@ contract ProvethVerifier { } else { nodeHashHash = keccak256(node[nibble].toRlpBytes()); } + + // Sanity + if (i == stack.length - 1) { + // need to process the child now + revert(); + } } else { // we have consumed the entire mptKey, so we need to look at what's contained in this node. @@ -419,5 +425,8 @@ contract ProvethVerifier { } } } + + // If execution reaches here, the proof was inconclusive or malformed + revert("Invalid MPT proof"); } }