# GHSA-R7X2-725F-H4M9: XSS via unescaped object values in JSX and MDX elements

- Database: GitHub
- Severity: CVSS 6.1 (Medium)
- Published: 2026-12-02
- Modified: 2026-12-02

## Affected versions

- astro (npm): through 7.4.13
- @astrojs/runtime (npm): through 0.1.2

## Description

## Summary

Astro escapes dynamic values in templates before rendering them as HTML, but only when the value was a string. Other values that turn into text, such as an `Error`, a `String` object, a Node.js `Buffer`, or any object with a custom `toString()`, were converted to a string and rendered without escaping.

This affected `.astro` templates, JSX and MDX. In JSX and MDX it also affected `set:text`, which is documented to escape its value.

For example:

```astro
---
let error;
try {
  await loadPost(Astro.url.searchParams.get('id'));
} catch (e) {
  error = e; // e.g. new Error(`Post "${id}" not found`)
}
---
<p>{error}</p>
```

rendered `<p>Error: Post "<script>alert(1)</script>" not found</p>` as live HTML. In JSX and MDX, `{new String(value)}`, `{Buffer.from(value)}` and `<div set:text={new String(value)} />` were rendered unescaped in the same way.

## Impact

Reflected or stored cross-site scripting, but only in applications that render untrusted input inside a non-string value, such as an error message built from a request parameter or a buffer read from user-supplied content. String values were always escaped.

Rendering a `Uint8Array` or `Buffer` in a `.astro` template, and passing a `Response`, stream or iterable to `set:html`, intentionally writes the raw content and is unchanged. Only use these with trusted content.

## Affected versions

`astro` <= 7.4.13 and `@astrojs/runtime` <= 0.1.2.

## Patches

Fixed in `astro` 7.4.14 and `@astrojs/runtime` 0.1.3. Non-string values in template expressions, JSX, MDX and `set:text` are now converted to a string and escaped like strings.

## Workarounds

Upgrade to `astro` 7.4.14 or later. Before upgrading, convert values to strings before rendering them, for example `{String(error)}` or `{error.message}`, so that Astro escapes them.

## Credits

Reported by [@HellboundAJ](https://github.com/HellboundAJ).

## References

- https://github.com/withastro/astro/security/advisories/GHSA-r7x2-725f-h4m9

Page: https://cve.now/GHSA-R7X2-725F-H4M9

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
