How to Ensure the Security of Your Container Images During Build?
Asked by
CuriousCoder123
I've been exploring our container supply chain and it's quite alarming. We pull base images from Docker Hub and npm packages from uncertain sources, plus our build process lacks visibility into what's actually included. Recently, during a security audit, they asked for signed Software Bill of Materials (SBOMs), and we had nothing to provide. We also had no provenance attestation in place. With some of our base images having over 500 Common Vulnerabilities and Exposures (CVEs) due to unnecessary bloated components, I'm curiousโwhat steps are others taking to ensure they're not just operating on 'trust but don't verify'? Are you signing everything? How can we effectively audit this at scale?
Answers
Have you considered the potential risks with your compiler and hardware as well? There are some really interesting angles on this in the paper "Reflections on Trusting Trust" where the author dives into the depths of trusting your build chain and tools.
Reply to this answer
Using a tool like Chainguard can be a lifesaver. If outsourcing is an option, definitely consider handing over the security mess to a vendor. Otherwise, leverage your CI tools to track artifacts and implement some SAST/DAST solutions for security checks.
SecureContractor11: Sounds like a smart move! We'll look into that vendor option.
ToolTamer44: I heard they might be launching a secure artifact store soon, which would be a game changer!
Reply to this answer
First off, make sure your management is seriously committed to tackling these issues and is willing to invest in fixing the chaos. If they are, then consider bringing in a DevSecOps expert to craft a manageable planโitโs usually a gradual process. On top of that, using common base images and multi-stage builds can streamline security. For Node apps, you could maintain a base node container and keep build dependencies minimal. Regularly review CVEs, and if youโre uncertain about an upstream source, prefer using versioning with git hashes. Automate updates to keep your images secure and up-to-date. That approach can help mitigate risk a lot!
DevOpsDude21: Thanks for the detailed breakdown! Super helpful.
SecureDev25: Great pointers! Also, getting familiar with using a consistent base image makes a big difference.
Reply to this answer
Starting with minimal setup for our containers really eased our spin-up times. We use just enough to get by without extra baggage. It's been working well so far.
Reply to this answer
In our case, we stick to distroless images as our base. After building, we scan everything with Trivy and deploy only if it passes our security gate.
Reply to this answer
We either grab base images from trusted sources like Oracle or AWS, or we build our own from scratch. We have a robust image pipeline where we apply configuration management tools, ensure vulnerability scans, and enforce strict version control for installed software. The final touch is signing our images and pushing them to an internal repository. This way, we can rebuild our images regularly and maintain a secure environment. I recommend starting with trusted images and then customizing them according to your specific security needs. Itโs not always easy, but with the right setup, you can greatly enhance your security posture.
CynicalCoder: Sounds like a solid process! Just be cautious; it can sometimes feel like a lot of workโlike youโre in a perpetual game of catch-up with vulnerabilities.
Reply to this answer
Honestly, we rely on tools like Semgrep and Trivy within our GitHub Actions to keep potentially harmful code in check. Itโs not a foolproof system, but it keeps most of my worries at bay. Plus, here are some rules we use for Semgrep in case youโre interested: it scans for known Docker patterns and other vulnerabilities to help bolster our security.
Reply to this answer
Add your answer
Answers are reviewed before publication.
DatabaseDynamo: That paper is fascinating! Definitely diving down that rabbit hole.
CyberSleuth33: Totally agree, it's a deeper issue than we're often led to believe.