Skip to content

Conversation

CertiK-Geth
Copy link
Contributor

Summary:

Replace incorrect expression 2^64-1 (bitwise XOR, evaluates to 65) with the intended uint64 maximum. This was a logic bug that passes the wrong limit into InsertReceiptChain during Era import.

Why:

In Go ^ is bitwise XOR, not exponentiation. 2^64-1 does not produce max uint64 and causes incorrect behavior during import. Not an immediate remote-exec security vulnerability, but a correctness bug that can cause data/consensus problems when importing history.

Fix:

Use idiomatic ^uint64(0) to represent max uint64 without adding imports.

Files changed:

  • cmd/utils/cmd.go

## Summary:

Replace incorrect expression 2^64-1 (bitwise XOR, evaluates to 65) with the intended uint64 maximum. This was a logic bug that passes the wrong limit into InsertReceiptChain during Era import.

## Why:

In Go ^ is bitwise XOR, not exponentiation. 2^64-1 does not produce max uint64 and causes incorrect behavior during import. Not an immediate remote-exec security vulnerability, but a correctness bug that can cause data/consensus problems when importing history.

## Fix:

Use idiomatic ^uint64(0) to represent max uint64 without adding imports.

## Files changed:
- cmd/utils/cmd.go
@CertiK-Geth
Copy link
Contributor Author

Fix 32935

cmd/utils/cmd.go Outdated
}
encReceipts := types.EncodeBlockReceiptLists([]types.Receipts{receipts})
if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, 2^64-1); err != nil {
if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, ^uint64(0)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use math.MaxUint64 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, use math.MaxUint64 to improve readability.

@rjl493456442 rjl493456442 changed the title fix: use maximum uint64 value for receipt chain insertion cmd/utils: use maximum uint64 value for receipt chain insertion Oct 18, 2025
@rjl493456442 rjl493456442 added this to the 1.16.6 milestone Oct 18, 2025
@rjl493456442 rjl493456442 merged commit 0ec6327 into ethereum:master Oct 18, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants