Skip to content

Latest commit

 

History

History
135 lines (99 loc) · 9.51 KB

File metadata and controls

135 lines (99 loc) · 9.51 KB

Attack Tree Analysis for openresty/lua-nginx-module

Objective: Gain unauthorized access, control, or disrupt the application by exploiting vulnerabilities or weaknesses introduced by the Lua-Nginx-Module.

Attack Tree Visualization

Compromise Application via Lua-Nginx-Module [CRITICAL NODE]
├───[OR] Exploit Lua Code Vulnerabilities [CRITICAL NODE] [HIGH-RISK]
│   ├───[OR] Lua Injection Vulnerabilities [CRITICAL NODE] [HIGH-RISK]
│   │   ├───[AND] Input Manipulation
│   │   │   ├───[AND] Identify Input Vectors
│   │   │   └───[AND] Inject Malicious Lua Code [HIGH-RISK]
│   │   └───[AND] Code Execution [CRITICAL NODE]
│   │       └───[AND] Execute Arbitrary Lua Code on Server [CRITICAL NODE]
│   │           └───[Goal Achieved: Code Execution] [CRITICAL NODE]
│   ├───[OR] Logic Errors in Lua Code [HIGH-RISK]
│   │   ├───[AND] Identify Logic Flaws [HIGH-RISK]
│   │   ├───[AND] Trigger Vulnerable Logic Flow [HIGH-RISK]
│   │   └───[AND] Exploit Logic Flaws [HIGH-RISK]
│   │       ├───[OR] Data Breach [HIGH-RISK]
│   │       └───[OR] Application Manipulation [HIGH-RISK]
│   ├───[OR] Vulnerable Lua Libraries [HIGH-RISK]
│   │   ├───[AND] Identify Used Lua Libraries
│   │   ├───[AND] Check for Known Vulnerabilities
│   │   └───[AND] Exploit Library Vulnerabilities [HIGH-RISK]
│   │       ├───[OR] Code Execution [HIGH-RISK]
│   │       └───[OR] Data Breach [HIGH-RISK]
│   └───[OR] Denial of Service (DoS) via Lua [HIGH-RISK]
│       ├───[AND] Resource Exhaustion [HIGH-RISK]
│       │   ├───[AND] Craft Malicious Request [HIGH-RISK]
│       │   │   └───[AND] Design request to trigger resource-intensive Lua operations [HIGH-RISK]
│       │   └───[AND] Send Malicious Request(s) [HIGH-RISK]
│       └───[AND] Application Unavailability [CRITICAL NODE]
│           └───[Goal Achieved: DoS] [CRITICAL NODE]
├───[OR] Exploit Nginx Configuration Issues (Lua Related) [HIGH-RISK]
│   ├───[OR] Insecure `lua_package_path`/`lua_package_cpath` [HIGH-RISK]
│   │   ├───[AND] Identify Package Paths
│   │   ├───[AND] Write Access to Package Paths [HIGH-RISK]
│   │   │   └───[AND] Determine if attacker can write to directories specified in package paths [HIGH-RISK]
│   │   └───[AND] Plant Malicious Lua Modules [HIGH-RISK]
│   │       ├───[AND] Upload Malicious Lua File [HIGH-RISK]
│   │       │   └───[AND] Upload a Lua file with malicious code to a writable package path [HIGH-RISK]
│   │       └───[AND] Trigger Module Loading [HIGH-RISK]
│   │           └───[AND] Application loads the malicious module via `require` [HIGH-RISK]
│   │               └───[Goal Achieved: Code Execution] [CRITICAL NODE]
│   ├───[OR] Exposing Internal APIs via Lua [HIGH-RISK]
│   │   ├───[AND] Identify Exposed APIs [HIGH-RISK]
│   │   │   └───[AND] Analyze Lua scripts for usage of Nginx internal APIs [HIGH-RISK]
│   │   ├───[AND] Access Exposed APIs [HIGH-RISK]
│   │   │   └───[AND] Craft requests or Lua code to access and exploit exposed internal APIs [HIGH-RISK]
│   │   └───[AND] Exploit Exposed APIs [HIGH-RISK]
│   │       ├───[OR] Information Disclosure [HIGH-RISK]
│   │       └───[OR] Configuration Manipulation [HIGH-RISK]
│   └───[OR] Misconfigured `content_by_lua*`, `access_by_lua*`, etc. [HIGH-RISK] [CRITICAL NODE]
│       ├───[AND] Identify Misconfigurations [HIGH-RISK]
│       │   └───[AND] Analyze Nginx configuration for incorrect or overly permissive usage of `content_by_lua*`, `access_by_lua*`, etc. [HIGH-RISK]
│       ├───[AND] Exploit Misconfiguration [HIGH-RISK]
│       │   └───[AND] Leverage misconfiguration to inject or execute malicious Lua code or bypass intended security controls [HIGH-RISK]
│       └───[AND] Gain Control [CRITICAL NODE]
│           ├───[OR] Code Execution [CRITICAL NODE] [HIGH-RISK]
│           └───[OR] Access Control Bypass [HIGH-RISK]

This is the root goal. Success means the attacker has achieved unauthorized access, control, or disruption of the application due to vulnerabilities related to Lua-Nginx-Module.

This category encompasses vulnerabilities arising from the Lua code written for the application.

Attack Vector: Injecting malicious Lua code through user-controlled input that is then executed by the application (e.g., using ngx.eval, loadstring, or string concatenation). * Impact: Arbitrary code execution on the server.

Attack Vector: Exploiting flaws in the application's business logic implemented in Lua (e.g., authentication bypass, authorization flaws, insecure data handling). * Impact: Data breach, application manipulation, unauthorized actions.

Attack Vector: Exploiting known vulnerabilities in third-party Lua libraries used by the application. * Impact: Code execution, data breach, depending on the library vulnerability.

Attack Vector: Crafting malicious requests that trigger resource-intensive Lua operations (e.g., infinite loops, excessive memory allocation) leading to server overload. * Impact: Application unavailability, service disruption.

This category focuses on vulnerabilities arising from misconfigurations in Nginx that are specific to its interaction with Lua-Nginx-Module.

Attack Vector: If lua_package_path or lua_package_cpath points to writable directories, attackers can upload malicious Lua modules and force the application to load and execute them. * Impact: Code execution on the server.

Attack Vector: Unintentionally exposing Nginx internal APIs (e.g., ngx.config, ngx.shared.DICT) through Lua scripts, allowing attackers to access sensitive information or manipulate Nginx internals. * Impact: Information disclosure (Nginx configuration, shared data), configuration manipulation, potentially leading to further compromise.

Attack Vector: Incorrect or overly permissive usage of Nginx directives like content_by_lua*, access_by_lua*, etc., such as directly executing untrusted Lua code or bypassing intended security controls. * Impact: Code execution, access control bypass, potentially full application control.

This is a critical node representing the achievement of arbitrary code execution on the server. It is the highest impact outcome for many attack paths.

This is the specific action that leads to Code Execution.

This marks the successful achievement of the Code Execution goal.

This is a critical node representing the state of the application being unavailable due to a successful Denial of Service attack.

This marks the successful achievement of the Denial of Service goal.

This node represents the attacker gaining control over the application due to misconfigurations, which can manifest as Code Execution or Access Control Bypass.