CVE-2024-30248: Piccolo admin Piccolo Admin's Raw SVG Loading Vulnerability

HIGH
Advisory Identifier: GHSA-pmww-v6c9-7p83
CVSS 7.7
CWE-79
Published
Advisory Summary

CVE-2024-30248 is a HIGH (CVSS 7.7) piccolo admin's raw svg loading vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Piccolo admin libraries in the PyPI ecosystem. The issue involves piccolo admin's raw svg loading may lead to complete data compromise from admin page. Remediation is available by upgrading affected packages to version 1.3.2.

CVE-2024-30248 at a Glance

CVE Identifier CVE-2024-30248
GHSA Identifier GHSA-pmww-v6c9-7p83
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Piccolo admin
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2024-30248

To remediate this vulnerability, upgrade all affected Piccolo admin dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

piccolo-admin fixed: 1.3.2
pip install piccolo-admin>=1.3.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show piccolo-admin

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-30248, inspect your installed packages using pip:

pip show piccolo-admin

Analyze the terminal output to locate any version of Piccolo admin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.2), your application is affected.

Note: The pip show piccolo-admin command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Piccolo admin, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: - The ability for an attacker to gain access to all data stored within the admin page - The ability for an attacker to make any action within the admin page such as creating, modifying or deleting table records 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](https://github.com/Skelmis/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](https://user-images.githubusercontent.com/47520067/300751626-ba09c524-ffd8-43b8-963e-9bc6803e3388.png) ##### 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](https://user-images.githubusercontent.com/47520067/300746553-9895217b-b509-4e03-b3bc-9ae730450e32.png) 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: - An enabled admin panel - A model which features media upload that allows for SVG files 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: - Ensuring the documentation for media handling includes some form of warning/recommendation relating to this. Ideally I think it should just provide an example of a code fix and link to security headers to test their own application - Modifying the Piccolo template generation to include the relevant security headers by default. These include things such as xss protection and a content security policy. [This](https://securityheaders.com/) site is a great resource for testing the security headers set on a website 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?

CVE-2024-30248 Affected Piccolo admin Versions

1 component(s)
Fixed Versions:
1.3.2
Product / Package Ecosystem Affected Versions Fixed Version
piccolo-admin
PyPI
≥ 1.2.0
< 1.3.2
1.3.2

References

Frequently Asked Questions

What is CVE-2024-30248?
CVE-2024-30248 is a security vulnerability in Piccolo admin involving Piccolo Admin's raw SVG loading may lead to complete data compromise from admin page under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Piccolo admin versions are affected?
Affected versions include releases prior to 1.3.2 across affected packages: piccolo-admin.
What version fixes CVE-2024-30248?
Upgrading to 1.3.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is piccolo-admin affected?
Yes, piccolo-admin is affected in releases prior to 1.3.2. Upgrade your dependency to 1.3.2 or later.
What is the CVSS score of CVE-2024-30248?
CVE-2024-30248 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2024-30248?
CVE-2024-30248 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check PyPI dependencies for CVE-2024-30248?
Run the dependency tree command: 'pip show piccolo-admin'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pmww-v6c9-7p83",
  "modified" : "2024-04-02T18:53:44Z",
  "published" : "2024-04-01T15:49:22Z",
  "aliases" : [ "CVE-2024-30248" ],
  "summary" : "Piccolo Admin's raw SVG loading may lead to complete data compromise from admin page",
  "details" : "### Summary\n\nPiccolo'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. \n\nThis access allows the following actions for example:\n- The ability for an attacker to gain access to all data stored within the admin page\n- The ability for an attacker to make any action within the admin page such as creating, modifying or deleting table records\n\nAs 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\n*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*\n\n### PoC\n_Complete instructions, including specific configuration details, to reproduce the vulnerability._\n\nCurrently, 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. \n\nSee the following repository: [Piccolo XSS](https://github.com/Skelmis/piccolo_xss)\n\n1. Clone the repo\n2. Run all migrations & create an admin user\n3. Run `app.py` as a FastAPI application\n4. Login to the admin page\n5. Create a new task and upload the following file to see basic execution: `payloads/basic_xss.svg`\n6. Click the SVG to view it inline \n7. Click \"Open image in new tab\"\n8. Observe the XSS triggering\n\n\n*Fig 1: An example XSS payload executing*\n![Example XSS](https://user-images.githubusercontent.com/47520067/300751626-ba09c524-ffd8-43b8-963e-9bc6803e3388.png)\n\n\n##### Extended PoC\n\nThis repo also includes an extended PoC which sends the `Task` table to an attacker controlled server.\n\n1. Run `exhil_server.py` as a FastAPI application\n2. Upload the following payload: `payloads/exhil.svg`\n3. Open the SVG in a new tab and observe the data being sent to the attacker controlled server\n\n*Fig 2: An example screenshot from the attacker controlled server showing incoming data*\n![Example data sent to attacker server](https://user-images.githubusercontent.com/47520067/300746553-9895217b-b509-4e03-b3bc-9ae730450e32.png)\n\nFurther, 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.\n\n### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nAll applications with the following conditions present are affected:\n- An enabled admin panel\n- A model which features media upload that allows for SVG files\n\nFurther, if the site is behind a proxy of sorts it must not set the relevant security headers.\n\n### Further thoughts\n\nWhile 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:\n- Ensuring the documentation for media handling includes some form of warning/recommendation relating to this. Ideally I think it should just provide an example of a code fix and link to security headers to test their own application\n- Modifying the Piccolo template generation to include the relevant security headers by default. These include things such as xss protection and a content security policy. [This](https://securityheaders.com/) site is a great resource for testing the security headers set on a website\n\nGiven 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. \n\nThis 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.\n\nWhat are your thoughts on the approach to take to mitigate this?",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "piccolo-admin"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.2.0"
      }, {
        "fixed" : "1.3.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/piccolo-orm/piccolo_admin/security/advisories/GHSA-pmww-v6c9-7p83"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-30248"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/piccolo-orm/piccolo_admin/commit/c419575c2467959d906154084d305648eb2b8faf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/piccolo-orm/piccolo_admin"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-01T15:49:22Z",
    "nvd_published_at" : "2024-04-02T15:15:53Z"
  }
}