Skip to content

Commit f7e5feb

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 f7e5feb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/server/grpc/server.go

Lines changed: 11 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"
@@ -38,6 +39,16 @@ func (s *Server) Start(ctx context.Context, t *tracee.Tracee, e *engine.Engine)
3839
}
3940
s.listener = lis
4041

42+
// Set restrictive permissions on Unix socket
43+
if s.protocol == "unix" {
44+
err = os.Chmod(s.listenAddr, 0600)
45+
if err != nil {
46+
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)
47+
lis.Close()
48+
return
49+
}
50+
}
51+
4152
srvCtx, srvCancel := context.WithCancel(ctx)
4253
defer srvCancel()
4354

0 commit comments

Comments
 (0)