Skip to content

Commit 76a4166

Browse files
committed
CVE-2026-33186: Update code to apply mitigation to maintain uniformity with lower versions where fork can't be used
1 parent 3cd8085 commit 76a4166

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

pkg/csi/cinder/server.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import (
2525
"k8s.io/klog/v2"
2626

2727
"github.com/container-storage-interface/spec/lib/go/csi"
28+
29+
"google.golang.org/grpc/codes"
30+
"google.golang.org/grpc/status"
31+
"context"
2832
)
2933

3034
// NonBlockingGRPCServer defines Non blocking GRPC server interfaces
@@ -87,8 +91,16 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
8791
klog.Fatalf("Failed to listen: %v", err)
8892
}
8993

94+
// Mitigation for CVE-2026-33186 in grpc according to https://github.com/grpc/grpc-go/security/advisories/GHSA-p77j-4mvh-x3m3
95+
pathValidationInterceptor := func (ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
96+
if info.FullMethod == "" || info.FullMethod[0] != '/' {
97+
return nil, status.Errorf(codes.Unimplemented, "malformed method name")
98+
}
99+
return handler(ctx, req)
100+
}
101+
90102
opts := []grpc.ServerOption{
91-
grpc.UnaryInterceptor(logGRPC),
103+
grpc.ChainUnaryInterceptor(pathValidationInterceptor, logGRPC),
92104
}
93105
server := grpc.NewServer(opts...)
94106
s.server = server

pkg/csi/manila/driver.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import (
3333
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
3434
"k8s.io/cloud-provider-openstack/pkg/version"
3535
"k8s.io/klog/v2"
36+
37+
"google.golang.org/grpc/codes"
38+
"google.golang.org/grpc/status"
3639
)
3740

3841
type DriverOpts struct {
@@ -320,7 +323,15 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids *identityServer, cs *
320323
klog.Fatalf("listen failed for GRPC server: %v", err)
321324
}
322325

323-
server := grpc.NewServer(grpc.UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
326+
// Mitigation for CVE-2026-33186 in grpc according to https://github.com/grpc/grpc-go/security/advisories/GHSA-p77j-4mvh-x3m3
327+
pathValidationInterceptor := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
328+
if info.FullMethod == "" || info.FullMethod[0] != '/' {
329+
return nil, status.Errorf(codes.Unimplemented, "malformed method name")
330+
}
331+
return handler(ctx, req)
332+
}
333+
334+
server := grpc.NewServer(grpc.ChainUnaryInterceptor(pathValidationInterceptor, func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
324335
callID := atomic.AddUint64(&serverGRPCEndpointCallCounter, 1)
325336

326337
klog.V(3).Infof("[ID:%d] GRPC call: %s", callID, info.FullMethod)

pkg/kms/server/server.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import (
1313
"k8s.io/cloud-provider-openstack/pkg/kms/encryption/aescbc"
1414
"k8s.io/klog/v2"
1515
pb "k8s.io/kms/apis/v2"
16+
17+
"google.golang.org/grpc/codes"
18+
"google.golang.org/grpc/status"
1619
)
1720

1821
const (
@@ -72,7 +75,15 @@ func Run(configFilePath string, socketpath string, sigchan <-chan os.Signal) (er
7275
return err
7376
}
7477

75-
gServer := grpc.NewServer()
78+
// Mitigation for CVE-2026-33186 in grpc according to https://github.com/grpc/grpc-go/security/advisories/GHSA-p77j-4mvh-x3m3
79+
pathValidationInterceptor := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
80+
if info.FullMethod == "" || info.FullMethod[0] != '/' {
81+
return nil, status.Errorf(codes.Unimplemented, "malformed method name")
82+
}
83+
return handler(ctx, req)
84+
}
85+
86+
gServer := grpc.NewServer(grpc.UnaryInterceptor(pathValidationInterceptor))
7687
pb.RegisterKeyManagementServiceServer(gServer, s)
7788

7889
serverCh := make(chan error, 1)

0 commit comments

Comments
 (0)