<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
---
name: detecting-container-supply-chain-attacks
description: >-
  Detect container supply chain attacks including malicious base images,
  compromised dependencies, typosquatted packages, backdoored build
  pipelines, and untrusted registry pulls in container ecosystems.
domain: cybersecurity
subdomain: cloud-native-security
tags:
  - supply-chain
  - container-security
  - sbom
  - vulnerability-scanning
  - trivy
  - grype
  - base-image
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1195.002"]
---

# Detecting Container Supply Chain Attacks

## Overview

Detect container supply chain attacks including malicious base images, compromised dependencies, typosquatted packages, backdoored build pipelines, and untrusted registry pulls in container ecosystems.

Mode: `[MODE: BLUE]` — Detect supply chain threats. `[MODE: RED]` — Map supply chain attack surface (T1195.002).

## Prerequisites

| Requirement | Details |
|---|---|
| trivy >= 0.50 or grype installed | Required |
| Container registry access | Required |
| CI/CD pipeline access for build verification | Required |

## Key Concepts

### Scan Images for Vulnerabilities

```bash
# Scan with trivy
trivy image --severity CRITICAL,HIGH registry.example.com/app:v1.0

# Scan with grype
grype registry.example.com/app:v1.0 --only-fixed --fail-on high

# Generate SBOM and scan
syft registry.example.com/app:v1.0 -o spdx-json | grype
```

### Audit Base Images

```bash
# Check base image source in Dockerfile
grep -i '^FROM' Dockerfile

# Verify base image digest
docker inspect --format='{{{{.RepoDigests}}}}' IMAGE

# Find images not from trusted registries
kubectl get pods -A -o json | \
  jq -r '.items[].spec.containers[].image' | \
  grep -v 'gcr.io\|ecr.*amazonaws.com\|registry.example.com'
```

### Detect Typosquatting

```bash
# Compare package names against known-good list
trivy image --list-all-pkgs -o json IMAGE | \
  jq '.Results[].Packages[].Name' | sort > installed.txt

# Check for suspicious package names
diff <(sort known-good-packages.txt) installed.txt
```

### CI/CD Pipeline Integrity

```bash
# Verify build provenance with SLSA
slsa-verifier verify-image \
  --source-uri github.com/org/repo \
  --builder-id https://github.com/slsa-framework/slsa-github-generator \
  registry.example.com/app:v1.0
```

## Workflow

```bash
node scripts/agent.js --action audit --namespace production
cat /tmp/detecting-container-supply-chain-attacks-audit.json | jq '.findings[]'
```

## Detection

```yaml
title: Container Supply Chain Attacks Detection
id: b6986d6a-8b64-4c38-b827-162092c652ef
status: experimental
description: Detects suspicious activity related to detecting container supply chain attacks techniques in cloud native security context
logsource:
  product: kubernetes
  service: audit
detection:
  selection:
    eventName: "*Unauthorized*"
  condition: selection
level: medium
tags:
  - attack.t1195.002
  - attack.privilege_escalation
falsepositives:
  - Kubernetes controller reconciliation loops during cluster updates
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Container Supply Chain Attacks Detection | kubernetes | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1195.002 |

## Verification

- [ ] All images scanned for CVEs before deploy
- [ ] Base images pinned by digest, not tag
- [ ] SBOM generated and stored for every release
- [ ] Only trusted registries allowed via admission policy
- [ ] Build provenance verifiable (SLSA Level 2+)
- [ ] Dependency review automated in CI pipeline

## References

- [SLSA Supply Chain Framework](https://slsa.dev/)
- [Trivy Container Scanning](https://aquasecurity.github.io/trivy/)
- [MITRE ATT&CK T1195.002 — Supply Chain Compromise](https://attack.mitre.org/techniques/T1195/002/)
- [NIST SP 800-218 — SSDF](https://csrc.nist.gov/publications/detail/sp/800-218/final)
