# GHSA-pj96-4jhv-v792: Cross site scripting via cookies in gogs

> An attacker can manipulate CSRF cookies to trigger self-XSS in Gogs, potentially bypassing security controls for the malicious user.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 2 Jun 2022
- **Also known as:** GO-2022-0473

## What is GHSA-pj96-4jhv-v792?

GHSA-pj96-4jhv-v792 is a cross-site scripting vulnerability in gogs.io/gogs, published on 2 Jun 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

### Impact

There is no known practical impact other than it is just possible to manipulate CSRF cookie and XSS the malicious user self.

### Patches

Invalid characters of CSRF tokens are stripped after reading cookie. Users should upgrade to 0.12.8 or the latest 0.13.0+dev.

### Workarounds

No need for workarounds.

### References

N/A

### For more information

If you have any questions or comments about this advisory, please post on https://github.com/gogs/gogs/issues/6953.

## Which versions are affected by GHSA-pj96-4jhv-v792?

3 open source packages ship an affected version, including gogs.io/gogs.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `gogs.io/gogs` | Go | All versions | 0.12.8 |
| `gogs.io/gogs` | Go | All versions | 0.12.8 |
| `gogs.io/gogs` | Go | All versions | 0.12.8 |

## How do I fix GHSA-pj96-4jhv-v792?

Upgrade gogs.io/gogs to 0.12.8 or later.

## Is GHSA-pj96-4jhv-v792 being exploited?

There is no known exploitation of GHSA-pj96-4jhv-v792 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-pj96-4jhv-v792 and fix it if it is affected.

What it is: GHSA-pj96-4jhv-v792 is a cross-site scripting vulnerability in gogs.io/gogs, published on 2 Jun 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-pj96-4jhv-v792 in the wild and no public exploit code.

Affected packages and fixed versions:
- gogs.io/gogs (Go): affected all versions; fixed in 0.12.8
- gogs.io/gogs (Go): affected all versions; fixed in 0.12.8
- gogs.io/gogs (Go): affected all versions; fixed in 0.12.8

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-pj96-4jhv-v792/ (Markdown: https://insights.sbomify.com/GHSA-pj96-4jhv-v792/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-pj96-4jhv-v792

---
From sbomify Insights: https://insights.sbomify.com/GHSA-pj96-4jhv-v792/
Summaries are generated and may contain mistakes; the official description above is the record.
