Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1wbXd3LXY2YzktN3A4M84AA6gN

Piccolo Admin's raw SVG loading may lead to complete data compromise from admin page

Summary

Piccolo's admin panel provides the ability to upload media files and view them within the admin panel. If SVG is an allowed file type for upload; the default; an attacker can upload an SVG which when loaded under certain contexts allows for arbitrary access to the admin page.

This access allows the following actions for example:

As the SVG is executed from the context of an authenticated admin session, any actions they may be able to make can be made by the attacker.

N.b. The relevant session cookies are inaccessible from JavaScript due to httponly being set so all exploits must be present within the SVG file

PoC

Complete instructions, including specific configuration details, to reproduce the vulnerability.

Currently, this requires the ability for a user to have access to an administrators account in order to upload the malicious file for simplicity sake. I can however imagine situations where general end users have the ability to upload files which can later be managed via the admin page.

See the following repository: Piccolo XSS

  1. Clone the repo
  2. Run all migrations & create an admin user
  3. Run app.py as a FastAPI application
  4. Login to the admin page
  5. Create a new task and upload the following file to see basic execution: payloads/basic_xss.svg
  6. Click the SVG to view it inline
  7. Click "Open image in new tab"
  8. Observe the XSS triggering

Fig 1: An example XSS payload executing
Example XSS

Extended PoC

This repo also includes an extended PoC which sends the Task table to an attacker controlled server.

  1. Run exhil_server.py as a FastAPI application
  2. Upload the following payload: payloads/exhil.svg
  3. Open the SVG in a new tab and observe the data being sent to the attacker controlled server

Fig 2: An example screenshot from the attacker controlled server showing incoming data
Example data sent to attacker server

Further, the repo includes a list of routes the admin panel exposes which could be used to automate table discovery and compromise in a more sophisticated PoC.

Impact

What kind of vulnerability is it? Who is impacted?

All applications with the following conditions present are affected:

Further, if the site is behind a proxy of sorts it must not set the relevant security headers.

Further thoughts

While this issue has been raised against the piccolo_admin repository, it technically exists for all file uploads within a piccolo website if an end developer chooses to include the ability to view SVG files inline within their application. Further thought should likely be given to either or both of the following:

Given the need to allow end developers the freedom to allow for SVG upload, removing the ability to upload them entirely is likely out of the picture.

This could also be resolved by making attempts to view attachments in a new tab set the relevant content-disposition header and force the browser to download the file instead of rendering it inline of the website.

What are your thoughts on the approach to take to mitigate this?

Permalink: https://github.com/advisories/GHSA-pmww-v6c9-7p83
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1wbXd3LXY2YzktN3A4M84AA6gN
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: about 1 month ago
Updated: about 1 month ago


CVSS Score: 7.7
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N

Identifiers: GHSA-pmww-v6c9-7p83, CVE-2024-30248
References: Repository: https://github.com/piccolo-orm/piccolo_admin
Blast Radius: 8.0

Affected Packages

pypi:piccolo-admin
Dependent packages: 0
Dependent repositories: 11
Downloads: 4,060 last month
Affected Version Ranges: >= 1.2.0, < 1.3.2
Fixed in: 1.3.2
All affected versions: 1.2.0, 1.2.1, 1.2.2, 1.3.0, 1.3.1
All unaffected versions: 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.10.5, 0.10.6, 0.10.7, 0.10.8, 0.10.9, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.11.6, 0.11.7, 0.11.8, 0.11.9, 0.11.10, 0.11.11, 0.11.12, 0.11.13, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.14.0, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.17.0, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 0.19.4, 0.19.5, 0.19.6, 0.20.0, 0.21.0, 0.22.0, 0.22.1, 0.22.2, 0.23.0, 0.24.0, 0.25.0, 0.26.0, 0.26.1, 0.27.0, 0.28.0, 0.29.0, 0.29.1, 0.30.0, 0.31.0, 0.31.1, 0.31.2, 0.32.0, 0.33.0, 0.33.1, 0.34.0, 0.35.0, 0.36.0, 0.37.0, 0.38.0, 0.39.0, 0.40.0, 0.41.0, 0.42.0, 0.43.0, 0.44.0, 0.45.0, 0.45.1, 0.45.2, 0.46.0, 0.47.0, 0.48.0, 0.49.0, 0.50.0, 0.51.0, 0.52.0, 0.53.0, 0.54.0, 0.55.0, 0.56.0, 0.57.0, 0.58.0, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.3.2