-
Notifications
You must be signed in to change notification settings - Fork 16
Sync geth: security fix #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SegueII
wants to merge
11
commits into
main
Choose a base branch
from
sync-gap-v1.16.3-v1.16.7-p0-p1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
66044d0
graphql: limit query depth
SegueII 82f9362
rpc: cap websocket message reads
SegueII ababf62
filters: bound log query width
SegueII 3d86dc5
ethapi: validate proof hash inputs early
SegueII 269f573
eth/protocols: reject duplicate tx messages
SegueII cb8f34c
state: skip code hooks for unchanged code
SegueII d9e7b6d
vm: skip code install for empty creates
SegueII 0147b8d
fetcher: clear dropped peer alternates
SegueII f006de0
filters: unsubscribe polling filters on errors
SegueII a3515ba
rpc: isolate websocket large-read test helper
SegueII 33add58
graphql: enhance max query depth test with introspection query
SegueII File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package state | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/morph-l2/go-ethereum/common" | ||
| "github.com/morph-l2/go-ethereum/core/rawdb" | ||
| "github.com/morph-l2/go-ethereum/core/tracing" | ||
| ) | ||
|
|
||
| func TestSetCodeNoChangeDoesNotHook(t *testing.T) { | ||
| statedb, err := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()), nil) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| addr := common.HexToAddress("0x1111111111111111111111111111111111111111") | ||
| var calls int | ||
| hooked := NewHookedState(statedb, &tracing.Hooks{ | ||
| OnCodeChange: func(common.Address, common.Hash, []byte, common.Hash, []byte) { | ||
| calls++ | ||
| }, | ||
| }) | ||
|
|
||
| code := []byte{1, 2, 3} | ||
| hooked.SetCode(addr, code) | ||
| if calls != 1 { | ||
| t.Fatalf("first SetCode should hook once, got %d", calls) | ||
| } | ||
| hooked.SetCode(addr, append([]byte(nil), code...)) | ||
| if calls != 1 { | ||
| t.Fatalf("unchanged SetCode should not hook, got %d", calls) | ||
| } | ||
| hooked.SetCode(addr, nil) | ||
| if calls != 2 { | ||
| t.Fatalf("clearing code should hook once, got %d", calls) | ||
| } | ||
| hooked.SetCode(addr, nil) | ||
| if calls != 2 { | ||
| t.Fatalf("repeated empty SetCode should not hook, got %d", calls) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package vm | ||
|
|
||
| import ( | ||
| "math/big" | ||
| "testing" | ||
|
|
||
| "github.com/morph-l2/go-ethereum/common" | ||
| "github.com/morph-l2/go-ethereum/core/rawdb" | ||
| statedb "github.com/morph-l2/go-ethereum/core/state" | ||
| "github.com/morph-l2/go-ethereum/params" | ||
| ) | ||
|
|
||
| type setCodeCountingStateDB struct { | ||
| StateDB | ||
| setCodeCalls int | ||
| } | ||
|
|
||
| func (db *setCodeCountingStateDB) SetCode(addr common.Address, code []byte) []byte { | ||
| db.setCodeCalls++ | ||
| return db.StateDB.SetCode(addr, code) | ||
| } | ||
|
|
||
| func newCreateTestEVM(t *testing.T) (*EVM, *setCodeCountingStateDB, common.Address) { | ||
| t.Helper() | ||
|
|
||
| base, err := statedb.New(common.Hash{}, statedb.NewDatabase(rawdb.NewMemoryDatabase()), nil) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| caller := common.HexToAddress("0x1111111111111111111111111111111111111111") | ||
| base.CreateAccount(caller) | ||
|
|
||
| wrapped := &setCodeCountingStateDB{StateDB: base} | ||
| blockCtx := BlockContext{ | ||
| CanTransfer: func(StateDB, common.Address, *big.Int) bool { return true }, | ||
| Transfer: func(StateDB, common.Address, common.Address, *big.Int) {}, | ||
| GetHash: func(uint64) common.Hash { return common.Hash{} }, | ||
| BlockNumber: big.NewInt(0), | ||
| Time: big.NewInt(0), | ||
| GasLimit: 10_000_000, | ||
| BaseFee: big.NewInt(params.InitialBaseFee), | ||
| } | ||
| txCtx := TxContext{ | ||
| Origin: caller, | ||
| GasPrice: big.NewInt(params.InitialBaseFee), | ||
| } | ||
| return NewEVM(blockCtx, txCtx, wrapped, params.TestChainConfig, Config{}), wrapped, caller | ||
| } | ||
|
|
||
| func TestCreateEmptyReturnSkipsSetCode(t *testing.T) { | ||
| evm, statedb, caller := newCreateTestEVM(t) | ||
|
|
||
| ret, _, _, err := evm.Create(AccountRef(caller), nil, 1_000_000, new(big.Int)) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if len(ret) != 0 { | ||
| t.Fatalf("expected empty create return, got %x", ret) | ||
| } | ||
| if statedb.setCodeCalls != 0 { | ||
| t.Fatalf("empty create called SetCode %d times", statedb.setCodeCalls) | ||
| } | ||
| } | ||
|
|
||
| func TestCreateNonEmptyReturnSetsCode(t *testing.T) { | ||
| evm, statedb, caller := newCreateTestEVM(t) | ||
|
|
||
| code := []byte{ | ||
| byte(PUSH1), 0x2a, | ||
| byte(PUSH1), 0x00, | ||
| byte(MSTORE), | ||
| byte(PUSH1), 0x20, | ||
| byte(PUSH1), 0x00, | ||
| byte(RETURN), | ||
| } | ||
| ret, _, _, err := evm.Create(AccountRef(caller), code, 1_000_000, new(big.Int)) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if len(ret) != 32 { | ||
| t.Fatalf("expected non-empty create return, got %x", ret) | ||
| } | ||
| if statedb.setCodeCalls != 1 { | ||
| t.Fatalf("non-empty create called SetCode %d times", statedb.setCodeCalls) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject negative
rpc.logquerylimitvalues during config sanitization.At Line 1715, negative values can flow from CLI/config into
cfg.LogQueryLimit; later checks treat any negative as “everything exceeds limit”, effectively breaking all log queries.Proposed fix
if ctx.IsSet(RPCGlobalLogQueryLimit.Name) { cfg.LogQueryLimit = ctx.Int(RPCGlobalLogQueryLimit.Name) } + if cfg.LogQueryLimit < 0 { + Fatalf("--%s must be >= 0", RPCGlobalLogQueryLimit.Name) + }📝 Committable suggestion
🤖 Prompt for AI Agents