Symfony's HtmlSanitizer passed srcset and imagesrcset attribute values through untouched. Even when you limit images to certain hosts or schemes, sanitized HTML could make a visitor's browser load images from anywhere. It doesn't let an attacker run JavaScript.
The src attribute on the same <img> was checked correctly. No URL check was registered for these two attributes. See the Symfony advisory and the fix.
Who is affected
Apps that sanitize untrusted HTML with symfony/html-sanitizer when both of these are true:
- The config allows
srcsetorimagesrcset, throughallowSafeElements(),allowStaticElements()or allowing them by name. - The app relies on
allowMediaHosts(),allowMediaSchemes()orforceHttpsUrls()to limit media URLs.
<img>, <source> and <link rel="preload"> elements are all affected. If you don't restrict media hosts or schemes, there's no rule to get around. Symfony rates the issue low (CVSS 2.3).
What to do
Update symfony/html-sanitizer (or symfony/symfony) to 6.4.50, 7.4.23 or 8.1.11, depending on your branch. After the update, each URL in a srcset list is checked against your media rules, and the attribute is dropped when none pass. This fix depends on the one for CVE-2026-118517, which ships in the same releases.
Reported independently by Shriyansh Gupta, Ilia Alshanetsky and 李智遥.