openshift / openshift/router

Harden permissions for router PEM files containing private keys

Open
#827 2 comments 0 reactions 1 assignee View on GitHub

@bentito is already working on this.

Since Jul 27, 2026.

Dominant language
Go
Stars
86
Forks
146
Avg merge
5d 14h
Merged PRs (30d)
1

Description

Summary

Harden the permissions used for router PEM files that include TLS private-key material.

simpleCertificateWriter.WriteCertificate currently sets the temporary PEM file mode to 0644 before atomically renaming it into the HAProxy certificate directory. The combined PEM written by WriteCertificatesForConfig includes certObj.PrivateKey, so it should not be world-readable.

Required change

Update pkg/router/template/certmanager.go so simpleCertificateWriter.WriteCertificate uses restrictive permissions (0600) for PEM files containing private keys. Preserve the existing temporary-file cleanup, error logging, and atomic rename behavior.

Rationale

This is existing behavior rather than a regression introduced by PR #825, so it is being tracked separately. Restricting permissions reduces unnecessary exposure of TLS private-key material within the router container.

Affected area

  • pkg/router/template/certmanager.go
  • simpleCertificateWriter.WriteCertificate

Acceptance criteria

  • PEM files written by WriteCertificate have mode 0600.
  • The write remains atomic: write to a temporary file, close it, then rename it into place.
  • Error cleanup and logging behavior remains intact.
  • Relevant certificate writer tests are updated or added to verify the expected file mode.

Backlinks

Requested by: @bentito

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.