# GHSA-5vm8-hhgr-jcjp: Cross-site scripting vulnerability in TinyMCE

> An XSS vulnerability in TinyMCE allows arbitrary JavaScript execution via crafted form URLs when content is previewed or rendered outside the editor.

- **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:** 28 May 2021

## What is GHSA-5vm8-hhgr-jcjp?

GHSA-5vm8-hhgr-jcjp is a cross-site scripting vulnerability in tinymce, published on 28 May 2021. 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
A cross-site scripting (XSS) vulnerability was discovered in the URL sanitization logic of the core parser for `form` elements. The vulnerability allowed arbitrary JavaScript execution when inserting a specially crafted piece of content into the editor using the clipboard or APIs, and then submitting the form. However, as TinyMCE does not allow forms to be submitted while editing, the vulnerability could only be triggered when the content was previewed or rendered outside of the editor. This impacts all users who are using TinyMCE 5.7.0 or lower.

### Patches
This vulnerability has been patched in TinyMCE 5.7.1 by improved URL sanitization logic.

### Workarounds
To work around this vulnerability, either:
- Upgrade to TinyMCE 5.7.1 or higher
- Manually sanitize `form` URL attributes using a [TinyMCE node filter](https://www.tiny.cloud/docs/api/tinymce.html/tinymce.html.domparser/#addnodefilter).
- Disable `form` elements in your content using the [invalid_elements](https://www.tiny.cloud/docs/configure/content-filtering/#invalid_elements) setting.

#### Example: Sanitizing using a node filter
```js
editor.parser.addNodeFilter('form', function(nodes) {
  nodes.forEach(function(node) {
    if (node.attributes) {
      node.attributes.forEach(function(attr) {
        var name = attr.name;
        var value = attr.value;
        // Sanitize the attribute value here or remove it entirely
        var sanitizedValue = ...;
        node.attr(name, santizedValue);
      });
    }
  });
});
```

#### Example: Using invalid_elements
```js
invalid_elements: 'form'
```

### Acknowledgements
Tiny Technologies would like to thank Mikhail Khramenkov at Solar Security Research Team for discovering this vulnerability.

### References
https://www.tiny.cloud/docs/release-notes/release-notes571/#securityfixes

### For more information
If you have any questions or comments about this advisory:
* Open an issue in the [TinyMCE repo](https://github.com/tinymce/tinymce/issues)
* Email us at [infosec@tiny.cloud](mailto:infosec@tiny.cloud)

## Which versions are affected by GHSA-5vm8-hhgr-jcjp?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `tinymce` | npm | All versions | 5.7.1 |
| `tinymce` | npm | All versions | 5.7.1 |

## How do I fix GHSA-5vm8-hhgr-jcjp?

Upgrade tinymce to 5.7.1 or later.

## Is GHSA-5vm8-hhgr-jcjp being exploited?

There is no known exploitation of GHSA-5vm8-hhgr-jcjp in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-5vm8-hhgr-jcjp and fix it if it is affected.

What it is: GHSA-5vm8-hhgr-jcjp is a cross-site scripting vulnerability in tinymce, published on 28 May 2021. 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-5vm8-hhgr-jcjp in the wild and no public exploit code.

Affected packages and fixed versions:
- tinymce (npm): affected all versions; fixed in 5.7.1
- tinymce (npm): affected all versions; fixed in 5.7.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-5vm8-hhgr-jcjp/ (Markdown: https://insights.sbomify.com/GHSA-5vm8-hhgr-jcjp/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-5vm8-hhgr-jcjp

---
From sbomify Insights: https://insights.sbomify.com/GHSA-5vm8-hhgr-jcjp/
Summaries are generated and may contain mistakes; the official description above is the record.
