Skip to content

Commit b091fe1

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: fix merge [FrameworkBundle] Remove extra argument from ContainerBuilder::willBeAvailable call fix ext-redis 6.2.0 compatibility [CssSelector] Fix incorrect return type for Token::getType() [Workflow] State contamination due to class-based setter cache fix: fixed State contamination in marking stores due to class-based getter cache [Validator] Fix call to undefined getParser() in YamlValidator [ObjectMapper] Update Map attribute PHPDoc to match TransformCallableInterface signature fix tests Fix contentId assignment for inline attachments [HtmlSanitizer] Remove `srcdoc` from allowed attributes [EventDispatcher][FrameworkBundle] Rework union types on `#[AsEventListener]`
2 parents f80bf94 + 5b0bbcc commit b091fe1

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

Reference/W3CReference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ final class W3CReference
368368
'span' => true,
369369
'spellcheck' => true,
370370
'src' => true,
371-
'srcdoc' => true,
371+
// 'srcdoc' => false, // XSS vector if not properly sandboxed, should be enabled explicitly with ->allowAttribute('srcdoc', 'iframe')->forceAttribute('iframe', 'sandbox', '')
372372
'srclang' => true,
373373
'srcset' => true,
374374
'standby' => true,

Tests/Fixtures/baseline-attribute-allow-list.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@
182182
"span",
183183
"spellcheck",
184184
"src",
185-
"srcdoc",
186185
"srclang",
187186
"srcset",
188187
"standby",

Tests/HtmlSanitizerAllTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,23 @@ public static function provideSanitizeHtml(): iterable
590590
];
591591
}
592592

593+
public function testIFrameDefaultsAreSafe()
594+
{
595+
$sanitizer = new HtmlSanitizer((new HtmlSanitizerConfig())
596+
->allowElement('iframe', '*')
597+
);
598+
$input = '<iframe src="javascript:alert()" onload="alert()" srcdoc="<script>alert()</script>">XSS</iframe>';
599+
$this->assertSame('<iframe>XSS</iframe>', $sanitizer->sanitize($input));
600+
601+
$sanitizer = new HtmlSanitizer((new HtmlSanitizerConfig())
602+
->allowElement('iframe', '*')
603+
->allowAttribute('srcdoc', 'iframe')
604+
->forceAttribute('iframe', 'sandbox', '')
605+
);
606+
$input = '<iframe src="javascript:alert()" onload="alert()" srcdoc="<script>alert()</script>">XSS-prevented by sandbox</iframe>';
607+
$this->assertSame('<iframe srcdoc="&lt;script&gt;alert()&lt;/script&gt;" sandbox>XSS-prevented by sandbox</iframe>', $sanitizer->sanitize($input));
608+
}
609+
593610
public function testUnlimitedLength()
594611
{
595612
$sanitizer = new HtmlSanitizer((new HtmlSanitizerConfig())->withMaxInputLength(-1));

Tests/HtmlSanitizerConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function testAllowElementStandardAttributes()
109109
$config = new HtmlSanitizerConfig();
110110
$config = $config->allowElement('div', '*');
111111
$this->assertSame(['div'], array_keys($config->getAllowedElements()));
112-
$this->assertCount(211, $config->getAllowedElements()['div']);
112+
$this->assertCount(210, $config->getAllowedElements()['div']);
113113
$this->assertSame([], $config->getBlockedElements());
114114
}
115115

0 commit comments

Comments
 (0)