The vulnerability stems from incomplete URL sanitization within the Symfony HtmlSanitizer component, leading to two distinct cross-site scripting (XSS) vectors. An analysis of the provided patch commit reveals the exact nature of these flaws.
First, the UrlAttributeSanitizer was not configured to sanitize all attributes that can contain URLs. The getSupportedAttributes function in UrlAttributeSanitizer.php was missing several URL-bearing attributes, including data, codebase, archive, and longdesc. This meant that if a developer configured the sanitizer to allow elements like <object> or <applet> with these attributes, any URL provided in them, including malicious javascript: payloads, would not be sanitized.
Second, the sanitizer lacked the capability to handle URLs embedded within the content attribute of <meta http-equiv="refresh"> tags. The default configuration, set in HtmlSanitizerConfig::__construct, did not include a sanitizer to parse this specific format. This allowed an attacker to craft a payload like content="0; url=javascript:alert(1)" which would be executed by the browser if the application allowed <meta> tags.
The patch addresses these issues by:
- Expanding the list of attributes in
UrlAttributeSanitizer::getSupportedAttributes to include the missing ones.
- Introducing a new
MetaRefreshAttributeSanitizer class to specifically handle and sanitize URLs within the content attribute of meta-refresh tags and registering it in the HtmlSanitizerConfig constructor.