Loading
[Security] GetReferenceMemo silently returns zero-value on not-found, enabling phantom state writes
Resolve #2602
This MR implements the changes described in issue #2602.
Summary
- Add
ReferenceMemoExistschecks infetchMemoFromReferenceandtrackReferenceMemoUsageto prevent phantom state writes when transactions reference non-existent reference IDs - Without these guards,
GetReferenceMemoreturns a zero-value record (Height=0, Memo="") for missing references, andtrackReferenceMemoUsagewrites this phantom record to state viaSetReferenceMemo, polluting the KV store - Add corresponding
ReferenceMemoExistsmethod to the mock keeper in tests
Test plan
-
All existing unit tests pass (
make test) -
Linter passes (
make lint) - Blockchain consensus safety review: no non-deterministic patterns, no float math, no map iteration, no goroutines in consensus code
-
The fix uses the existing deterministic
ReferenceMemoExistsKV store lookup -
Verified that
fetchMemoFromReferencereturns empty string for non-existent references (preventing further processing) -
Verified that
trackReferenceMemoUsageskips writing for non-existent references (preventing phantom state writes)