LowGHSA-q8jq-xrf4-v5j8CVE-2026-121949

Symfony: HtmlSanitizer Does Not URL-Sanitize srcset and imagesrcset Leading to Media Scheme and Host Allow-List Bypass

Published 1 Dec 2026 · Updated 1 Dec 2026

Affected packages

Affected
>=6.1.0 <6.4.50
Fixed in
6.4.50
Update to the fixed version for your release line, for example:composer require symfony/html-sanitizer:^6.4.50
Affected
>=7.0.0 <7.4.23
Fixed in
7.4.23
Update to the fixed version for your release line, for example:composer require symfony/html-sanitizer:^7.4.23
Affected
>=8.0.0 <8.1.11
Fixed in
8.1.11
Update to the fixed version for your release line, for example:composer require symfony/html-sanitizer:^8.1.11
Affected
>=6.1.0 <6.4.50
Fixed in
6.4.50
Update to the fixed version for your release line, for example:composer require symfony/symfony:^6.4.50
Affected
>=7.0.0 <7.4.23
Fixed in
7.4.23
Update to the fixed version for your release line, for example:composer require symfony/symfony:^7.4.23
Affected
>=8.0.0 <8.1.11
Fixed in
8.1.11
Update to the fixed version for your release line, for example:composer require symfony/symfony:^8.1.11

We confirm your address first. See our privacy policy.

Which symfony/html-sanitizer does your project really install?

Drop your composer.lock hereWe find the exact symfony/html-sanitizer version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

Works for private projects: the file is read in memory to run the scan and then dropped. Also reads composer.json.

Public repo?

Look after several Laravel or PHP apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Details

Description

W3CReference::ATTRIBUTES marks srcset and imagesrcset as allowed attributes, but UrlAttributeSanitizer::getSupportedAttributes() does not list them, so no URL sanitizer is registered for either. The DOM visitor preserves an attribute value verbatim when no sanitizer handles it, so attacker-controlled responsive-image URL lists survive unchanged and the media scheme and host allow-lists are bypassed. The fixes for CVE-2026-45753 and CVE-2026-48761 extended the same attribute list but did not cover these two attributes.

The same policy correctly drops the equivalent img[src] value, so this is not a configuration mistake but a missing sanitizer for two browser-active URL attributes.

$config = (new HtmlSanitizerConfig())->allowSafeElements()
    ->allowMediaSchemes(['https'])->allowMediaHosts(['trusted.example']);
$sanitizer = new HtmlSanitizer($config);

$sanitizer->sanitize('<img srcset="https://evil.example/a.png 1x" alt="x">');
// srcset survives, browser fetches from evil.example

$sanitizer->sanitize('<img src="https://evil.example/a.png" alt="x">');
// src correctly dropped

source[srcset] and, in the head context, link[rel=preload][imagesrcset] behave the same way. The confirmed primitive is a browser-active URL policy bypass, not JavaScript execution.

Exploitation requires the application to sanitize attacker-controlled HTML with a configuration that allows these attributes, through allowSafeElements(), allowStaticElements() or an explicit opt-in, and to rely on allowMediaHosts(), allowMediaSchemes() or forceHttpsUrls() to restrict media URLs. The severity is rated low on that basis.

Resolution

srcset and imagesrcset are now sanitized. Because they carry a comma-separated list of candidates rather than a single URL, the value is parsed following the HTML srcset parsing rules, which correctly handles commas inside URLs and trailing width or density descriptors. Each candidate URL is passed through UrlSanitizer::sanitize() against the media policy, rejected candidates are dropped, and survivors are re-serialized with their descriptors intact. If every candidate is rejected, or the value is empty or holds only separators, the attribute is dropped, consistent with a rejected src, letting the browser fall back to the already sanitized src.

The patches for this issue are available here for branch 6.4 (and forward-ported to 7.4, 8.1 and 8.2). They require the patch for CVE-2026-118517, available here. Without it, a candidate written without //, like http:evil.example/a.png, is not checked against the media host allow-list.

Credits

Symfony would like to thank Shriyansh Gupta, Ilia Alshanetsky and 李智遥 for independently reporting the issue.

Is GHSA-q8jq-xrf4-v5j8 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected symfony/html-sanitizer, and gives you the command that fixes it.

More advisories for symfony/html-sanitizer

  • LowCVE-2026-118517Symfony: HtmlSanitizer allowLinkHosts() / allowMediaHosts() Bypass via URLs Without a Well-Formed Authority: Incomplete Fix for CVE-2026-45066 · 1 Dec 2026
  • MediumCVE-2026-121373Symfony: HtmlSanitizer MetaRefreshAttributeSanitizer Matches Only a Narrow Subset of the Browser Refresh Grammar: Incomplete Fix for CVE-2026-48761 · 1 Dec 2026
  • MediumCVE-2026-48760Symfony: HtmlSanitizer URL Parser Deny Gates Underinclusive: Percent-Encoded BiDi Marks and Unicode Whitespace Bypass Visual-Spoofing Defense · 15 Jun 2026
  • MediumCVE-2026-48761Symfony: HtmlSanitizer UrlAttributeSanitizer Misses URL Attributes · 15 Jun 2026
  • LowCVE-2026-45753Symfony's HtmlSanitizer UrlAttributeSanitizer Omits action/formaction/poster/cite — `javascript`: URI Survives Sanitization (XSS) · 28 May 2026
  • MediumCVE-2026-45066Symfony has an HtmlSanitizer allowLinkHosts() / allowMediaHosts() Bypass via URL-Parser Differentials and <area> Misclassification · 27 May 2026
All 8 advisories for symfony/html-sanitizer

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.