CVE-2026–17633 — Authenticated RCE in Langflow OSS via /api/v1/custom_component
The custom component endpoint in Langflow executed user-supplied Python code without content validation, because the only check was whether the feature was enabled. Any authenticated user could send a crafted class definition and run arbitrary commands on the server.
Published on medium.com
AI
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
## Context
Langflow is an open-source low-code platform for building LLM applications and agent workflows visually. One of its features, **Custom Components**, lets users define a component's behaviour directly in Python. That feature is the attack surface for this vulnerability.
IBM's security advisory (published August 5, 2026) disclosed a cluster of issues in Langflow OSS 1.0.0-1.10.3. CVE-2026-17633 is the authenticated RCE reachable through `/api/v1/custom_component`.
{{media:0}}
## Setup
The issue affects Langflow OSS versions 1.0.0 through 1.10.3. The endpoint requires an authenticated user. The precondition that matters is the `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` setting: in production, `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true` is a common setting, and the endpoint's gate depends on it.
## Finding it
The researcher's starting point is the endpoint handler in `langflow/api/v1/endpoints.py` (around line 1271):
```python
@router.post("/custom_component", status_code=HTTPStatus.OK, include_in_schema=False)async def custom_component( raw_code: CustomComponentRequest, user: CurrentActiveUser, request: Request,) -> CustomComponentResponse: … # The only gate: "is the custom-component feature enabled at all?" if not settings.allow_custom_components and not code_hash_matches_any_template(raw_code.code, all_known): raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, …)# scan_code_security() is never called here component = Component(_code=effective_code) built_frontend_node, component_instance = build_custom_component_template(component, user_id=user.id)
```
The important detail isn't that there's "no validation"; it's that the validation checks the wrong thing. `allow_custom_components` answers "is this user allowed to create custom components," not "is this code's content safe." Once the setting is on, this check passes trivially and the code flows through with zero content inspection. Langflow does ship a separate AST-based scanner, `scan_code_security()`, but this endpoint's execution path never calls it.
## Exploitation
### Step 1: reach the endpoint with a class body payload
`custom_component()` calls `build_custom_component_template()`, which flows into `create_class()` in `lfx/custom/validate.py`. That function calls `prepare_global_scope()`, and the submitted code is `exec()`'d shortly after:
```python
def prepare_global_scope(module): exec_globals = globals().copy() … for node in module.body: if isinstance(node, ast.Import | ast.ImportFrom): imports.append(node) elif isinstance(node, ast.ClassDef | ast.FunctionDef | ast.Assign | ast.AnnAssign): definitions.append(node) … if definitions: compiled_code = compile(combined_module, "<string>", "exec") exec(compiled_code, exec_globals) # ← exec() happens here
```
This function walks the submitted code's AST and only collects `import` statements and `class`/`def`/assignment nodes into `definitions`. That is the trap:
1. A top-level statement like `os.system(…)` is, at the AST level, an `ast.Expr` node.
2. `ast.Expr` isn't in the `isinstance` allow-list above, so it is silently dropped.
3. Code placed inside a class body, however, is part of that `ClassDef` node, so when the class is defined (that is, when `exec()` runs), that code executes right along with it.
The difference between the two placements is shown directly:
```python
# ❌ Module level - classified as ast.Expr, silently dropped by prepare_global_scope()import osos.system("id > /tmp/pwned.txt")class PocComponent(Component): …# �
Inside the class body - part of ClassDef, runs when exec() defines the classclass PocComponent(Component): os.system("id > /tmp/pwned.txt") # ← executes at class-definition time …
```
So the entire trick an attacker needs is to put the payload inside the class body, not at module level. No encoding tricks, no filter bypass gymnastics, just a design flaw.
### Step 2: send the request
The full path from request to command execution is:
```text
Authenticated user (any privilege level) │ ▼POST /api/v1/custom_component { "code": "<malicious Python class>" } │ ▼build_custom_component_template() → create_class() │ ▼prepare_global_scope() - only ClassDef nodes get collected into definitions/exec target │ ▼compile_class_code() → exec(compiled_class, exec_globals) │ ▼Class body executes at definition time → RCE achieved
```
{{media:2}}
No LLM involvement, no scanner to evade. One HTTP request is enough.
## Root cause
The mistake is in `prepare_global_scope()`. It walks the submitted code's AST and only collects `import` statements and `class`/`def`/assignment nodes into `definitions`, then compiles and `exec()`s that combined module. Top-level expression statements such as `os.system(…)` are `ast.Expr` nodes and are silently dropped, but code inside a class body is part of the `ClassDef` node and therefore executes when the class is defined during `exec()`.
The endpoint's only gate, `allow_custom_components`, answers whether the user is allowed to create custom components, not whether the code's content is safe. With `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true`, that check passes trivially and the code flows through with zero content inspection.
Langflow ships a separate AST-based scanner, `scan_code_security()`, in `langflow/agentic/helpers/code_security.py`, but it is wired only into the **Agentic Assistant path** (validating LLM-generated component code) and is never called from `/api/v1/custom_component`. CVE-2026-17633 is therefore not really a scanner bypass; it exploits a code path the scanner was never attached to. The scanner's own detection logic has a separate weakness (missing `vars()` coverage leading to a false `is_safe: True` verdict, tracked as CVE-2026-17632), which surfaced from analysing the same codebase but is a distinct issue.
## Impact
An authenticated user can achieve remote code execution through a single request to `/api/v1/custom_component`, provided the custom-component feature is enabled. The report does not describe the resulting command output or any further post-exploitation steps.
## Fix
1. Upgrade to Langflow 1.10.4+, which adds content validation to the `custom_component` endpoint.
2. Keep `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` set to `false` in production unless the feature is genuinely needed.
3. If custom components must be enabled, restrict which accounts can reach that feature.
4. Audit the group permissions of the container's runtime user (`gid=0` membership) to reduce lateral-movement and container-escape surface.
## Variants to test
1. **Class-body payloads against other AST-filtered exec paths.** Wherever an application collects only `ClassDef`/`FunctionDef`/assignment nodes before `exec()`, place the payload inside a class body rather than at module level. A positive result is command execution at class-definition time, for example the file written by `os.system("id > /tmp/pwned.txt")`.
2. **Check whether the security scanner is actually wired in.** For each endpoint that accepts code, trace whether the scanner function is called on that path. A positive result is an endpoint that reaches `exec()` without invoking the scanner.
3. **Feature-flag gates that check permission rather than content.** Look for settings such as `allow_custom_components` that gate on whether a user may use a feature rather than on what the submitted content does. A positive result is a flag that, once enabled, lets arbitrary code through with no content inspection.
4. **Container runtime user group membership.** Check whether the runtime user is a member of `gid=0`. A positive result widens lateral-movement and container-escape options after code execution.## What happened, in plain words
Langflow is a free, open-source tool that lets people build applications powered by large language models (LLMs, the kind of software behind chatbots) by dragging blocks around on a screen instead of writing lots of code. It is a "low-code" platform: you do a little coding, and the tool does the rest.
One of its blocks is called a **Custom Component**. It lets a user type Python code directly into the tool and have that code become part of their application. Python is a popular programming language; code is the set of instructions a computer follows.
That feature is the weak point. A security researcher found that a logged-in user could send a specially shaped piece of Python code to one of Langflow's web addresses, and the server would run it. Running someone else's code on your server is called **remote code execution**, or RCE. It is one of the most serious kinds of security bug, because the attacker's code runs with the server's own powers.
The bug is tracked as **CVE-2026-17633**. A CVE is a public catalogue number given to a known security flaw so people can look it up and talk about it unambiguously. IBM published a security advisory about a group of issues in Langflow on August 5, 2026, and this CVE is one of them.
The word **authenticated** in the title matters: the attacker has to be logged in.
{{media:0}}
## The product and the feature
Langflow OSS is the open-source edition. The affected versions are 1.0.0 through 1.10.3.
A **component** in Langflow is one building block of a workflow: something that reads a document, calls a model, formats an answer. Normally you pick components from a menu. The Custom Component feature lets you write your own in Python instead, and the platform will load and run it.
To understand the bug you need one more idea: an **API**. An API is the set of web addresses a program offers so other programs can talk to it. When you use a website in a browser, your browser is quietly sending requests to addresses like `/api/v1/...` and getting answers back. Langflow has an API too, and one of its addresses is `/api/v1/custom_component`. That address is where a user submits their custom Python code.
## The setting that opens the door
The endpoint (the web address that accepts requests) only works if a configuration switch called `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` is turned on. Configuration switches like this are often called **feature flags**: a named on/off setting that changes how the software behaves.
In real deployments, `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true` is a common setting, because people want the feature. Once it is on, the endpoint's gate passes, and the submitted code is accepted without anyone looking at what the code actually does.
## Finding it: the endpoint's code
The researcher started by reading the source code of the endpoint, in the file `langflow/api/v1/endpoints.py`, around line 1271:
```python
@router.post("/custom_component", status_code=HTTPStatus.OK, include_in_schema=False)async def custom_component( raw_code: CustomComponentRequest, user: CurrentActiveUser, request: Request,) -> CustomComponentResponse: … # The only gate: "is the custom-component feature enabled at all?" if not settings.allow_custom_components and not code_hash_matches_any_template(raw_code.code, all_known): raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, …)# scan_code_security() is never called here component = Component(_code=effective_code) built_frontend_node, component_instance = build_custom_component_template(component, user_id=user.id)
```
Line by line, in plain words:
- `@router.post("/custom_component", ...)` says: this function handles requests sent to the address `/custom_component` using the POST method. POST is the HTTP method browsers and programs use when they are sending data to a server, as opposed to just asking for a page.
- `async def custom_component(...)` is the function itself. It receives three things: `raw_code` (the code the user submitted), `user` (who is logged in) and `request` (the raw incoming request).
- The comment `# The only gate: "is the custom-component feature enabled at all?"` is the researcher's own note pointing at the heart of the problem.
- The `if not settings.allow_custom_components and not code_hash_matches_any_template(...)` line is the gate. It asks two things: is the feature switched off, and does the submitted code fail to match a known built-in template? If both are true, it raises an error (`HTTPException` with status `403`, which means "forbidden"). In other words, the check is about whether the feature is enabled, not about whether the code is safe.
- The comment `# scan_code_security() is never called here` records that Langflow does have a security scanner, but this endpoint never uses it.
- The last two lines build the component from the submitted code and hand it to `build_custom_component_template()`, which is where the code will eventually be run.
The key insight is not that there is no check at all. There is a check, but it answers the wrong question. `allow_custom_components` asks "is this user allowed to use custom components?" It does not ask "is this code's content safe?" A comparison: a nightclub bouncer who only checks that you have a ticket, and never looks in your bag. The ticket check is real, but it does not stop anything dangerous getting inside.
Langflow does ship a separate scanner, `scan_code_security()`, which reads code and looks for dangerous patterns. But the path this endpoint takes never calls it.
## Exploitation, step 1: how the code gets run
When the endpoint accepts the code, it calls `build_custom_component_template()`, which leads to `create_class()` in the file `lfx/custom/validate.py`. That function calls `prepare_global_scope()`, and shortly afterwards the submitted code is run with Python's `exec()` function. `exec()` is a built-in Python function that takes a piece of code as text and executes it. It is powerful and dangerous when the text comes from someone else.
Here is `prepare_global_scope()`:
```python
def prepare_global_scope(module): exec_globals = globals().copy() … for node in module.body: if isinstance(node, ast.Import | ast.ImportFrom): imports.append(node) elif isinstance(node, ast.ClassDef | ast.FunctionDef | ast.Assign | ast.AnnAssign): definitions.append(node) … if definitions: compiled_code = compile(combined_module, "<string>", "exec") exec(compiled_code, exec_globals) # ← exec() happens here
```
Line by line:
- `def prepare_global_scope(module):` defines a function that takes the submitted code, already parsed into a tree structure called `module`.
- `exec_globals = globals().copy()` makes a copy of the current global variables, the shared workspace the code will run in.
- The `for node in module.body:` loop walks through the top-level pieces of the submitted code one by one. Each piece is called a **node**.
- `if isinstance(node, ast.Import | ast.ImportFrom):` checks whether the piece is an `import` statement, the Python instruction that brings in another library (a bundle of ready-made code). If so, it is kept in a list called `imports`.
- `elif isinstance(node, ast.ClassDef | ast.FunctionDef | ast.Assign | ast.AnnAssign):` checks whether the piece is a class definition, a function definition, or an assignment (setting a variable to a value). If so, it is kept in a list called `definitions`.
- Anything that is none of those is simply not added to either list. It is dropped without a word.
- `if definitions:` then compiles the collected pieces and runs them with `exec(compiled_code, exec_globals)`. The arrow comment marks the exact moment the code executes.
To follow the trap you need two ideas. First, **AST**: when Python reads code, it first turns it into a tree that describes its structure, the Abstract Syntax Tree. Each kind of statement becomes a particular type of node. Second, **class**: a class is a template in Python for creating objects, and it can contain code in its body. When Python defines a class, it runs the code written inside that class body.
Now the trap, in three steps:
1. A top-level statement such as `os.system(...)` (a call that runs a system command) is, in the tree, an `ast.Expr` node, meaning an expression.
2. `ast.Expr` is not in the list of node types the function keeps, so it is silently dropped. It never runs.
3. Code placed inside a class body, however, is part of the `ClassDef` node. That node is kept, so when the class is defined during `exec()`, the code inside the class body runs too.
The difference between the two placements is shown directly:
```python
# ❌ Module level - classified as ast.Expr, silently dropped by prepare_global_scope()import osos.system("id > /tmp/pwned.txt")class PocComponent(Component): …# �
Inside the class body - part of ClassDef, runs when exec() defines the classclass PocComponent(Component): os.system("id > /tmp/pwned.txt") # ← executes at class-definition time …
```
Line by line:
- The first comment marks the module-level version as failing. "Module level" means code written at the top of the file, outside any class or function.
- `import os` brings in Python's `os` library, which lets code talk to the operating system.
- `os.system("id > /tmp/pwned.txt")` asks the operating system to run the command `id`, which prints who the current user is, and to write the output into the file `/tmp/pwned.txt`. Writing a file is a simple, visible proof that a command really ran.
- `class PocComponent(Component): …` starts a class. At module level, the `os.system` line above it is an expression and gets dropped, so nothing happens.
- The second comment marks the class-body version as working.
- Inside `class PocComponent(Component):`, the same `os.system("id > /tmp/pwned.txt")` line now sits in the class body. It is part of the class definition, so it runs the moment the class is defined.
So the whole trick is to put the payload inside the class body rather than at module level. No clever encoding, no dodging filters. Just a design flaw. A comparison: a security guard who only inspects the boxes in the hallway and ignores anything packed inside a labelled crate. Put your item in the crate and it sails through.
## Exploitation, step 2: sending the request
The full path from request to command execution is:
```text
Authenticated user (any privilege level) │ ▼POST /api/v1/custom_component { "code": "<malicious Python class>" } │ ▼build_custom_component_template() → create_class() │ ▼prepare_global_scope() - only ClassDef nodes get collected into definitions/exec target │ ▼compile_class_code() → exec(compiled_class, exec_globals) │ ▼Class body executes at definition time → RCE achieved
```
Read it top to bottom:
- An authenticated user, at any privilege level, starts the chain.
- They send a POST request to `/api/v1/custom_component` whose body is JSON (a common text format for structured data) containing a `code` field with a malicious Python class.
- The server calls `build_custom_component_template()`, which calls `create_class()`.
- That reaches `prepare_global_scope()`, where only class definitions are collected into the list that will be executed.
- The collected code is compiled and passed to `exec()`.
- The class body runs at the moment the class is defined, and code execution is achieved.
{{media:2}}
No LLM is involved, and there is no scanner to evade. One HTTP request is enough. An HTTP request is simply a message a browser or program sends to a server over the web; you make them every time you load a page.
## Root cause, restated
The mistake is in `prepare_global_scope()`. It walks the submitted code's tree and keeps only imports, class definitions, function definitions and assignments, then compiles and runs that combined set. Top-level expressions such as `os.system(...)` are dropped, but code inside a class body travels along with the class and runs when the class is defined.
The endpoint's only gate, `allow_custom_components`, answers whether the user may create custom components, not whether the code is safe. With `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true`, that check passes trivially and the code flows through with no content inspection.
Langflow ships a separate scanner, `scan_code_security()`, in `langflow/agentic/helpers/code_security.py`, but it is wired only into the Agentic Assistant path, the part of the product that validates code generated by an LLM. It is never called from `/api/v1/custom_component`. So this CVE is not really a scanner bypass: it exploits a code path the scanner was never attached to. The scanner's own detection logic has a separate weakness, missing coverage of `vars()` leading to a false `is_safe: True` verdict, tracked as CVE-2026-17632. That surfaced from analysing the same codebase but is a distinct issue.
## Impact
An authenticated user can achieve remote code execution through a single request to `/api/v1/custom_component`, provided the custom-component feature is enabled. The report does not describe the resulting command output or any further post-exploitation steps.
## Fix
1. Upgrade to Langflow 1.10.4 or later, which adds content validation to the `custom_component` endpoint.
2. Keep `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` set to `false` in production unless the feature is genuinely needed.
3. If custom components must be enabled, restrict which accounts can reach that feature.
4. Audit the group permissions of the container's runtime user (`gid=0` membership) to reduce lateral-movement and container-escape surface. A container is a lightweight, isolated environment an application often runs inside; `gid=0` means membership of the root group, which grants broad permissions and makes it easier for an attacker to move around or break out.
## Variants to test
1. **Class-body payloads against other AST-filtered exec paths.** Wherever an application collects only class, function and assignment nodes before `exec()`, place the payload inside a class body rather than at module level. A positive result is command execution at class-definition time, for example the file written by `os.system("id > /tmp/pwned.txt")`.
2. **Check whether the security scanner is actually wired in.** For each endpoint that accepts code, trace whether the scanner function is called on that path. A positive result is an endpoint that reaches `exec()` without invoking the scanner.
3. **Feature-flag gates that check permission rather than content.** Look for settings such as `allow_custom_components` that gate on whether a user may use a feature rather than on what the submitted content does. A positive result is a flag that, once enabled, lets arbitrary code through with no content inspection.
4. **Container runtime user group membership.** Check whether the runtime user is a member of `gid=0`. A positive result widens lateral-movement and container-escape options after code execution.
## Glossary
- **API**: the set of web addresses a program offers so other programs can talk to it.
- **AST (Abstract Syntax Tree)**: the tree structure Python builds from code before running it, describing each statement's type.
- **Authenticated**: having logged in with a valid account.
- **Class**: a Python template for creating objects; code in its body runs when the class is defined.
- **Component**: a building block of a Langflow workflow.
- **Container**: a lightweight, isolated environment an application runs inside.
- **CVE**: a public catalogue number for a known security flaw.
- **Custom Component**: a Langflow feature that lets users write their own component in Python.
- **Endpoint**: a specific web address that accepts requests.
- **exec()**: a Python function that runs code supplied as text.
- **Feature flag**: a named on/off configuration setting that changes software behaviour.
- **gid=0**: membership of the root group, which grants broad permissions.
- **HTTP request**: a message a browser or program sends to a server over the web.
- **JSON**: a common text format for structured data.
- **LLM**: a large language model, the kind of software behind chatbots.
- **Low-code**: a way of building software with visual tools and a little code.
- **Module level**: code written at the top of a file, outside any class or function.
- **Node**: one piece of the AST.
- **Payload**: the piece of code an attacker wants the target to run.
- **POST**: the HTTP method used to send data to a server.
- **Python**: a popular programming language.
- **RCE (remote code execution)**: running an attacker's code on a server.
- **Scanner**: a tool that reads code and looks for dangerous patterns.
- **Vulnerability**: a weakness in software that an attacker can exploit.