Securing CI/CD for Open Source: Credentials and Verification in Kubernetes
In open source projects, securing your CI/CD pipeline is critical to prevent unauthorized access and ensure the integrity of your software. With the rise of supply chain attacks, implementing robust security measures is no longer optional. This article focuses on how to manage credentials and verification processes effectively within a Kubernetes environment, emphasizing the importance of using GITHUB_TOKENs and signing container images.
The mechanism begins with the use of GITHUB_TOKENs, which by default are scoped to minimal read permissions on contents and packages. This limits exposure and reduces the risk of credential leakage. Additionally, you can manage two distinct sets of registry credentials behind separate GitHub protected environments. CI credentials can push to your development image registry, while production credentials require explicit maintainer approval before use. This layered approach ensures that sensitive operations are tightly controlled. Moreover, every actions/checkout call sets persist-credentials: false, preventing the GITHUB_TOKEN from being stored in the runner’s git config, which could lead to accidental leaks.
In production, integrating tools like Sigstore Cosign is essential. Every container image released is signed using keyless OIDC, providing an extra layer of verification. Additionally, a Software Bill of Materials (SBOM) is generated for each container image, which helps in tracking dependencies and vulnerabilities. Implementing DCO sign-off enforcement ensures that every commit carries a Signed-off-by line, further solidifying the integrity of your codebase. Be aware of the specific versions you are using; for instance, the Cosign installer is at v4.1.1 and the SBOM action at v0.24.0, which are crucial for compatibility and security enhancements.
Key takeaways
- →Utilize GITHUB_TOKENs with minimal read permissions to limit exposure.
- →Manage CI and production credentials in separate GitHub protected environments.
- →Sign container images with Sigstore Cosign using keyless OIDC for enhanced security.
- →Generate SBOMs for container images to track dependencies and vulnerabilities.
- →Enforce DCO sign-off to ensure every commit is verified.
Why it matters
In production, a compromised CI/CD pipeline can lead to significant security breaches. By implementing these practices, you protect your project from potential supply chain attacks and maintain trust with your users.
Code examples
- name: Install Cosign
uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.11- name: Generate SBOM
2 uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
3 with:
4 artifact-name: sbom_${{ inputs.sbom_name }}.spdx.json
5 output-file: ./sbom_${{ inputs.sbom_name }}.spdx.json
6 image: ${{ inputs.image_tag }}- name: Sign Container Image
shell: bash
run: cosign sign -y "${{ inputs.image }}"When NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsIndustry-standard certifications built by the people behind Linux and Kubernetes. Earn the CKA — the gold standard Kubernetes administrator cert. OpsCanary readers get 30% off year-round with code OPSCANARY3.
Get CKA certified →Shadow AI in CI/CD: Securing the Path from Developer Laptop to Kubernetes
Shadow AI tools are creeping into your CI/CD pipelines without oversight, posing significant risks. Understanding how these tools operate and the potential for prompt injection is crucial for safeguarding your deployments. Dive into how to model these threats effectively.
Cortex Security Audit: What You Need to Know
Cortex has completed a rigorous security audit by OSTIF, enhancing its credibility as a multi-tenant storage solution for Prometheus and OpenTelemetry. The audit focused on the security health of tenant boundaries and cluster operations, using advanced code review techniques. This is crucial for anyone looking to deploy Cortex in sensitive environments.
Runtime Supply Chain Verification with NRI: Securing Your Kubernetes Deployments
In a world where supply chain attacks are rampant, ensuring the integrity of your container images is crucial. The Node Resource Interface (NRI) allows you to enforce supply chain verification at runtime, leveraging plugins to validate image attestations before they even start. Dive into how this mechanism works and what you need to watch out for in production.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.