{"id":"XE-0627","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":242,"title":"[Core/Ledger] addBlock shallow copy mutates caller's Signatures slice — core/ledger.go:740-744","area":"leasing-ledger","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-05T07:20:04.984648+00:00","updated_at":"2026-11-08T20:47:34.883080+00:00","source_created_at":null,"told_at":"2026-11-08T20:47:34.887809+00:00","status_changed_at":"2026-11-08T20:47:28.344246+00:00","url":"https://bounty.xe.network/XE-0627","body":"## Summary\n`addBlock()` at `core/ledger.go:740` creates a shallow copy via `bc := *b`, then calls `normalizeBlockHex(&bc)` which lowercases `Signatures[i].PublicKey` and `Signatures[i].Sig` in-place. Because `bc.Signatures` shares the backing array with `b.Signatures`, the caller's block object has its Signature fields silently mutated.\n\n## Affected Code\n`core/ledger.go:740-745`:\n```go\nbc := *b                                          // shallow copy\nbc.Attestations = make([]BlockAttestation, ...)    // deep copy\ncopy(bc.Attestations, b.Attestations)\n// NOTE: Signatures is NOT deep-copied here\nreturn n.normalizeBlockHex(&bc)                    // mutates shared backing array\n```\n\n`normalizeBlockHex` lowercases every `Signatures[i].PublicKey` and `Signatures[i].Sig`. Since `bc.Signatures` and `b.Signatures` point to the same underlying array, the original block is modified as a side effect.\n\n## Impact\nAny caller that re-uses the block object after `addBlock` returns gets lowercased signature fields. This is a correctness bug — signature hex casing should not be the caller's concern and side-effecting their data is unexpected.\n\n## Severity\nLow — correctness issue, not directly exploitable, but violates caller expectations and could cause subtle bugs.\n\n## Fix\nDeep-copy the Signatures slice, following the same pattern as Attestations at line 742:\n```go\nbc.Signatures = make([]BlockSignature, len(b.Signatures))\ncopy(bc.Signatures, b.Signatures)\n```","patch_refs":[],"thread":[{"id":1237,"source":"desk","source_ref":"reply:778","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read the code you point at and agree the copy is shallower than it looks; we could not find a behavioural consequence beyond the casing of the caller's fields, and are treating it as a small hardening item. https://bounty.xe.network/XE-0627 will be updated when it is addressed.","created_at":"2026-11-08T20:47:34.883080+00:00"}]}