Skip to content

Arbitrary File Upload via MIME Spoofing in FlowiseAI/Flowise

High
igor-magun-wd published GHSA-j8g8-j7fc-43v6 Mar 5, 2026

Package

npm flowise (npm)

Affected versions

< =3.0.12

Patched versions

3.0.13

Description

Vulnerability Description


Vulnerability Overview

  • The /api/v1/attachments/:chatflowId/:chatId endpoint is listed in WHITELIST_URLS, allowing unauthenticated access to the file upload API.
  • While the server validates uploads based on the MIME types defined in chatbotConfig.fullFileUpload.allowedUploadFileTypes, it implicitly trusts the client-provided Content-Type header (file.mimetype) without verifying the file's actual content (magic bytes) or extension (file.originalname).
  • Consequently, an attacker can bypass this restriction by spoofing the Content-Type as a permitted type (e.g., application/pdf) while uploading malicious scripts or arbitrary files. Once uploaded via addArrayFilesToStorage, these files persist in backend storage (S3, GCS, or local disk). This vulnerability serves as a critical entry point that, when chained with other features like static hosting or file retrieval, can lead to Stored XSS, malicious file hosting, or Remote Code Execution (RCE).

Vulnerable Code

  • Upload Route Definition

    // CREATE
    router.post('/:chatflowId/:chatId', getMulterStorage().array('files'), attachmentsController.createAttachment)
    export default router

    // CREATE
    router.post('/:chatflowId/:chatId', getMulterStorage().array('files'), attachmentsController.createAttachment)
    export default router
  • Mount /api/v1/attachments to the global router

    const router = express.Router()
    router.use('/ping', pingRouter)
    router.use('/apikey', apikeyRouter)
    router.use('/assistants', assistantsRouter)
    router.use('/attachments', attachmentsRouter)

    const router = express.Router()
    router.use('/ping', pingRouter)
    router.use('/apikey', apikeyRouter)
    router.use('/assistants', assistantsRouter)
    router.use('/attachments', attachmentsRouter)
  • Include /api/v1/attachments in the WHITELIST_URLS list

    export const WHITELIST_URLS = [
    '/api/v1/verify/apikey/',
    '/api/v1/chatflows/apikey/',
    '/api/v1/public-chatflows',
    '/api/v1/public-chatbotConfig',
    '/api/v1/public-executions',
    '/api/v1/prediction/',
    '/api/v1/vector/upsert/',
    '/api/v1/node-icon/',
    '/api/v1/components-credentials-icon/',
    '/api/v1/chatflows-streaming',
    '/api/v1/chatflows-uploads',
    '/api/v1/openai-assistants-file/download',
    '/api/v1/feedback',
    '/api/v1/leads',
    '/api/v1/get-upload-file',
    '/api/v1/ip',
    '/api/v1/ping',
    '/api/v1/version',
    '/api/v1/attachments',
    '/api/v1/metrics',

    export const WHITELIST_URLS = [
        '/api/v1/verify/apikey/',
        '/api/v1/chatflows/apikey/',
        '/api/v1/public-chatflows',
        '/api/v1/public-chatbotConfig',
        '/api/v1/public-executions',
        '/api/v1/prediction/',
        '/api/v1/vector/upsert/',
        '/api/v1/node-icon/',
        '/api/v1/components-credentials-icon/',
        '/api/v1/chatflows-streaming',
        '/api/v1/chatflows-uploads',
        '/api/v1/openai-assistants-file/download',
        '/api/v1/feedback',
        '/api/v1/leads',
        '/api/v1/get-upload-file',
        '/api/v1/ip',
        '/api/v1/ping',
        '/api/v1/version',
        '/api/v1/attachments',
        '/api/v1/metrics',
  • Bypass JWT validation if the URL is whitelisted

    const denylistURLs = process.env.DENYLIST_URLS ? process.env.DENYLIST_URLS.split(',') : []
    const whitelistURLs = WHITELIST_URLS.filter((url) => !denylistURLs.includes(url))
    const URL_CASE_INSENSITIVE_REGEX: RegExp = /\/api\/v1\//i
    const URL_CASE_SENSITIVE_REGEX: RegExp = /\/api\/v1\//
    await initializeJwtCookieMiddleware(this.app, this.identityManager)
    this.app.use(async (req, res, next) => {
    // Step 1: Check if the req path contains /api/v1 regardless of case
    if (URL_CASE_INSENSITIVE_REGEX.test(req.path)) {
    // Step 2: Check if the req path is casesensitive
    if (URL_CASE_SENSITIVE_REGEX.test(req.path)) {
    // Step 3: Check if the req path is in the whitelist
    const isWhitelisted = whitelistURLs.some((url) => req.path.startsWith(url))
    if (isWhitelisted) {
    next()

            const denylistURLs = process.env.DENYLIST_URLS ? process.env.DENYLIST_URLS.split(',') : []
            const whitelistURLs = WHITELIST_URLS.filter((url) => !denylistURLs.includes(url))
            const URL_CASE_INSENSITIVE_REGEX: RegExp = /\/api\/v1\//i
            const URL_CASE_SENSITIVE_REGEX: RegExp = /\/api\/v1\//
    
            await initializeJwtCookieMiddleware(this.app, this.identityManager)
    
            this.app.use(async (req, res, next) => {
                // Step 1: Check if the req path contains /api/v1 regardless of case
                if (URL_CASE_INSENSITIVE_REGEX.test(req.path)) {
                    // Step 2: Check if the req path is casesensitive
                    if (URL_CASE_SENSITIVE_REGEX.test(req.path)) {
                        // Step 3: Check if the req path is in the whitelist
                        const isWhitelisted = whitelistURLs.some((url) => req.path.startsWith(url))
                        if (isWhitelisted) {
                            next()
  • Multer Configuration: Saves files without file type validation

    export const getUploadPath = (): string => {
    return process.env.BLOB_STORAGE_PATH
    ? path.join(process.env.BLOB_STORAGE_PATH, 'uploads')
    : path.join(getUserHome(), '.flowise', 'uploads')
    }
    export function generateId() {
    return uuidv4()
    }
    export const getMulterStorage = () => {
    const storageType = process.env.STORAGE_TYPE ? process.env.STORAGE_TYPE : 'local'
    if (storageType === 's3') {
    const s3Client = getS3Config().s3Client
    const Bucket = getS3Config().Bucket
    const upload = multer({
    storage: multerS3({
    s3: s3Client,
    bucket: Bucket,
    metadata: function (req, file, cb) {
    cb(null, { fieldName: file.fieldname, originalName: file.originalname })
    },
    key: function (req, file, cb) {
    cb(null, `${generateId()}`)
    }
    })
    })
    return upload
    } else if (storageType === 'gcs') {
    return multer({
    storage: new MulterGoogleCloudStorage({
    projectId: process.env.GOOGLE_CLOUD_STORAGE_PROJ_ID,
    bucket: process.env.GOOGLE_CLOUD_STORAGE_BUCKET_NAME,
    keyFilename: process.env.GOOGLE_CLOUD_STORAGE_CREDENTIAL,
    uniformBucketLevelAccess: Boolean(process.env.GOOGLE_CLOUD_UNIFORM_BUCKET_ACCESS) ?? true,
    destination: `uploads/${generateId()}`
    })
    })
    } else {
    return multer({ dest: getUploadPath() })
    }
    }

    export const getUploadPath = (): string => {
        return process.env.BLOB_STORAGE_PATH
            ? path.join(process.env.BLOB_STORAGE_PATH, 'uploads')
            : path.join(getUserHome(), '.flowise', 'uploads')
    }
    
    export function generateId() {
        return uuidv4()
    }
    
    export const getMulterStorage = () => {
        const storageType = process.env.STORAGE_TYPE ? process.env.STORAGE_TYPE : 'local'
    
        if (storageType === 's3') {
            const s3Client = getS3Config().s3Client
            const Bucket = getS3Config().Bucket
    
            const upload = multer({
                storage: multerS3({
                    s3: s3Client,
                    bucket: Bucket,
                    metadata: function (req, file, cb) {
                        cb(null, { fieldName: file.fieldname, originalName: file.originalname })
                    },
                    key: function (req, file, cb) {
                        cb(null, `${generateId()}`)
                    }
                })
            })
            return upload
        } else if (storageType === 'gcs') {
            return multer({
                storage: new MulterGoogleCloudStorage({
                    projectId: process.env.GOOGLE_CLOUD_STORAGE_PROJ_ID,
                    bucket: process.env.GOOGLE_CLOUD_STORAGE_BUCKET_NAME,
                    keyFilename: process.env.GOOGLE_CLOUD_STORAGE_CREDENTIAL,
                    uniformBucketLevelAccess: Boolean(process.env.GOOGLE_CLOUD_UNIFORM_BUCKET_ACCESS) ?? true,
                    destination: `uploads/${generateId()}`
                })
            })
        } else {
            return multer({ dest: getUploadPath() })
        }
    }
  • Transfers uploaded files to storage without verification

    const files = (req.files as Express.Multer.File[]) || []
    const fileAttachments = []
    if (files.length) {
    const isBase64 = req.body.base64
    for (const file of files) {
    if (!allowedFileTypes.length) {
    throw new InternalFlowiseError(
    StatusCodes.BAD_REQUEST,
    `File type '${file.mimetype}' is not allowed. Allowed types: ${allowedFileTypes.join(', ')}`
    )
    }
    // Validate file type against allowed types
    if (allowedFileTypes.length > 0 && !allowedFileTypes.includes(file.mimetype)) {
    throw new InternalFlowiseError(
    StatusCodes.BAD_REQUEST,
    `File type '${file.mimetype}' is not allowed. Allowed types: ${allowedFileTypes.join(', ')}`
    )
    }
    await checkStorage(orgId, subscriptionId, appServer.usageCacheManager)
    const fileBuffer = await getFileFromUpload(file.path ?? file.key)
    const fileNames: string[] = []
    // Address file name with special characters: https://github.com/expressjs/multer/issues/1104
    file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
    const { path: storagePath, totalSize } = await addArrayFilesToStorage(
    file.mimetype,
    fileBuffer,
    file.originalname,
    fileNames,
    orgId,
    chatflowid,
    chatId
    )

        const files = (req.files as Express.Multer.File[]) || []
        const fileAttachments = []
        if (files.length) {
            const isBase64 = req.body.base64
            for (const file of files) {
                if (!allowedFileTypes.length) {
                    throw new InternalFlowiseError(
                        StatusCodes.BAD_REQUEST,
                        `File type '${file.mimetype}' is not allowed. Allowed types: ${allowedFileTypes.join(', ')}`
                    )
                }
    
                // Validate file type against allowed types
                if (allowedFileTypes.length > 0 && !allowedFileTypes.includes(file.mimetype)) {
                    throw new InternalFlowiseError(
                        StatusCodes.BAD_REQUEST,
                        `File type '${file.mimetype}' is not allowed. Allowed types: ${allowedFileTypes.join(', ')}`
                    )
                }
    
                await checkStorage(orgId, subscriptionId, appServer.usageCacheManager)
    
                const fileBuffer = await getFileFromUpload(file.path ?? file.key)
                const fileNames: string[] = []
                // Address file name with special characters: https://github.com/expressjs/multer/issues/1104
                file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
                const { path: storagePath, totalSize } = await addArrayFilesToStorage(
                    file.mimetype,
                    fileBuffer,
                    file.originalname,
                    fileNames,
                    orgId,
                    chatflowid,
                    chatId
                )

PoC


PoC Description

  • Create a local file named shell.js containing arbitrary JavaScript code (or a malicious payload).
  • Send a multipart/form-data request to the /api/v1/attachments/891f64a2-a26f-4169-b333-905dc96c200a/:chatId endpoint without any authentication (login, session, or API keys).
  • During the upload, retain the filename as shell.js but spoof the Content-Type header as application/pdf.
  • This exploits the server's reliance solely on the client-provided file.mimetype, forcing it to process the malicious JS file as an allowed PDF, thereby confirming unauthenticated arbitrary file upload.

PoC

curl -X POST \
  "http://localhost:3000/api/v1/attachments/891f64a2-a26f-4169-b333-905dc96c200a/$(uuidgen)" \
  -F "files=@shell.js;type=application/pdf"
image

Impact


1. Root Cause
The vulnerability stems from relying solely on the MIME type without cross-validating the file extension or actual content. This allows attackers to upload executable files (e.g., .js, .php) or malicious scripts (.html) by masquerading them as benign images or documents.

2. Key Attack Scenarios

  • Server Compromise (RCE): An attacker uploads a Web Shell and triggers its execution on the server. Successful exploitation grants system privileges, allowing unauthorized access to internal data and full control over the server.
  • Client-Side Attack (Stored XSS): An attacker uploads files containing malicious scripts (e.g., HTML, SVG). When a victim views the file, the script executes within their browser, leading to session cookie theft and account takeover.

3. Impact
This vulnerability is rated as High severity. The risk is particularly critical if the system utilizes shared storage (e.g., S3, GCS) or static hosting features, as the compromise could spread to the entire infrastructure and affect other tenants.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity High
Attack Requirements Present
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity High
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N

CVE ID

CVE-2026-30821

Weaknesses

Unrestricted Upload of File with Dangerous Type

The product allows the upload or transfer of dangerous file types that are automatically processed within its environment. Learn more on MITRE.

Credits