10000 [HtmlSanitizer] Processing instructions misinterpreted as elements · Issue #54492 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[HtmlSanitizer] Processing instructions misinterpreted as elements #54492
Closed
@nielsdos

Description

@nielsdos

Symfony version(s) affected

7.0, perhaps lower too

Description

You're checking the node name in the node traversal, but not the node type.
So creating a processing instruction with the name of an allowed element results in a misinterpretation: the processing instruction will be considered as if it is an element. Fortunately, this has no security impact because we can only misinterpret nodes into an allowed element.

How to reproduce

<?php
require 'vendor/autoload.php';

use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;

$config = (new HtmlSanitizerConfig())->allowElement("div");

$sanitizer = new HtmlSanitizer($config);
echo $sanitizer->sanitize("<?div x?>"), "\n";

Results in:

<div></div>

Possible Solution

Don't allow processing instructions, those aren't allowed by HTML5 anyway.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0