Skip to content
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

Avoids leaking execution.rpc.classic-redirect URL #2908

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go-ethereum
43 changes: 43 additions & 0 deletions system_tests/classic_redirect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2021-2025, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE

package arbtest

import (
"context"
"testing"
"time"

"github.com/ethereum/go-ethereum/rpc"

"github.com/offchainlabs/nitro/util/testhelpers"
)

func TestClassicRedirectURLNotLeaked(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// nitro will expect that listener provides an RPC server.
// However we don't need to provide a real RPC server here, so calls to it will fail
listener, err := testhelpers.FreeTCPPortListener()
Require(t, err)
defer listener.Close()

builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.execConfig.RPC.ClassicRedirect = "http://" + listener.Addr().String()
builder.execConfig.RPC.ClassicRedirectTimeout = time.Second
cleanup := builder.Build(t)
defer cleanup()

l2rpc := builder.L2.Stack.Attach()

var result traceResult
err = l2rpc.CallContext(ctx, &result, "arbtrace_call", callTxArgs{}, []string{"trace"}, rpc.BlockNumberOrHash{})
// checks that it errors and that the error message does not contains the classic redirect URL
expectedErrMsg := "Failed to call fallback API"
if err == nil || err.Error() != expectedErrMsg {
t.Fatalf("Expected error message to be %s, got %v", expectedErrMsg, err)
}
}
Loading