Fix security vulnerabilities (jws, qs, express) and remove private key from image#89
Conversation
- Update express to ^4.22.0 to fix body-parser and qs vulnerabilities - Add npm override for jws ^3.2.3 to fix CVE-2025-65945 - Generate SSL certificates in memory at runtime instead of build time to avoid storing private keys in the Docker image - Make LOG_IGNORE_PATH also skip Morgan HTTP access logs, not just the JSON echo output - Update LOG_WITHOUT_NEWLINE test to expect 4 log lines (includes the certificate generation message)
df79271 to
c94de3c
Compare
|
Hi there, this is a debugging/troubleshooting utility so I don't consider the presence of a key to be a HIGH problem but I do get that Trivy is just doing what a scanner should do, it simply lacks the context and many organisations simply go off what the scanners say... However I am not at all comfortable maintaining that JS code that creates a certificate in memory. I can only think of two other approaches. Either a or, An entrypoint script that generates the certificate when the container is spun up. That way we can still rely on openssl to do the work, and that should hopefully not trip up scanners. Then the Dockerfile CMD needs to run that entrypoint.sh instead of "node index.js". |
No problem at all! 💯 I completely understand your concern about maintaining that JS certificate generation code. Regarding the two approaches you mentioned: .trivyignore: Unfortunately, this doesn't actually solve the image scan finding—it just tells Trivy to ignore it. The secret would still be flagged by other scanners and security tools. Entrypoint script: This would work, but introduces a new issue: the volume might not be writable (a common hardening practice in production environments). Workaround: Write to /dev/shm/ instead, but this still adds complexity. The PR now contains only the minimal changes needed: Rename privkey.pem → testpk.pem (fixes the Trivy secret detection) LMK. Thank you kindly. 💯 |
|
Thanks for that I had no idea about this test prefix of trivy. I'll push a tag in a bit. |
Summary
This PR fixes security vulnerabilities detected by trivy image scanning:
Changes
expressto^4.22.0and addedoverridesforjws: ^3.2.3Trivy scan BEFORE (mendhak/http-https-echo:latest)
Trivy scan AFTER (this PR)
Test plan
Notes
HTTPS_KEY_FILEandHTTPS_CERT_FILEenvironment variables for backward compatibility