Rails Gitaly client: present a client certificate in GRPC::Core::ChannelCredentials for tls:// storages
Finding
GitLab Rails (Puma and Sidekiq) dials tls:// Gitaly storages with root certificates only. Gitlab::GitalyClient builds GRPC::Core::ChannelCredentials from the CA bundle; the second and third constructor arguments (client private key and client certificate chain) are never supplied. Rails is the highest-volume Gitaly client and the one that carries user-attributed operations, so it must present an identity for I-1 require mode to be deployable.
Standards
- NIST SP 800-53 Rev. 5 IA-3(1) Cryptographic Bidirectional Authentication, IA-9 Service Identification and Authentication.
- NIST SP 800-172 3.5.1e (CMMC Level 3, IA.L3-3.5.1e).
- NSA CSI Application and Workload Pillar (May 2024): application identities authenticate to necessary services under least privilege.
- DoD Zero Trust Capability Execution Roadmap v1.1: 2.3 Enterprise PKI, 3.4 Resource Authorization and Integration.
Proposal
Add gitaly.client_cert_path and gitaly.client_key_path (and optionally gitaly.ca_cert_path) to gitlab.yml, with environment-variable fallbacks GITALY_CLIENT_CERT_PATH, GITALY_CLIENT_KEY_PATH, and GITALY_CA_CERT_PATH for parity with I-2. Where channel credentials are built for tls:// addresses:
# Gitlab::GitalyClient, credentials for tls:// storages
root_ca = ::Gitlab::X509::Certificate.ca_certs_bundle # existing behavior
client_key = File.read(client_key_path) if client_key_path.present?
client_cert = File.read(client_cert_path) if client_cert_path.present?
GRPC::Core::ChannelCredentials.new(root_ca, client_key, client_cert)The C-core gRPC gem supports mutual TLS natively through these arguments; no new dependency is required. Rails also hands Gitaly connection details to Workhorse and GitLab Shell through internal API responses; those components should use their own configured key pairs (I-2) rather than expecting Rails to transmit credentials.
Acceptance criteria
- Rails and Sidekiq complete Gitaly RPCs against a Gitaly running I-1 in
requiremode when the key pair is configured. - A missing or unreadable key pair with a
require-mode Gitaly produces a clear error at boot or first RPC, with no silent plaintext fallback. -
gitlab:gitaly:checkreports whether a client certificate was presented and verified. - Key pair rotation is documented (channel re-creation or process reload).
Related issues
- Depends on:
- Blocks:
- Tracked by:
Context
Impacts programs operating self-hosted GitLab at DoD Impact Levels 5 and 6 and under CMMC Level 3.