Skip to content

fix: prevent nil pointer panic in vsock proxy connection pool#106

Open
danilaverbena wants to merge 1 commit into
base:mainfrom
danilaverbena:fix/vsock-nil-panic
Open

fix: prevent nil pointer panic in vsock proxy connection pool#106
danilaverbena wants to merge 1 commit into
base:mainfrom
danilaverbena:fix/vsock-nil-panic

Conversation

@danilaverbena

Copy link
Copy Markdown

Description

The HTTP proxy in cmd/server/main.go can panic when vsock.Dial fails inside sync.Pool.New. When New returns nil, the single-value type assertion pool.Get().(*vsock.Conn) panics with *interface conversion: interface is nil, not vsock.Conn.

Fix

Use the two-value form of the type assertion: conn, ok := pool.Get().(*vsock.Conn). Also check conn == nil in case a nil *vsock.Conn was previously returned to the pool.

Impact

Without this fix, if the vsock service is unavailable, any HTTP request to the proxy server will cause a panic and crash the entire server process. With this fix, the proxy returns HTTP 500 instead.

Related

This was found during a security audit of op-enclave.

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.

1 participant