mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #168] [MERGED] fix: remove CA private key after certificate signing in entrypoint #208
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/168
Author: @mason5052
Created: 3/2/2026
Status: ✅ Merged
Merged: 3/2/2026
Merged by: @asdek
Base:
feature/next_release← Head:fix/entrypoint-ca-key-cleanup📝 Commits (1)
5563001fix: remove CA private key after certificate signing in entrypoint📊 Changes
1 file changed (+5 additions, -1 deletions)
View changed files
📝
scripts/entrypoint.sh(+5 -1)📄 Description
Description of the Change
Problem
The entrypoint script (
scripts/entrypoint.sh) generates a self-signed CA to issue the server certificate at startup. After signing, the CA private key (ssl/service_ca.key), CSR (ssl/service.csr), and serial file (ssl/service_ca.srl) remain on disk inside the container.These files are never used again at runtime -- the server only needs
server.keyandserver.crt(which already includes the CA cert appended). Leaving the CA private key on disk increases the attack surface: if the container filesystem is compromised (e.g., via a path traversal or container escape), an attacker could use the CA key to issue arbitrary certificates trusted by the server's certificate chain.The script also runs
chmod g+ron the CA key, which widens read access to a file that should not exist at all after signing.Solution
Replace
chmod g+r ${SERVER_SSL_CA_KEY}withrm -fto delete the CA private key, CSR, and serial file immediately after the server certificate is signed.Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
openssl x509 -reqsigning stepserver.crt(cat ${SERVER_SSL_CA_CRT} >> ${SERVER_SSL_CRT})service_ca.keyafter entrypointservice.csrandservice_ca.srlare also not used after signingTest Results
server.key,server.crt, andservice_ca.crt(public cert, needed in the chain) remainSecurity Considerations
This fix reduces attack surface by removing cryptographic key material that is no longer needed:
Performance Impact
None.
rm -fof 3 small files at startup is negligible.Deployment Notes
Backward-compatible. Existing containers will clean up the CA key on next restart when
SERVER_USE_SSL=trueand certificates are regenerated. If certificates already exist (theifbranch), no change in behavior.Checklist
Code Quality
Security
Compatibility
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.