The vulnerability lies in how Zebra, a Zcash implementation, handles SIGHASH_SINGLE for V5 transparent transactions. The Zcash consensus rules, as implemented in the reference client zcashd, require that a transaction input using SIGHASH_SINGLE must have a corresponding output at the same index. If not, the transaction is invalid. Zebra's implementation failed to enforce this rule.
Specifically, the function zebra_script::CachedFfiTransaction::is_valid would proceed to calculate a signature hash even when there were fewer outputs than inputs. An attacker could craft a transaction with, for example, two inputs and one output, and sign the second input with SIGHASH_SINGLE. Zebra would calculate a digest for this invalid scenario and, if the attacker provided a matching signature, would accept the transaction as valid. This transaction would be accepted into Zebra's mempool and could be included in a block template.
If a miner were to mine a block containing such a transaction, it would be accepted by Zebra nodes but rejected by zcashd nodes, leading to a consensus split or a fork in the Zcash network. This poses a significant risk to the integrity of the blockchain.
The patch addresses this by adding a crucial validation step in zebra_script::CachedFfiTransaction::is_valid. It now checks that the number of transaction inputs equals the number of previous outputs before attempting script verification. If the counts do not match, the function immediately returns an error, aligning Zebra's behavior with the zcashd reference implementation and closing the consensus vulnerability.