[Node/P2P] CertificateHash[:12] slice without bounds check panics node on crafted lease_accept — core/ledger.go:1692
Report
Summary
core/ledger.go line 1692 slices CertificateHash[:12] without verifying the field has at least 12 bytes. A peer that sends a lease_accept message with a truncated CertificateHash (≤11 bytes) causes the receiving node to panic with an index-out-of-range, terminating the process.
Affected Code
core/ledger.go:1692 — inside the lease accept/settle handler:
hash := cert.CertificateHash[:12]
No length check precedes this slice. The CertificateHash field is a raw []byte from the wire, and a malicious or buggy peer can send any length.
Reproduction
- Run a local XE node (genesis or testnet join).
- Craft a
lease_acceptmessage withCertificateHashset to a short byte slice (e.g., 4 bytes instead of the expected 32-byte hash). - Send it to the node's P2P port.
- The node panics and terminates.
Impact
Network-triggerable denial of service: any peer on the network can crash a node. In a network with open peering (testnet), this is trivially exploitable.
Severity
Medium — node crash, network-reachable, no privilege required, no data loss beyond the process termination.
Fix
Add a length check before the slice:
if len(cert.CertificateHash) < 12 {
return fmt.Errorf("certificate hash too short: %d bytes", len(cert.CertificateHash))
}
hash := cert.CertificateHash[:12]
Thread
Thanks for the report. We have read the code path you point at. The slice is unguarded, but the checks before it pin the value to a certificate hash that has already been verified on the way in, so we could not find a way for a peer to reach it with a short value. We are treating it as a small hardening item rather than a crash; https://bounty.xe.network/XE-0623 will be updated when it is addressed.