Lesson 3 of 3 Amazon Inspector and Secure Pipelines

Securing the Software Supply Chain

This lesson explains the controls that make sure only trusted, scanned and unmodified artifacts reach production, since most of the code a workload runs, base images, open-source packages and build tools, was written by someone else.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how AWS CodeArtifact restricts builds to trusted sources.
  • Describe image scanning and the export of software bills of materials.
  • Explain how image signing and immutability verify integrity.
  • Explain how dependency confusion attacks are prevented.

Trusted sources

Builds should obtain dependencies only from trusted sources. The following list describes how this is enforced.

  • AWS CodeArtifact as the only package source for builds, with upstream connections to public registries. Package origin controls block upstream versions of internal package names, which prevents dependency confusion attacks.
  • ECR pull-through cache for public container images, so builds pull from a repository you control and scan.
  • Restrict build environments' network egress so they cannot fetch from arbitrary locations.

The following diagram shows where a malicious public package is stopped in a dependency confusion attack when installs go through CodeArtifact.

Preventing dependency confusion. All installs go through CodeArtifact, where internal packages are published, and package origin controls on internal names block upstream versions, so a malicious public package with the same name and a higher version is never pulled. Developers keep their tools.
The scenario is illustrative.

Scanning and SBOMs

Amazon Inspector scans ECR images on push and continuously, and can export a software bill of materials (SBOM) in CycloneDX or SPDX format for every resource it monitors. In pipelines, the Inspector SBOM Generator and CI/CD integration scan artifacts before they are pushed, so a build fails on critical vulnerabilities instead of a finding appearing after deployment.

True or false

SBOMs and pre-push scanning

Exam skills 3.2.3 · 3.2.6

Check how Inspector produces SBOMs and scans before push.

Log in to try this activity Interactive activities are free with an account.

Integrity: signing and immutability

Supply chain controls make sure that what is deployed is exactly what was built and approved. Container images are signed with AWS Signer and Notation, and an admission controller such as Kyverno or Gatekeeper on EKS verifies the signature before a pod can run. ECR tag immutability prevents a trusted tag, such as v1.4, from being overwritten with a different image. Lambda packages are protected by a code signing configuration that references Signer profiles; set to Enforce, it rejects unsigned or altered code. Build artefacts are encrypted with KMS, stored in buckets that only the pipeline roles can access, and recorded with their digests so any change can be detected. The following table summarises the controls.

ArtifactControl
Container imagesSign with AWS Signer and Notation; verify signatures at deployment with an admission controller (for example Kyverno or Gatekeeper on EKS)
Image tagsECR tag immutability, so a trusted tag cannot be overwritten with a different image
Lambda packagesCode signing configuration with Signer profiles, set to Enforce
Build artifactsEncrypt with KMS, restrict bucket access to the pipeline roles, and record digests
Match the pairs

Keeping artefacts intact

Exam skills 3.2.6 · 5.2.2

Match each artefact with its integrity control.

Log in to try this activity Interactive activities are free with an account.

Securing the pipeline itself

The deployment pipeline is itself a target and must be secured. The following list describes the recommended controls.

  • Require reviews and branch protection, so one compromised developer account cannot push to production.
  • Give each stage a narrowly scoped role; only the deploy stage can change production.
  • Use OIDC federation for external CI systems instead of stored access keys.
  • Keep build secrets in Secrets Manager, referenced from the buildspec, never in source.
  • Log and alert on changes to pipeline definitions and build projects.
Select all that apply

Securing the pipeline itself

Exam skills 3.2.6

Pick the controls that protect the deployment pipeline.

Log in to try this activity Interactive activities are free with an account.
Worked example

A company finds that a build pulled a malicious package from a public registry with the same name as one of its internal libraries, but a higher version number. How can this be prevented with minimal changes to developer workflows?

This is dependency confusion. Route all package installs through CodeArtifact, publish internal packages there, and set package origin controls on internal names to block upstream versions. Developers keep using the same tools, pointed at CodeArtifact.

Check yourself

How does CodeArtifact help prevent dependency confusion?

Show answer

With package origin controls, which stop public packages from replacing internal ones of the same name.

Exam Tips

Remember for the exam

  • Use CodeArtifact with package origin controls to prevent dependency confusion.
  • Inspector scans ECR images and exports SBOMs; scan in the pipeline before deployment too.
  • Sign images with AWS Signer and Notation and verify at deployment.
  • Enable ECR tag immutability so trusted tags cannot be overwritten.
  • Enforce Lambda code signing for function packages.
  • Use OIDC instead of stored keys for external CI systems.