<!-- XE-0627 · [Core/Ledger] addBlock shallow copy mutates caller's Signatures slice — core/ledger.go:740-744 · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0627>. The page is the record; this is the same page for reading.*

XE-0627 · Bounty

# \[Core/Ledger\] addBlock shallow copy mutates caller's Signatures slice — core/ledger.go:740-744

Triaging
web
filed 2026-11-05 07:20 UTC
by Ashev Ardiansyah

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   —

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-08 20:47 UTC

Told
:   2026-11-08 20:47 UTC

### Patches

None linked.

### History

- [45468](https://bounty.xe.network/log/45468) 2026-11-08 20:47 UTC reply.sent
- [45467](https://bounty.xe.network/log/45467) 2026-11-08 20:47 UTC proposal.adopted
- [45465](https://bounty.xe.network/log/45465) 2026-11-08 20:47 UTC proposal.adopted
- [45464](https://bounty.xe.network/log/45464) 2026-11-08 20:47 UTC ticket.status new → triaging
- [45463](https://bounty.xe.network/log/45463) 2026-11-08 20:47 UTC proposal.adopted
- [45462](https://bounty.xe.network/log/45462) 2026-11-08 20:47 UTC ticket.award
- [45461](https://bounty.xe.network/log/45461) 2026-11-08 20:47 UTC proposal.adopted
- [45460](https://bounty.xe.network/log/45460) 2026-11-08 20:47 UTC ticket.facts
- [45459](https://bounty.xe.network/log/45459) 2026-11-08 20:47 UTC proposal.adopted
- [45458](https://bounty.xe.network/log/45458) 2026-11-08 20:47 UTC ticket.facts
- [45457](https://bounty.xe.network/log/45457) 2026-11-08 20:47 UTC proposal.adopted
- [45456](https://bounty.xe.network/log/45456) 2026-11-08 20:47 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-0627) · [JSON](https://bounty.xe.network/v1/tickets/XE-0627) · [markdown](https://bounty.xe.network/XE-0627.md)

### Report

## Summary

`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.

## Affected Code

`core/ledger.go:740-745`:

```
bc := *b                                          // shallow copy
bc.Attestations = make([]BlockAttestation, ...)    // deep copy
copy(bc.Attestations, b.Attestations)
// NOTE: Signatures is NOT deep-copied here
return n.normalizeBlockHex(&bc)                    // mutates shared backing array
```

`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.

## Impact

Any 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.

## Severity

Low — correctness issue, not directly exploitable, but violates caller expectations and could cause subtle bugs.

## Fix

Deep-copy the Signatures slice, following the same pattern as Attestations at line 742:

```
bc.Signatures = make([]BlockSignature, len(b.Signatures))
copy(bc.Signatures, b.Signatures)
```

### Thread

**Joseph Denne**team2026-11-08 20:47 UTCdesk

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.
