Web Command Injection Vulnerability Detection Method for Cisco IOS-XE
By extracting API information from the front-end and back-end, combining the characteristics of command injection vulnerabilities to generate initial seeds and optimizing mutation rules, the problem of low efficiency and easy omission of Web command injection vulnerabilities in the IOS-XE system is solved, and multiple commands are detected Injecting vulnerabilities, including undisclosed vulnerabilities, improves system security.
Patent Information
- Application Number
- CN202210392201.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-04-14
AI Technical Summary
Existing technology is difficult to effectively detect Web command injection vulnerabilities in Cisco IOS-XE systems, especially in the absence of feedback information, strict parameter formats, and hidden APIs, resulting in low fuzz testing efficiency and easy false negatives.
A Web command injection vulnerability detection method for Cisco IOS-XE is proposed. By extracting API information from front-end Web requests and back-end Lua programs, combined with command injection vulnerability characteristics to generate initial seeds, parameter attribute marking and mutation rule optimization are performed, and simulation Request and monitor the status of routing devices, use the CLI Command API to determine the existence of vulnerabilities and restore the test environment.
The vulnerability detection capability of fuzz testing was improved, the test scope was narrowed, the code coverage was improved, 11 command injection vulnerabilities were detected, 2 of which were undisclosed vulnerabilities, and the security of the IOS-XE system web management service was enhanced.
Smart Images

Figure CN114780398B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of vulnerability detection, and in particular relates to a Web command injection vulnerability detection method for Cisco IOS-XE. Background Art
[0002] Code injection is a common security vulnerability in Web applications and one of the main threats to network security. It ranks third among the top ten network security threats released by OWASP in 2021. Command injection is an attacker taking advantage of the improper processing of untrusted data by the application to insert maliciously constructed system commands into the input, resulting in unplanned execution behavior, causing denial of service (DoS) or permission escape, etc. Command injection vulnerabilities exist not only in Web applications hosted on servers, but also in Web management services of network core devices and IoT devices.
[0003] Cisco IOS-XE (IOS-XE for short) is one of Cisco's new operating systems (IOS-XE, IOS-XR and NX-OS), which is widely used in Cisco enterprise switches, aggregation service routers, branch routers, industrial routers, Ethernet switches, wireless LAN controllers and cloud virtual routers. Among them, the Web UI, as an interactive interface for users to view routing device information and modify device configurations, also has command injection vulnerabilities. Attackers can exploit these security vulnerabilities to achieve privilege escape. Users who log in with Read-Only privileges can be upgraded to administrator privileges, thereby obtaining sensitive data information or tampering with the configuration of routing devices. Attackers can even achieve a higher level of escape, enter the Linux system at the bottom of the device, and execute arbitrary commands with root privileges, such as reading or tampering with system files, downloading and running malicious programs, etc., to achieve complete control over routing devices.
[0004] However, there is currently no vulnerability detection method for IOS-XE. Due to the unique system architecture and command mode of IOS-XE, the existing vulnerability detection methods for traditional Cisco IOS or IoT devices do not work well on IOS-XE. Cisco IOS vulnerability detection relies heavily on Dynamips to simulate the firmware, but there is currently no simulator that supports the IOS-XE system. Among the vulnerability detection methods for IoT, fuzz testing is considered to be the simplest and most efficient method for discovering vulnerabilities. However, existing IoT fuzz testing methods either only generate initial seeds by analyzing the front end or referring to official and third-party API documents, which is prone to false positives, and there is no clear test target range, resulting in low vulnerability detection efficiency; or rely on simulators such as QEMU to simulate the device, which is not applicable to IOS-XE.
[0005] To design an effective fuzz testing method to detect security vulnerabilities in IOS-XE, the following difficulties need to be solved:
[0006] (1) Lack of feedback information. Currently, there is no tool or method that can monitor the execution information inside the IOS-XE system without exploiting vulnerabilities, which makes it impossible for fuzz testing to optimize mutation strategies based on feedback information such as code coverage.
[0007] (2) Strict parameter format. Both the front-end and back-end programs of the Web service have strict syntax requirements for the parameter format. Most test cases generated by random mutation will be directly rejected by the server. In addition, in the back-end function that processes the request, special characters (such as quotation marks) may be added to some parameters, turning them into non-executable strings.
[0008] (3) There are hidden APIs. Since there is a lot of code reuse between cross-platform IOS-XE systems, or some functions require additional configuration, there are some APIs in the IOS-XE system that do not have corresponding configuration interfaces or are unavailable in the front-end Web UI. If the initial seed is generated only from the front-end analysis, it is easy to cause underreporting. Summary of the invention
[0009] In view of the defects and problems of the current fuzzy test vulnerability detection method for IOS-XE, such as easy missed reports, low vulnerability detection efficiency, and reliance on simulators such as QEMU to simulate devices and being not applicable to IOS-XE, the present invention provides a command injection vulnerability detection method for Cisco IOS-XE Web.
[0010] The solution adopted by the present invention to solve the technical problem is: a Web command injection vulnerability detection method for Cisco IOS-XE, comprising the following steps:
[0011] Step 1: Seed generation: Extract API information from front-end Web requests and back-end Lua programs, combine the basic characteristics of command injection vulnerabilities, screen the back-end Lua programs, obtain vulnerable code segments that may have vulnerabilities, and generate the initial seeds for fuzz testing;
[0012] Step 2: Test case generation: Mark the initial seed with parameter attributes, and generate test cases by applying corresponding mutation rules according to the command injection vulnerability types; the command injection vulnerability types include underlying system command injection vulnerabilities and user permission command injection vulnerabilities;
[0013] Step 3: Simulate a request: simulate a Web UI login operation to initiate a request to the routing device and receive a response; the request includes a GET request and a POST request;
[0014] Step 4: Abnormal monitoring and test environment recovery: Monitor the status of the routing device, use the CLI Command API of the IOS-XE system Web service to view or modify the router configuration information to determine whether the command injection is successful, and restore the device configuration to the initial state.
[0015] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, in step 1, API information is extracted from the front-end Web request. During the extraction process, the header and parameter information of the request are parsed and stored.
[0016] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, in step 1, API information is extracted from the backend Lua program, specific parameters in the request are identified based on the reference of data in the function, and the corresponding initial seed is generated. The parameter identification process is as follows:
[0017] (1) The identification program parses the request parameters to obtain the initial parameter names;
[0018] (2) According to the access method of parameter elements, identify the first-level parameters and record the parameter names and corresponding variable names;
[0019] (3) Continue to identify the second-layer parameters based on the extracted variable names;
[0020] (4) Identify fixed strings in the program;
[0021] (5) Generate API information based on the records of (2), (3), and (4).
[0022] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, the parameter attribute marking method for the initial seed generated by the front-end request in step 2 is: first identify the text type and mark it, then perform several large-scale mutations on the parameter marked as a string, and determine whether it is a constant string based on the feedback result.
[0023] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, the parameter attribute marking method for the initial seed generated by the backend program in step 2 is as follows: first, constant inference is performed based on the parameter name, and then the attributes of the remaining empty characters are mutated in turn to generate a new seed, and the request data generated by the simulated client is sent to the routing device, and the actual attributes of the parameter are inferred based on the feedback result information.
[0024] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, in step 2, when mutating the seed for the underlying system command injection vulnerability, the special string is completed so that the injected command can be successfully executed; when mutating the seed for the user permission command injection vulnerability, two rules of viewing the configuration and modifying the configuration are adopted.
[0025] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, during abnormal monitoring in step 4, for the underlying system command injection vulnerability, in the generated test case, the injected command is to create a file in bootflash. To determine whether the command is injected successfully, log in as an administrator user, send a command to the CLI Command API to view the storage content of bootflash, and check whether the returned result contains the created file name.
[0026] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, during the abnormal monitoring in step 4, the response data and device configuration are monitored respectively according to the corresponding mutation rules for the user permission type command injection vulnerability; if the response data of the test case contains the pre-configured administrator user and its password, it indicates that the sensitive data is obtained successfully; log in as the administrator user, send a command to view the router configuration to the CLI Command API, and if the return result contains the added administrator user and password, it indicates that the device configuration is modified successfully.
[0027] In the above-mentioned Web command injection vulnerability detection method for Cisco IOS-XE, when the test environment is restored in step 4, for the underlying system command injection vulnerability, the CLI Command API is used to delete the file created in the bootflash; for the user permission command injection vulnerability, only the impact of the injected command on the device is considered. If the injected command is to view sensitive data, there is no need to restore the test environment. If the injected command is to add an administrator user, the CLICommand API is used to delete the added user.
[0028] Beneficial effects of the present invention: The present invention proposes a fuzz testing framework CRFuzzer for the Web management service of the IOS-XE system, which is used to detect command injection vulnerabilities. Different from the existing fuzz testing methods, this method combines the Web front-end and back-end analysis to optimize the seed generation strategy, analyzes the attributes of the parameters by analyzing the front-end request, and analyzes the back-end program to discover the hidden API, thereby improving the seed generation and improving the vulnerability detection capability of the fuzz test.
[0029] The testing method of the present invention can screen out vulnerable code that may have command injection vulnerabilities based on vulnerability features, narrow the test scope, and improve the efficiency of fuzz testing. The framework generates multiple initial seeds for a single backend endpoint based on constant value parameters, which can improve the code coverage of fuzz testing.
[0030] The present invention tested 124 firmwares of 31 different versions on the physical router ISR 4000 series and the cloud virtual router CSR1000v, and detected a total of 11 command injection vulnerabilities, of which 2 were undisclosed vulnerabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 Communication architecture for Cisco IOS-XE Web UI.
[0032] Figure 2 This is the system structure diagram of the fuzz testing framework CRFuzzer.
[0033] Figure 3 This is an example diagram of extracting parameters from the backend.
[0034] Figure 4 It provides API information and the number of vulnerable codes.
[0035] Figure 5 The test time comparison results are shown below. DETAILED DESCRIPTION
[0036] Before the present invention is introduced in detail, a brief introduction to the relevant contents is first given.
[0037] 1. Cisco IOS-XE Web UI Communication Architecture
[0038] IOS-XE is built on Linux. The traditional IOS runs as an independent process IOSd on the Linux kernel, and the Web UI server Nginx also runs as an independent process. The server-side request processing adopts the Lua-Nginx mode, and the back-end Lua program performs request data parsing, command construction, and response data filtering. The communication architecture of the Web UI is as follows: Figure 1 shown.
[0039] The user uses a browser to log in to the Web interface of IOS-XE, and uses the Web UI to view information and modify configurations of the routing device, and sends the corresponding request data generated on the front end to the server. On the server side of the Web UI, Nginx passes the request data to the baseHandler program to verify user permissions, then searches for the corresponding uri in the URLMap, finds the corresponding request handler, completes request parameter parsing and command construction. Finally, the command is executed in the underlying Linux system, or the WSMAGetData or WSMAApplyCmd function is called to pass the generated command to IOSd for execution.
[0040] During the backend processing, the Lua program is responsible for parsing the request data and constructing the corresponding commands. Some parameters will be used to generate the final command. If there is a lack of verification of such parameters or the verification method is incorrect, command injection may occur. Attackers can attach maliciously constructed commands to the parameters to cause the system to perform unplanned execution behaviors, obtain sensitive data information or tamper with device configurations.
[0041] 2. Cisco IOS-XE Command Injection Vulnerability
[0042] Different from the monolithic structure of traditional Cisco IOS, IOS-XE adopts modular design, with Linux as the underlying system, and removes some functional modules from IOS and converts them into independent processes on Linux. The remaining IOS parts also run on Linux as independent processes IOSd, and share the same command mode as traditional IOS.
[0043] According to the unique system architecture of IOS-XE and different command execution levels, command injection vulnerabilities in IOS-XE Web services are divided into two categories: underlying system command injection vulnerabilities executed in the underlying Linux system, and user privilege command injection vulnerabilities executed in the command line interface (CLI) of IOSd. Among them:
[0044] (1) Bottom-level system: This type of vulnerability allows users to access the bottom-level Linux system of IOS-XE and execute arbitrary commands in Linux with root privileges. By exploiting this type of vulnerability, attackers can read or delete files in the bottom-level Linux system and gain full control over the routing device.
[0045] (2) User privilege type: This type of vulnerability allows users with Read-Only privileges to execute commands in the IOSd CLI that can only be executed by users with administrator privileges. By exploiting this type of vulnerability, attackers can obtain sensitive data information of the device with Read-Only privileges, or even modify the configuration of the routing device.
[0046] Network core devices and IoT devices are widely used in industrial production or daily life. While they bring convenience to people, the security vulnerabilities of the devices also pose serious security threats to cyberspace. Researchers have tried to use a variety of methods such as fuzz testing, symbolic execution, and taint analysis to perform security analysis on embedded device firmware and detect security vulnerabilities. However, IOS-XE is quite different from common embedded devices, and there is currently no fuzz testing method for IOS-XE. Therefore, this article selects a relatively close technology, that is, a fuzz testing method for embedded devices, to introduce related work. Fuzz testing of embedded devices can be divided into two research routes based on the test object: simulation-based and physical device-based.
[0047] Among the simulation-based methods, RPFuzzer simulates the router firmware based on a modified Dynamips, while FIRM-AFL, FirmFuzz, and FIRMADYNE simulate IoT devices based on QEMU and embed fuzz testing tools in them. In the absence of a bootloader in the firmware, FIoT slices the firmware code according to the call flow graph, then dynamically executes the sliced code and applies fuzz testing. ReLink combines fuzz testing with dynamic data flow tracking to detect command injection vulnerabilities that require multiple requests to trigger based on the data stored on the device. The above methods use simulators to simulate the firmware, with the main purpose of obtaining CPU and memory status information during system operation for anomaly monitoring. At the same time, this status information can be used as feedback to guide the mutation strategy. However, it is difficult for researchers to fully simulate various CPU architectures. In addition, simulators such as Dynamips or QEMU do not support simulation of IOS-XE.
[0048] Among the methods targeting physical devices, the main work is reflected in optimizing seed generation and mutation strategies. SRFuzzer is an automated fuzz testing framework for physical SOHO routers. It generates initial seeds by capturing web requests during device operation, and performs semantic analysis and attribute tagging on the parameters in the request to optimize the mutation strategy. IoTFuzzer obtains initial seeds by analyzing the App used to connect and configure the device. In the mutation rules, it mainly targets three memory error vulnerabilities: stack overflow, integer overflow or out-of-bounds access, null pointer or data type error. The initial seeds of Snipuzz come from official or third-party API documents or test cases. Snipuzz proposes a message element attribute inference mechanism, which infers the relationship between bytes in the message based on response classification. The above methods are all based on the premise that the firmware and system runtime status cannot be obtained. They only extract API information from the front end to generate the initial seeds, ignoring the analysis of the backend program, which is easy to cause underreporting and cannot solve the hidden API problem mentioned in this article.
[0049] Although some methods combine the analysis of the backend program, for example, Jiang Yikun et al. combined program static analysis with dynamic fuzz testing to extract string information from the program obtained by unpacking the firmware to generate the initial seed, this method still relies on QEMU's simulation of the firmware. Chen Libo et al. pointed out that the front-end and back-end program variables usually share the same keyword, based on which the correlation between the front-end input and the back-end program can be established, but in subsequent work, the static taint analysis method is used.
[0050] Secondly, the fuzz testing methods listed above have no directional testing objectives and are mostly "carpet-style" tests, resulting in low vulnerability detection efficiency.
[0051] In summary, there is currently no fuzz testing framework for the IOS-XE system Web management service. Existing methods do not combine the characteristics of IOS-XE command injection vulnerabilities and cannot detect vulnerabilities such as the escalation of Read-Only permissions to administrator permissions.
[0052] In view of the above problems, the present invention provides a fuzzy testing framework CRFuzzer for Cisco IOS-XE system Web management service to detect command injection vulnerabilities. The present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0053] Embodiment 1: This embodiment provides a method for detecting a Web command injection vulnerability for Cisco IOS-XE. The method uses a fuzz testing framework CRFuzzer for the Web management service of the Cisco IOS-XE system to perform vulnerability detection. The CRFuzzer system structure is as follows: Figure 2 The method mainly includes the following contents:
[0054] 1. Seed generation: Extract API information from front-end Web requests and back-end Lua programs, combine command injection vulnerability features to find vulnerable code segments that may have vulnerabilities, and generate the initial seed for fuzz testing;
[0055] 1.1 API Information Extraction
[0056] (1) Request the extraction API from the front end:
[0057] Similar to some existing IoT fuzz testing methods, CRFuzzer extracts API information from front-end requests. During the extraction process, CRFuzzer parses and stores the request header and parameter information. The URL and its structure information in the header (such as Content-Type, Cookie structure, X-Csrf-Token, etc.) will be used to build the request simulator, while the parameters are necessary conditions for triggering the command injection vulnerability and will be used for subsequent mutation operations.
[0058] The CONF-READ communication mode also exists in the Web service of IOS-XE. For example, in the User Administration function, Add or Delete both initiate requests with the POST method to perform operations to add or delete users, which is a CONF request. After the configuration modification is completed, a request is initiated with the GET method to obtain all current user information, which is a READ request. However, the two command injection vulnerabilities targeted by CRFuzzer only require a single request to trigger, and do not involve sequence operations formed by multiple requests. Therefore, CRFuzzer does not consider requests without parameters.
[0059] (2) Extracting API from backend Lua program:
[0060] The Lua program receives the request data, obtains the parameter information in the request after the user permission is verified, and then calls the relevant functions to construct the command. The example program for parameter parsing and command construction is as follows: Figure 3 Left half shown.
[0061] In the program, dataTable is the parameter passed in the front-end request. The data format is table in Lua language. CRFuzzer identifies the specific parameters in the request based on the function's reference to the data in dataTable and generates the corresponding initial seeds. Among them, the parameters may be nested in multiple layers. From the seeds collected by the front-end, it is observed that the nesting relationship is at most two layers, so CRFuzzer only considers the parameter form with at most two layers of nesting relationship. The parameter identification process is as follows:
[0062] 1) Identify the program's analysis of the request parameters and obtain the initial parameter names;
[0063] 2) According to the access method of parameter elements, identify the first-level parameters and record the parameter names and corresponding variable names;
[0064] 3) Based on the variable names extracted in the second step, identify the second layer parameters in the same way;
[0065] 4) Identify fixed strings in the program;
[0066] 5) Generate API information based on the records in steps 2), 3), and 4).
[0067] An example of extracting API information from the backend is as follows Figure 3 As shown, the method for identifying the elements contained in the parameter according to the parameter name is shown in Algorithm 1.
[0068] During the API information extraction process, some parameters are constant strings. If such parameters are assigned values arbitrarily, invalid test cases will be generated. In addition, constant strings are usually used for branch condition judgments, and different values of constant strings correspond to different execution paths. Therefore, CRFuzzer generates an initial seed for each value of the constant string to cover as many code execution paths as possible.
[0069] Algorithm 1 Parameter element identification
[0070] Input: parameter name list paramList, Lua program luaFile
[0071] Output: The elements contained in the parameter and their corresponding variable names, in the form of a dictionary paramDict
[0072] Execution process:
[0073]
[0074] 1.2 Vulnerable Code Discovery
[0075] Existing fuzz testing technology for embedded devices tends to be black box testing, which performs "carpet-style" testing on the extracted API interfaces, and the vulnerability detection efficiency is not high. Based on the characteristics of two command injection vulnerabilities, CRFuzzer discovers vulnerable code in backend programs through given rules, narrowing the target scope of fuzz testing.
[0076] In the Web management service of IOS-XE, the backend Lua program parses the request data, builds the specified command and executes it. If the command contains user-entered parameters, and the Lua program lacks verification of the parameters or the verification method is incorrect, the attacker can inject malicious commands into the request parameters to achieve unplanned execution. Therefore, command injection vulnerabilities have two basic characteristics: 1) The corresponding request contains user-entered parameters; 2) The user-entered parameters are used to construct the command and are called for execution.
[0077] For example, in the underlying system-type vulnerable code below, in the underlying system-type command injection vulnerability, the constructed command will be executed by the execute function call in the underlying Linux system. By using shell command connection symbols such as ";" and "&", the constructed command is attached to the parameters input by the user, and arbitrary commands can be executed with root privileges in the underlying Linux system.
[0078]
[0079] If the constructed command is of the CLI type of IOS-XE, the WSMAGetData or WSMAApplyCmd function is called to pass the command to IOSd for execution and obtain the original response result. Among them, WSMAGetData will execute the command in privileged EXEC mode, and WSMAApplyCmd will execute the command in global configuration mode, both of which require administrator privileges. As shown in the following user-privileged vulnerable code example, if the backend program lacks verification of the user-entered parameters or the verification method is incorrect, the attacker can attach malicious commands to the parameters, obtain sensitive data information of the routing device, and even tamper with the router configuration.
[0080]
[0081] Before constructing the command, baseHandler will perform a preliminary check on the user's permissions. GET requests are allowed to be initiated by all users, while POST requests are only allowed to be executed by administrators. Under the condition that administrator permissions are already available, command injection is performed to obtain sensitive data information or modify the configuration of the routing device. This injection does not involve permission escape and has no practical significance. Therefore, requests for user permission command injection vulnerabilities can only be initiated through the GET method.
[0082] Based on the basic characteristics of the above two command injection vulnerabilities, the backend Lua program is screened to obtain vulnerable code segments that may have security vulnerabilities as the target of subsequent CRFuzzer testing.
[0083] 2. Test case generation: Parameter attribute marking is performed from the initial seed, and the corresponding mutation rules are applied according to the command injection vulnerability type to generate test cases;
[0084] 2.1 Seed initialization strategy
[0085] Since embedded devices have strict format requirements for user input parameters, when mutating the parameters in the seed, if random mutation is used, most of the generated test cases will fail during the server parameter format verification, causing the server to directly reject the request. For example, if a string is passed to an integer parameter, or a constant string parameter is mutated, an invalid test case will be generated.
[0086] In order to reduce the generation of invalid test cases, the seed parameters need to be attributed before applying the mutation strategy. When performing seed mutation, the mutation of constant strings will no longer be considered, and other parameters will be mutated according to their marked attributes, and cross-attribute mutation operations will not be performed. Based on the API information corresponding to the discovered vulnerable code, the corresponding initial seeds are selected from the seed set, and request tests are performed on these seeds to mark parameter attributes.
[0087] For the initial seed generated by the front-end request, the parameter format is relatively accurate, and the identification and marking of parameter attributes are relatively simple. First, identify the text type (string, number), then perform several large variations on the parameters marked as strings, and determine whether they are constant strings based on the feedback results.
[0088] For the initial seed generated based on the backend program analysis, CRFuzzer first makes common sense inferences based on the parameter name. For example, the attribute of the parameter ipaddress will be marked as an IP address. Then, the remaining empty characters are mutated in turn. The mutated attributes mainly include variable strings, numbers, etc., to generate a new seed, and send the request data generated by the simulated client to the routing device, and infer the actual attributes of the parameter based on the feedback result information.
[0089] 2.2 Seed mutation rules
[0090] (1) Bottom-level system command injection vulnerability:
[0091] In the file system of IOS-XE, the bootflash directory is stored in the root directory of the underlying Linux, and the files in the bootflash can be accessed in Linux. To facilitate the subsequent monitoring of whether the injected command is successfully executed, CRFuzzer chooses to append the command to create a file in bootflash after the variable string of the seed. IOS-XE may append special characters (such as quotes, escape characters, etc.) to the parameters, turning them into non-executable strings. Therefore, CRFuzzer considers the completion of special characters when mutating so that the injected command can be successfully executed.
[0092] (2) User-privileged command injection vulnerability:
[0093] CRFuzzer is dedicated to discovering command injection vulnerabilities that can achieve user privilege escape, allowing users with Read-Only privileges to execute commands with administrator privileges, obtain sensitive data, or modify device configurations. To this end, this article designs two mutation rules for user privilege command injection vulnerabilities:
[0094] 1) Check the configuration. This injection method is relatively simple and attempts to obtain the administrator's username and password. However, since the backend Lua program may filter the original response, even if the injected command is successfully executed, the response data received by the client does not contain the configuration information of the routing device.
[0095] 2) Modify the configuration. The command injected is to add an administrator user. This command injection method involves switching between privileged mode and global configuration mode, requires additional conf t commands, and has limitations on the applicable firmware versions.
[0096]
[0097] (3) Mutation Optimization
[0098] When mutating the seed to generate test cases, it is only necessary to ensure that the Lua program can execute to the corresponding branch, without requiring the original command to be executed correctly. Therefore, CRFuzzer makes the prefix command execution error as much as possible, and directly executes the injected command. On the one hand, it can reduce the modification of the routing device configuration and facilitate the recovery of the test environment; on the other hand, it can save the execution time of the test case. For example, when it comes to the install command, CRFuzzer will set the package path to the wrong path during the mutation process to avoid the transmission and installation of the package.
[0099] 3. Simulate requests: simulate the login operation of the Web UI to initiate a request to the routing device and receive a response; CRFuzzer simulates the login operation, GET request and POST request of the IOS-XE system Web UI. Among them, the GET request can be initiated directly after login, while the POST request needs to obtain the CSRF-Token first.
[0100] 4. Abnormal monitoring and test environment recovery: Monitor the status of routing devices and restore the test environment after each test (use the CLI Command API of the IOS-XE system Web service to view or modify router configuration information to determine whether the command injection is successful and restore the device configuration to the initial state).
[0101] 4.1 Abnormality Monitoring
[0102] (1) Bottom-level system command injection vulnerability
[0103] When logging in as an administrator, you can execute configuration view commands in the IOS-XE Web UI. In the generated test case, the command injected is to create a file in bootflash. Therefore, to determine whether the command injection is successful, you only need to log in as an administrator, send a command to view the bootflash storage content to the CLI Command API, and check whether the returned result contains the created file name.
[0104] (2) User-privileged command injection vulnerability
[0105] According to the mutation rules of the user-privileged command injection vulnerability, CRFuzzer monitors the response data and device configuration respectively. If the response data of the test case contains the pre-configured administrator user and password, it means that the sensitive data has been successfully obtained. Log in as an administrator user and send a command to the CLI Command API to view the router configuration. If the return result contains the added administrator user and password, it means that the device configuration has been successfully modified.
[0106] 4.2 Test environment recovery
[0107] In order to prove that the command injected in the test case is successfully executed, it is necessary to ensure that the configuration of the router is consistent before each request is initiated. According to the type of command injection vulnerability, this paper designs a lightweight test environment recovery solution.
[0108] (1) Bottom-level system command injection vulnerability
[0109] The Web UI of IOS-XE can execute commands to modify device configuration when logged in as an administrator. In the test case, the injected command is to create a file in bootflash, which does not trigger a device crash or restart. By optimizing the mutation rules, the prefix command cannot be successfully executed, and thus does not change the router configuration. Therefore, it is only necessary to use the CLICommand API to delete the file created in bootflash.
[0110] (2) User-privileged command injection vulnerability
[0111] This type of vulnerability testing will not trigger a device crash or restart, and GET requests are mostly commands for viewing information, which will not cause changes to device configuration. Therefore, CRFuzzer only considers the impact of injected commands on the device. If the injected command is to view sensitive data, there is no need to restore the test environment. If the injected command is to add an administrator user, the CLICommand API is used to delete the added user.
[0112] Test case: This test case evaluates CRFuzzer from the aspects of API information extraction and vulnerable code discovery, command injection vulnerability detection capability and detection efficiency, and compares it with the existing fuzz testing method SRFuzzer. In addition, since SRFuzzer only detects injections into the Linux system in terms of command injection vulnerabilities, this paper adds mutation rules for user permission command injection vulnerabilities to SRFuzzer, and adds a strategy for completing special characters to form SRFuzzer+ for comparative experiments.
[0113] 1. Experimental Setup
[0114] The devices used in the experiment are ISR 4000 series physical routers (including ISR 4221, ISR4321 and ISR 4331), and cloud virtual router CSR 1000v. The firmware of the four devices all use 31 versions from 16.5.x to 16.11.x, totaling 124 different firmwares. The administrator user with username and password admin and the user with username and password guest and Read-Only permissions are pre-configured in the router.
[0115] 2. Experimental results
[0116] 2.1 API Information Extraction and Vulnerable Code Discovery
[0117] This experiment takes 7 versions of firmware, 16.5.1, 16.6.1, 16.7.1, 16.8.1, 16.9.1, 16.10.1 and 16.11.1, as examples to extract front-end and back-end API information and discover vulnerable code based on vulnerability features. In the experiment, only APIs with parameters are considered, and an API message is defined as a tuple consisting of a URL and a request method, such as<URL,method> The experimental results are as follows Figure 4 As shown in the figure, a unit from left to right represents ISR Front-end API, ISR Back-end API, ISR Vulnerable Code, CSR Front-end API, CSR Back-end API, and CSRVulnerable Code.
[0118] from Figure 4 It can be seen that there is a difference in the quantity of API information extracted from the front-end and back-end, with the back-end being more than the front-end. This indicates that there are hidden APIs in the Web management service of the IOS-XE system. By viewing the API information extracted from the front-end and back-end, it is found that the APIs missing from the front-end are mainly divided into the following two types: (1) The front-end does not have the corresponding functional interface, such as Threat Defense, VPN, Application Visibility, and Custom Application, and the tested firmware does not support the corresponding functions; (2) The front-end cannot directly use the corresponding functional interface, such as Python Sandbox and troubleshooting audit. The former requires pre-configured Guestshell on the router, while the latter requires online authentication of a Cisco account. However, the back-end also has the corresponding request handler, which can call the corresponding API and execute the relevant code by simulating sending requests.
[0119] like Figure 4As shown in the figure, the API information extracted from the ISR 4000 and CSR 1000v backend programs is basically the same, while the API information extracted from the ISR 4000 and CSR 1000v frontends is less than the backend API. This is because there is a lot of code reuse between cross-platform IOS-XE systems. The ISR 4000 series routing devices do not support functions such as Threat Defense and VPN. The Application Visibility and Custom Application functions only exist in some versions of the firmware. This results in the lack of the above two hidden APIs in the ISR 4000 frontend, while the CSR 1000v frontend mainly lacks the second hidden API. CRFuzzer extracts API information from the frontend request and the backend program respectively. The experimental results show that CRFuzzer can extract more complete API information, which helps to generate a more complete initial seed library and cover more program execution paths.
[0120] In addition, this experiment is based on the basic characteristics of the two types of command injection vulnerabilities, the underlying system type and the user permission type, to discover vulnerable codes and screen out APIs that may have vulnerabilities. Figure 4 As shown in the figure, the number of APIs corresponding to the filtered vulnerable codes is far less than the total number of APIs extracted from the backend. The Web UI of the IOS-XE system is an interface for users to view information and modify configurations. The former is mainly initiated by GET requests and allowed to be initiated by users with all permissions, while the latter is mainly POST and only allowed to be executed by administrator users. Since user permissions are checked before parameter parsing and command construction, there is no user permission type command injection vulnerability for APIs with a request method of POST. In addition, only a small number of APIs need to execute the built commands in the underlying Linux, that is, only a small number of APIs may have underlying system type command injection vulnerabilities. Therefore, the vulnerability features proposed in Section 3.1 are relatively weak, and their main purpose is to filter some APIs that do not have command injection vulnerabilities while minimizing missed reports. The experimental results show that although this method cannot accurately locate the vulnerability, it can greatly reduce the target range of fuzz testing.
[0121] 2.2 Vulnerability Detection Capabilities
[0122] In order to verify the vulnerability detection capability of CRFuzzer, this paper selects SRFuzzer and SRFuzzer+ formed by adding mutation rules for comparative experiments. The experiment detects command injection vulnerabilities on 31 versions of firmware from 16.5.1 to 16.11.1 on ISR 4000 and CSR1000v routers respectively. The experimental results are shown in Table 1.
[0123] Table 1 Comparison of vulnerability detection effects
[0124]
[0125] As shown in Table 1, CRFuzzer detected a total of 11 command injection vulnerabilities, of which 5 were of the underlying system type, which can be used to execute arbitrary commands in the underlying Linux system with root privileges; 6 were of the user privilege type, which can be used to log in as a user with Read-Only privileges, execute commands that require administrator privileges, obtain sensitive data, or modify router configurations. Among these 11 vulnerabilities, 9 CVE vulnerabilities are known vulnerabilities. Cisco officially disclosed some vulnerability information and critical versions (the first fix or the first unaffected version), but did not disclose the vulnerability location and vulnerability triggering method; 2 CNVD vulnerabilities are undisclosed vulnerabilities discovered by CRFuzzer.
[0126] SRFuzzer does not have the ability to detect user-privileged command injection vulnerabilities because Linux and IOSd use two different sets of commands. Without adding a special character completion strategy, SRFuzzer can only detect one of the five underlying system-type command injection vulnerabilities. SRFuzzer+ adds mutation rules for user-privileged command injection vulnerabilities and a special character completion strategy, but still only extracts API information from the front-end request to generate the initial seed, so it can only detect security vulnerabilities related to non-hidden APIs. SRFuzzer+ performs better on CSR 1000v than on ISR 4000 because CSR 1000v has more complete functions and has some functional interfaces that are not supported by ISR 4000, which can extract more API information from the front-end request. CRFuzzer combines front-end request and back-end program analysis to extract more complete API information and has better vulnerability detection capabilities. The experimental results show that CRFuzzer can effectively detect both underlying system-type and user-privileged command injection vulnerabilities in the Web management service of the IOS-XE system.
[0127] 2.3 Vulnerability Detection Efficiency
[0128] In order to test the vulnerability detection efficiency of CRFuzzer, the time consumed by SRFuzzer+ and CRFuzzer for testing on each firmware of ISR 4000 and CSR1000v was recorded. SRFuzzer injects commands executed in the underlying Linux system into variable parameters through shell characters such as ";", "&" or "||". If the parameters are used to build commands executed in IOSd, they will not be recognized by the CLI command parsing module and will directly return Error. Since SRFuzzer does not have the time overhead of command execution, the test time of SRFuzzer is no longer compared in this experiment. Taking the seven versions of firmware 16.5.1, 16.6.1, 16.7.1, 16.8.1, 16.9.1, 16.10.1 and 16.11.1 as examples, the test time is as follows: Figure 5 As shown in the figure, a unit from left to right represents SRFuzzer+ on ISR, CRFuzzer on ISR, SRFuzzer+ on CSR, and CRFuzzer on CSR. The API information extracted by CRFuzzer on ISR4000 and CSR 1000v, and the number of APIs corresponding to the vulnerable code screened out based on the characteristics of command injection vulnerabilities are basically the same, and the test time on the two types of routing devices is basically the same. However, SRFuzzer+ can extract more API information from the front-end request of CSR 1000v, so the test time on CSR 1000v is longer than that on ISR 4000.
[0129] from Figure 5 It can be seen that for the same version of firmware, CRFuzzer consumes less time than SRFuzzer+. CRFuzzer combines front-end requests and back-end programs to extract more API information and generate more initial seeds. However, CRFuzzer screens vulnerable codes based on the basic characteristics of two types of command injection vulnerabilities: underlying system type and user permission type, and only tests APIs that may have vulnerabilities. Figure 4 As shown in the figure, the number of APIs corresponding to the filtered vulnerable codes is much smaller than the total number of APIs. The experimental results show that this method can significantly reduce the target scope of fuzz testing and improve the efficiency of vulnerability detection.
[0130] The above description is only a preferred embodiment of the present invention and does not limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A Web command injection vulnerability detection method for Cisco IOS-XE, characterized by: The following steps are involved: Step 1, seed generation: extract API information from the front-end Web request and the back-end Lua program, combine the basic characteristics of the command injection vulnerability, screen the back-end Lua program, obtain the vulnerable code segments that may have vulnerabilities, and generate the initial seed for the fuzz test; extract API information from the front-end Web request in step 1, and parse and store the request header and parameter information during the extraction process; extract API information from the back-end Lua program in step 1, identify the specific parameters in the request based on the reference of the data in the function, and generate the corresponding initial seed, where the parameter identification process is as follows: (1) Identify the program’s analysis of the request parameters to obtain the initial parameter name; (2) According to the access method of parameter elements, identify the first-level parameters and record the parameter names and corresponding variable names; (3) Continue to identify the second-layer parameters based on the extracted variable names; (4) Identify fixed strings in the program; (5) Generate API information based on the records of (2), (3), and (4); Step 2: Test case generation: Mark the initial seed with parameter attributes, apply the corresponding mutation rules according to the command injection vulnerability type, and generate test cases; The command injection vulnerability types include underlying system command injection vulnerabilities and user permission command injection vulnerabilities; In step 2, the parameter attribute marking method for the initial seed generated by the front-end request is: first identify the text type and mark it, then mutate the parameter marked as a string several times, and judge whether it is a constant string according to the feedback result; in step 2, the parameter attribute marking method for the initial seed generated by the back-end program is: first perform constant inference based on the parameter name, then mutate the attributes of the remaining empty characters in turn, generate a new seed, and send the request data generated by the simulated client to the routing device, and infer the actual attributes of the parameter according to the feedback result information; in step 2, when mutating the seed for the underlying system command injection vulnerability, the special string is filled so that the injected command can be successfully executed; When performing seed mutation for user permission command injection vulnerabilities, two rules are used: viewing configuration and modifying configuration; Step 3: Simulate a request: simulate a Web UI login operation to initiate a request to the routing device and receive a response; the request includes a GET request and a POST request; Step 4: Abnormal monitoring and test environment recovery: Monitor the status of the routing device, use the CLICommand API of the IOS-XE system web service to view or modify the router configuration information to determine whether the command injection is successful, and restore the device configuration to the initial state.
2. The method for detecting a Web command injection vulnerability for Cisco IOS-XE according to claim 1, characterized in that: During abnormal monitoring in step 4, for the underlying system command injection vulnerability, in the generated test case, the injected command is to create a file in bootflash. To determine whether the command injection is successful, log in as an administrator user and send a command to the CLI CommandAPI to view the storage content of bootflash, and check whether the returned result contains the created file name.
3. The method for detecting a Web command injection vulnerability for Cisco IOS-XE according to claim 1, characterized in that: During abnormal monitoring in step 4, the response data and device configuration are monitored according to the corresponding mutation rules for user permission command injection vulnerabilities; if the response data of the test case contains the pre-configured administrator user and its password, it means that the sensitive data is obtained successfully. Log in as the administrator user and send a command to view the router configuration to the CLI Command API. If the return result contains the added administrator user and password, it means that the device configuration is modified successfully.
4. The method for detecting a Web command injection vulnerability for Cisco IOS-XE according to claim 1, characterized in that: When restoring the test environment in step 4, for the underlying system command injection vulnerability, use the CLI Command API to delete the files created in the bootflash; for the user permission command injection vulnerability, only consider the impact of the injected command on the device. If the injected command is to view sensitive data, there is no need to restore the test environment. If the injected command is to add an administrator user, use the CLI Command API to delete the added user.
Citation Information
Cited By
Apparatus, embedded software application, data carrier, computer program, and method for fuzz testing embedded software applications
EP4711933A1
