# GHSA-785h-76cm-cpmf: Django TomSelect incomplete escaping of dangerous characters in widget attributes


- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 26 Mar 2025

## What is GHSA-785h-76cm-cpmf?

GHSA-785h-76cm-cpmf is a vulnerability in django-tomselect, published on 26 Mar 2025. 

### Official description

### Summary
User supplied values passed through to certain attributes in form widgets are not fully escaped for potentially dangerous tokens, and in some cases are rendered in browser as valid html tags.

### Details
Attributes passed to the widget (such as `label_field`) containing `<`, `>`, and similar tokens are not fully escaped. This results in some raw values reaching the widget, and rendering in part or fully.

For example, a label of: `"Test User <script>I can pass this to the label_field and it gets rendered</script>"` is rendered in the choices's label visually as `"Test User "` with the trailing space, and what appears as an un-executed script tag following it (which is visible when viewing source).

The actual output rendered in the browser for this example is: `<div role="option" data-value="63f205b6" class="item" data-ts-item="">Test User <script>I can pass this to the label_field and it gets rendered</script></div>`

The script tags appears to be valid in Chrome dev tools, but doesn't appear execute code.

### Impact
Although the risk may be mediated since the content within the rendered `<script></script>` tags does not seem to actually/immediately run, potential may exist for other ways of increasing the risk (e.g.: code injection).  In addition, the widget does not display correctly for valid strings containing `<` or `>`. Valid use-cases for printing these characters include widget label fields displaying email addresses (e.g.: `"User Jane <user.jane@example.com>"`

Because of the relatively small number of users at this moment, our plan to yank affected releases on PyPI and GitHub, and because raw text is rendered but does not seem to be executable, I am marking the Severity **Low**.

Update to version **5.3.3**. The only difference from 5.3.2 is the code and documentation changes to resolve this vulnerability, so the update process should not be problematic.

## Which versions are affected by GHSA-785h-76cm-cpmf?

2 open source packages ship an affected version, including django-tomselect.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `django-tomselect` | PyPI | All versions | 2025.3.3 |
| `django-tomselect` | PyPI | All versions | 2025.3.3 |

## How do I fix GHSA-785h-76cm-cpmf?

Upgrade django-tomselect to 2025.3.3 or later.

## Is GHSA-785h-76cm-cpmf being exploited?

There is no known exploitation of GHSA-785h-76cm-cpmf in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-785h-76cm-cpmf and fix it if it is affected.

What it is: GHSA-785h-76cm-cpmf is a vulnerability in django-tomselect, published on 26 Mar 2025. 
Exploitation: There is no known exploitation of GHSA-785h-76cm-cpmf in the wild and no public exploit code.

Affected packages and fixed versions:
- django-tomselect (PyPI): affected all versions; fixed in 2025.3.3
- django-tomselect (PyPI): affected all versions; fixed in 2025.3.3

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-785h-76cm-cpmf/ (Markdown: https://insights.sbomify.com/GHSA-785h-76cm-cpmf/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-785h-76cm-cpmf

---
From sbomify Insights: https://insights.sbomify.com/GHSA-785h-76cm-cpmf/
Summaries are generated and may contain mistakes; the official description above is the record.
