# GHSA-gp6m-fq6h-cjcx: Magento LTS vulnerable to stored XSS in admin file form

> Low-privileged attackers can inject malicious scripts via file uploads in Magento admin, leading to XSS execution in victim browsers.

- **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:** 27 Feb 2024

## What is GHSA-gp6m-fq6h-cjcx?

GHSA-gp6m-fq6h-cjcx is a cross-site scripting vulnerability in openmage/magento-lts, published on 27 Feb 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

### Summary
OpenMage is affected by a stored Cross-Site Scripting (XSS) vulnerability that could be abused by a low-privileged attacker to inject malicious scripts into vulnerable form fields.

### Details
`Mage_Adminhtml_Block_System_Config_Form_Field_File` does not escape filename value in certain situations.
Same as: https://nvd.nist.gov/vuln/detail/CVE-2024-20717

### PoC
1. Create empty file with this filename: `<img src=x onerror=alert(1)>.crt`
2. Go to _System_ > _Configuration_ > _Sales | Payment Methonds_.
3. Click **Configure** on _PayPal Express Checkout_.
4. Choose **API Certificate** from dropdown _API Authentication Methods_.
5. Choose the XSS-file and click **Save Config**.
6. Profit, alerts "1" -> XSS.
7. Reload, alerts "1" -> Stored XSS.

### Impact
Affects admins that have access to any fileupload field in admin in core or custom implementations.
Malicious JavaScript may be executed in a victim’s browser when they browse to the page containing the vulnerable field.

## Which versions are affected by GHSA-gp6m-fq6h-cjcx?

4 open source packages ship an affected version, including openmage/magento-lts.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `openmage/magento-lts` | Packagist | All versions | 19.5.3 |
| `openmage/magento-lts` | Packagist | All versions | 19.5.3 |
| `openmage/magento-lts` | Packagist | From 20.0.0 | 20.5.0 |
| `openmage/magento-lts` | Packagist | From 20.0.0 | 20.5.0 |

## How do I fix GHSA-gp6m-fq6h-cjcx?

Upgrade openmage/magento-lts to a fixed version for your release line: 19.5.3 or 20.5.0.

## Is GHSA-gp6m-fq6h-cjcx being exploited?

There is no known exploitation of GHSA-gp6m-fq6h-cjcx in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gp6m-fq6h-cjcx and fix it if it is affected.

What it is: GHSA-gp6m-fq6h-cjcx is a cross-site scripting vulnerability in openmage/magento-lts, published on 27 Feb 2024. 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-gp6m-fq6h-cjcx in the wild and no public exploit code.

Affected packages and fixed versions:
- openmage/magento-lts (Packagist): affected all versions; fixed in 19.5.3
- openmage/magento-lts (Packagist): affected all versions; fixed in 19.5.3
- openmage/magento-lts (Packagist): affected from 20.0.0; fixed in 20.5.0
- openmage/magento-lts (Packagist): affected from 20.0.0; fixed in 20.5.0

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-gp6m-fq6h-cjcx/ (Markdown: https://insights.sbomify.com/GHSA-gp6m-fq6h-cjcx/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gp6m-fq6h-cjcx

---
From sbomify Insights: https://insights.sbomify.com/GHSA-gp6m-fq6h-cjcx/
Summaries are generated and may contain mistakes; the official description above is the record.
