rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/http/zyxel_parse_config_rce.rb

Summary

Maintainability
C
1 day
Test Coverage

Consider simplifying this complex logical expression.
Open

        if (product.starts_with?('USG') && product.include?('W') && Rex::Version.new(version) <= Rex::Version.new('5.36.2') && Rex::Version.new(version) >= Rex::Version.new('5.10')) ||
           (product.starts_with?('USG') && !product.include?('W') && Rex::Version.new(version) <= Rex::Version.new('5.36.2') && Rex::Version.new(version) >= Rex::Version.new('5.00')) ||
           (product.starts_with?('ATP') && Rex::Version.new(version) <= Rex::Version.new('5.36.2') && Rex::Version.new(version) >= Rex::Version.new('5.10')) ||
           (product.starts_with?('VPN') && Rex::Version.new(version) <= Rex::Version.new('5.36.2') && Rex::Version.new(version) >= Rex::Version.new('5.00'))
          return CheckCode::Appears("Product: #{product}, Version: #{version}")
Severity: Critical
Found in modules/exploits/linux/http/zyxel_parse_config_rce.rb - About 3 hrs to fix

    Method exploit has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def exploit
        # Command injection has a 0x14 byte length limit so keep the file name as small as possible.
        # The length limit is also why we leverage the arbitrary file write -> write our payload to the .qrs file then execute it with the command injection.
        filename = rand_text_alpha(1)
        payload_filepath = "#{datastore['WRITABLE_DIR']}/#{filename}.qsr"
    Severity: Major
    Found in modules/exploits/linux/http/zyxel_parse_config_rce.rb - About 2 hrs to fix

      Method check has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def check
          res = send_request_cgi({
            'method' => 'GET',
            'uri' => normalize_uri(target_uri.path, 'ext-js', 'app', 'common', 'zld_product_spec.js')
          })
      Severity: Minor
      Found in modules/exploits/linux/http/zyxel_parse_config_rce.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Zyxel parse_config.py Command Injection',
      Severity: Minor
      Found in modules/exploits/linux/http/zyxel_parse_config_rce.rb - About 1 hr to fix

        Method exploit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def exploit
            # Command injection has a 0x14 byte length limit so keep the file name as small as possible.
            # The length limit is also why we leverage the arbitrary file write -> write our payload to the .qrs file then execute it with the command injection.
            filename = rand_text_alpha(1)
            payload_filepath = "#{datastore['WRITABLE_DIR']}/#{filename}.qsr"
        Severity: Minor
        Found in modules/exploits/linux/http/zyxel_parse_config_rce.rb - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        There are no issues that match your filters.

        Category
        Status