Fix: Semgrep grpc-server-insecure-connection #5890
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request addresses the Semgrep rule violation
grpc-server-insecure-connection, which identifies insecure gRPC server initialization without TLS credentials. Running a gRPC server without encryption exposes communication to interception, tampering, and man-in-the-middle attacks.Change Details
Modified File
cmd/kat-server/services/grpc-auth-v2.goUpdates
"google.golang.org/grpc/credentials"Replaced insecure gRPC server initialization:
grpc.NewServer()with a secure TLS-enabled server:Added error handling for TLS credential loading to ensure failures are surfaced properly.
Rationale
Semgrep flagged that the server was previously initialized without specifying TLS credentials, resulting in unencrypted network communication. Using grpc.Creds(credentials) ensures that all gRPC traffic is encrypted and authenticated using certificate-based TLS, significantly reducing the risk of message tampering or compromise.
Verification
Confirmed that TLS credentials (cert.pem, cert.key defined by g.Cert and g.Key) are now loaded correctly.
Semgrep rule warning is resolved.
The gRPC server now enforces encrypted connections.
The server continues to register the authorization service as expected.