:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(livestream): disable multipath tcp on listeners (CVE-2026-98432) (#126537)
James Greenhill11742b8e0149
diff --git a/livestream/go.mod b/livestream/go.modindex be871a59b253..236b74fd0798 100644--- a/livestream/go.mod+++ b/livestream/go.mod@@ -2,6 +2,10 @@ module github.com/posthog/posthog/livestreamgo 1.26.4+// CVE-2026-98432: the published RCE targets Multipath TCP listeners, which Go+// enables by default for Linux listen sockets since Go 1.24.+godebug multipathtcp=0+require (github.com/alicebob/miniredis/v2 v2.34.0github.com/charmbracelet/bubbles v1.0.0diff --git a/livestream/main.go b/livestream/main.goindex befe83065a1d..cef50a1f03dd 100644--- a/livestream/main.go+++ b/livestream/main.go@@ -5,6 +5,7 @@ import ("encoding/json""fmt""log"+ "net""net/http""os""os/signal"@@ -262,9 +263,16 @@ func main() {if port == "" {port = "8080"}+ addr := ":" + port++ listener, err := newListener(ctx, addr)+ if err != nil {+ e.Logger.Fatal(err)+ }+ e.Listener = listenergo func() {- if err := e.Start(":" + port); err != nil && err != http.ErrServerClosed {+ if err := e.Start(addr); err != nil && err != http.ErrServerClosed {e.Logger.Fatal(err)}}()@@ -283,6 +291,16 @@ func main() {log.Println("HTTP server stopped")}+// newListener returns a TCP listener with Multipath TCP off. Unlike the go.mod+// directive, this also wins over a GODEBUG, go.work or //go:debug override.+func newListener(ctx context.Context, addr string) (net.Listener, error) {+ var lc net.ListenConfig+ lc.SetMultipathTCP(false)+ // Echo set a 3 minute keep-alive on connections from its own listener.+ lc.KeepAlive = 3 * time.Minute+ return lc.Listen(ctx, "tcp", addr)+}+func createNotificationConsumer(consumerConfig configs.ConsumerConfig,statsRedis *events.StatsInRedis,diff --git a/livestream/main_linux_test.go b/livestream/main_linux_test.gonew file mode 100644index 000000000000..310a1a40c655--- /dev/null+++ b/livestream/main_linux_test.go@@ -0,0 +1,103 @@+package main++import (+ "net"+ "os"+ "strings"+ "syscall"+ "testing"++ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++// IPPROTO_MPTCP, which the syscall package does not define.+const ipProtoMPTCP = 262++func kernelSupportsMPTCP(t *testing.T) bool {+ t.Helper()++ enabled, err := os.ReadFile("/proc/sys/net/mptcp/enabled")+ if err != nil || strings.TrimSpace(string(enabled)) != "1" {+ return false+ }++ fd, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, ipProtoMPTCP)+ if err != nil {+ return false+ }+ require.NoError(t, syscall.Close(fd))++ return true+}++func listenerProtocol(t *testing.T, listener net.Listener) int {+ t.Helper()++ tcpListener, ok := listener.(*net.TCPListener)+ require.True(t, ok, "expected a *net.TCPListener, got %T", listener)++ rawConn, err := tcpListener.SyscallConn()+ require.NoError(t, err)++ var protocol int+ var sockErr error+ require.NoError(t, rawConn.Control(func(fd uintptr) {+ protocol, sockErr = syscall.GetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_PROTOCOL)+ }))+ require.NoError(t, sockErr)++ return protocol+}++// MPTCP on through GODEBUG, so this covers the per-socket opt-out, not the directive.+func TestNewListenerUsesTCPNotMPTCP(t *testing.T) {+ if !kernelSupportsMPTCP(t) {+ t.Skip("kernel does not support MPTCP, every listener is plain TCP")+ }++ t.Setenv("GODEBUG", "multipathtcp=1")+ require.True(t, new(net.ListenConfig).MultipathTCP(), "GODEBUG override did not take effect")++ listener, err := newListener(t.Context(), "127.0.0.1:0")+ require.NoError(t, err)+ t.Cleanup(func() { _ = listener.Close() })++ assert.Equal(t, syscall.IPPROTO_TCP, listenerProtocol(t, listener))+}++// Echo set a 3 minute keep-alive idle timeout; 15 seconds would drop quiet SSE streams.+func TestNewListenerKeepsThreeMinuteKeepAlive(t *testing.T) {+ listener, err := newListener(t.Context(), "127.0.0.1:0")+ require.NoError(t, err)+ t.Cleanup(func() { _ = listener.Close() })++ accepted := make(chan *net.TCPConn, 1)+ go func() {+ conn, err := listener.Accept()+ if err != nil {+ close(accepted)+ return+ }+ accepted <- conn.(*net.TCPConn)+ }()++ client, err := net.Dial("tcp", listener.Addr().String())+ require.NoError(t, err)+ t.Cleanup(func() { _ = client.Close() })++ server := <-accepted+ require.NotNil(t, server)+ t.Cleanup(func() { _ = server.Close() })++ rawConn, err := server.SyscallConn()+ require.NoError(t, err)++ var idle int+ require.NoError(t, rawConn.Control(func(fd uintptr) {+ idle, err = syscall.GetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE)+ }))+ require.NoError(t, err)++ assert.Equal(t, 180, idle)+}diff --git a/livestream/main_test.go b/livestream/main_test.goindex 12b97c9c72de..095be5573585 100644--- a/livestream/main_test.go+++ b/livestream/main_test.go@@ -2,14 +2,17 @@package mainimport (+ "net""net/http""net/http/httptest"+ "runtime/debug""testing""github.com/labstack/echo/v4""github.com/posthog/posthog/livestream/events""github.com/posthog/posthog/livestream/handlers""github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require")func TestIndex(t *testing.T) {@@ -51,3 +54,40 @@ func TestStatsHandler(t *testing.T) {assert.JSONEq(t, `{"users_on_product":1}`, rec.Body.String())}}++func TestMultipathTCPIsDisabledByDefault(t *testing.T) {+ buildInfo, ok := debug.ReadBuildInfo()+ require.True(t, ok, "build info unavailable")++ var defaults string+ for _, setting := range buildInfo.Settings {+ if setting.Key == "DefaultGODEBUG" {+ defaults += setting.Value+ }+ }+ require.Contains(t, defaults, "multipathtcp=0", "go.mod must keep godebug multipathtcp=0")++ var lc net.ListenConfig+ assert.False(t, lc.MultipathTCP())+}++func TestNewListenerAcceptsConnections(t *testing.T) {+ listener, err := newListener(t.Context(), "127.0.0.1:0")+ require.NoError(t, err)+ t.Cleanup(func() { _ = listener.Close() })++ accepted := make(chan error, 1)+ go func() {+ conn, err := listener.Accept()+ if err != nil {+ accepted <- err+ return+ }+ accepted <- conn.Close()+ }()++ conn, err := net.Dial("tcp", listener.Addr().String())+ require.NoError(t, err)+ require.NoError(t, conn.Close())+ require.NoError(t, <-accepted)+}