# Stored XSS on the job page

Stored XSS via kubernetes namespace in .gitlab-ci.yml rendered unsafely in the job page environments block, executing JS in viewers' browsers.

- Payout: $3,000
- Severity: high
- Program: GitLab
- Found by: mike12
- Disclosed: 2021-01-08
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/856554
- Library page: https://bugbountylibrary.com/r/h1%3A856554
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:ci-cd tech:nodejs technique:source-review vuln:xss

**Target:** GitLab job page environments_block.vue component
**Root cause:** The kubernetes namespace value from .gitlab-ci.yml is interpolated into the Vue template (via %{kubernetesNamespace} and related bindings) without sanitization, allowing HTML/JS injection.
**Steps:**
1. Run GitLab CE via docker.
2. Create project with README.md.
3. Operations->Kubernetes: add existing cluster, name cluster-example, API URL https://google.com, token token-example, uncheck GitLab-managed cluster.
4. Add .gitlab-ci.yml with environment.kubernetes.namespace set to `<img src=x onerror=alert(1)>`.
5. Go to CI/CD->Jobs and open the last job; payload executes.
**How found:** Code reading of environments_block.vue identified multiple locations where %{kubernetesNamespace} is rendered without escaping.
**Exploitation:** Attacker with commit access to a project's CI config sets a malicious namespace value; any user viewing the job page (including maintainers) executes attacker JS, enabling actions as the victim and credential/data theft.
**Insight:** CI/CD config fields (environment namespace, url, names) flow into Vue templates on job pages; test every user-controlled CI YAML field for HTML injection in the UI renderer.

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

**Malicious .gitlab-ci.yml with XSS payload in kubernetes namespace**

```
deploy:
      stage: deploy
      script:
        - echo "Example"
      environment:
        name: production
        url: https://google.com
        kubernetes:
          namespace: <img src=x onerror=alert(1)>
```

