Skip to content

fix(security): 2 improvements across 2 files#2616

Open
tomaioo wants to merge 2 commits intoe2b-dev:mainfrom
tomaioo:fix/security/insecure-grpc-transport-credentials-in-n
Open

fix(security): 2 improvements across 2 files#2616
tomaioo wants to merge 2 commits intoe2b-dev:mainfrom
tomaioo:fix/security/insecure-grpc-transport-credentials-in-n

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented May 10, 2026

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: High | File: packages/api/internal/orchestrator/nodemanager/client.go:L41

The nodemanager client uses insecure.NewCredentials() for gRPC connections, which disables TLS encryption. This could allow man-in-the-middle attacks and expose sensitive sandbox metadata in transit. While this might be acceptable for internal cluster communication, it should be reviewed against security requirements.

Solution

If this is for internal cluster communication within a trusted network, document this decision. Otherwise, implement TLS with proper certificate validation. Consider using the same TLS configuration as in instance_client.go which uses TLS 1.2+ with proper certificate handling.

Changes

  • packages/api/internal/orchestrator/nodemanager/client.go (modified)
  • packages/api/internal/clusters/instance_client.go (modified)

tomaioo added 2 commits May 10, 2026 05:18
- Security: Insecure gRPC Transport Credentials in Node Manager Client
- Security: Insecure gRPC Transport Credentials in Instance Client (Conditional)

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Insecure gRPC Transport Credentials in Node Manager Client
- Security: Insecure gRPC Transport Credentials in Instance Client (Conditional)

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 10, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @tomaioo on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53972aa35a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +54 to 56
if !endpointTLS {
return nil, fmt.Errorf("TLS is required for instance client connections")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve non-TLS path for local cluster gRPC

This change makes createClient fail whenever endpointTLS is false, but local-cluster instance creation intentionally passes false (newLocalCluster calls newInstance(..., false) in packages/api/internal/clusters/cluster.go), so every local instance now fails at client construction instead of connecting over the direct node IP as before. In environments using the local cluster path, this prevents instance registration/sync and breaks routing to local orchestrators.

Useful? React with 👍 / 👎.

func NewClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, host string) (*clusters.GRPCClient, error) {
conn, err := grpc.NewClient(host,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0 Badge Keep nodemanager client transport consistent with server

Switching this dial option to TLS breaks node-manager connectivity because discovered orchestrator targets are raw IP:port addresses and the orchestrator gRPC server is started without TLS credentials (grpc.NewServer via packages/shared/pkg/grpc/server.go), so this client now attempts a TLS handshake against a plaintext listener and cannot connect to nodes. That makes nodemanager.New fail to initialize node clients in normal local-orchestrator discovery flows.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The insecure import in packages/api/internal/clusters/instance_client.go is now unused and will cause a compilation error. Enforcing TLS by returning an error when endpointTLS is false is a breaking change that may cause failures in environments relying on insecure connections. The gRPC client in packages/api/internal/orchestrator/nodemanager/client.go is missing the WithAuthority option, which can lead to connection failures if the host does not match the certificate's server name.

"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/credentials"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The removal of the insecure import in this file is correct, but the same import remains in packages/api/internal/clusters/instance_client.go where it is now unused. Because Go does not allow unused imports, this will cause a compilation error and break the build.

Comment on lines +54 to 56
if !endpointTLS {
return nil, fmt.Errorf("TLS is required for instance client connections")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Enforcing TLS by returning an error when endpointTLS is false is a breaking change that will cause failures in any environment or caller currently relying on insecure connections. If this enforcement is intentional, ensure that all callers and development environments have been updated to support TLS.

func NewClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, host string) (*clusters.GRPCClient, error) {
conn, err := grpc.NewClient(host,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The TLS configuration is missing the WithAuthority option used in the instance_client.go reference. This inconsistency can lead to connection failures if the host string is an IP address or does not match the certificate's expected server name.

		grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})),
		grpc.WithAuthority(host),

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.

2 participants