Skip to content

Commit 2ab6a82

Browse files
committed
fix: set restrictive permissions (0600) on gRPC Unix socket
The Unix socket created at /var/run/tracee.sock was using default umask permissions, potentially allowing unauthorized local users to connect. Now explicitly sets 0600 permissions after socket creation to restrict access to owner only.
1 parent fd637fc commit 2ab6a82

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/server/grpc/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package grpc
33
import (
44
"context"
55
"net"
6+
"os"
67
"time"
78

89
"google.golang.org/grpc"
@@ -36,6 +37,17 @@ func (s *Server) Start(ctx context.Context, t *tracee.Tracee, e *engine.Engine)
3637
logger.Errorw("Failed to start GRPC server", "protocol", s.protocol, "address", s.listenAddr, "error", err)
3738
return
3839
}
40+
41+
// Set restrictive permissions on Unix socket
42+
if s.protocol == "unix" {
43+
err = os.Chmod(s.listenAddr, 0600)
44+
if err != nil {
45+
logger.Errorw("Failed to set permissions on Unix socket. This may leave the socket with insecure permissions and allow unauthorized access.", "path", s.listenAddr, "error", err)
46+
_ = lis.Close()
47+
return
48+
}
49+
}
50+
3951
s.listener = lis
4052

4153
srvCtx, srvCancel := context.WithCancel(ctx)

0 commit comments

Comments
 (0)