# GHSA-xgfm-fjx6-62mj: readthedocs-sphinx-search vulnerable to cross-site scripting when including search results from malicious projects

> An attacker can inject arbitrary HTML into search results via malicious projects, requiring user interaction to trigger execution.

- **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:** 16 Jan 2024

## What is GHSA-xgfm-fjx6-62mj?

GHSA-xgfm-fjx6-62mj is a cross-site scripting vulnerability in readthedocs-sphinx-search, published on 16 Jan 2024. 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

### Impact

This vulnerability could have allowed an attacker to include arbitrary HTML content in search results by having a user search a malicious project. This was due to our search client not correctly escaping all user content from search results. You can find more information in the [advisory published in our readthedocs.org repo](https://github.com/readthedocs/readthedocs.org/security/advisories/GHSA-qhqx-5j25-rv48).

Users of this extension should update to the 0.3.2 version, and trigger a new build.

This issue was discovered by a member of our team, and we have seen no signs that this vulnerability was exploited in the wild.

### Patches

This issue has been patched in our 0.3.2 version. 

### References

- https://github.com/readthedocs/readthedocs-sphinx-search/commit/8c6f6d01e88e72ef32ed0c220b6c19d1e1121c73

### For more information

If you have any questions or comments about this advisory, email us at [security@readthedocs.org](mailto:security@readthedocs.org) ([PGP](https://docs.readthedocs.io/page/security.html#pgp-key))

## Which versions are affected by GHSA-xgfm-fjx6-62mj?

2 open source packages ship an affected version, including readthedocs-sphinx-search.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `readthedocs-sphinx-search` | PyPI | All versions | 0.3.2 |
| `readthedocs-sphinx-search` | PyPI | All versions | 0.3.2 |

## How do I fix GHSA-xgfm-fjx6-62mj?

Upgrade readthedocs-sphinx-search to 0.3.2 or later.

## Is GHSA-xgfm-fjx6-62mj being exploited?

There is no known exploitation of GHSA-xgfm-fjx6-62mj in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-xgfm-fjx6-62mj and fix it if it is affected.

What it is: GHSA-xgfm-fjx6-62mj is a cross-site scripting vulnerability in readthedocs-sphinx-search, published on 16 Jan 2024. 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-xgfm-fjx6-62mj in the wild and no public exploit code.

Affected packages and fixed versions:
- readthedocs-sphinx-search (PyPI): affected all versions; fixed in 0.3.2
- readthedocs-sphinx-search (PyPI): affected all versions; fixed in 0.3.2

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-xgfm-fjx6-62mj/ (Markdown: https://insights.sbomify.com/GHSA-xgfm-fjx6-62mj/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-xgfm-fjx6-62mj

---
From sbomify Insights: https://insights.sbomify.com/GHSA-xgfm-fjx6-62mj/
Summaries are generated and may contain mistakes; the official description above is the record.
