CVE-2022-43286 is a critical vulnerability discovered in Nginx NJS v.7.2. The vulnerability is a heap-use-after-free bug caused by an illegal memory copy in the function njs_json_parse_iterator_call located in the njs_json.c file. This article will provide an overview of the vulnerability, an explanation of the affected code, and a description of the exploit details to help security professionals and developers better understand and defend against this security flaw.

Vulnerability Overview

The vulnerability identified in Nginx NJS v.7.2 occurs within the specific function njs_json_parse_iterator_call in the njs_json.c file. This function performs an illegal memory copy, resulting in a heap-use-after-free bug. Heap-use-after-free vulnerabilities are considered critical because attackers can exploit them to execute arbitrary code, potentially allowing for unauthorized access or control over the vulnerable system.

Affected Code Snippet

The affected function is njs_json_parse_iterator_call() found in the njs_json.c file. The illegal memory copy causing the heap use-after-free bug can be observed in the following code snippet:

static njs_int_t
njs_json_parse_iterator_call(njs_vm_t *vm, njs_value_t *invld_value,
    uintptr_t data)
    njs_mp_free(pool, it);

The njs_mp_free(pool, it) line in the above code snippet is responsible for the heap use-after-free vulnerability. The memory pool pool is released while there are still ongoing operations involving the iterator object it.

Original References

The details of this vulnerability were first published by security researchers from the following sources:

1. CVE Details: CVE-2022-43286
2. Nginx Security Advisory: NJS v.8.

Exploit Details

To successfully exploit the CVE-2022-43286 vulnerability, an attacker first needs to identify a system running a version of Nginx NJS affected by the vulnerability (v.7.2). The attacker must then construct a specifically crafted JSON payload designed to trigger the heap-use-after-free bug in the njs_json_parse_iterator_call function.

The specific JSON content needed to trigger the vulnerability may vary depending on what actual NJS code is being executed on the target system. However, to exploit CVE-2022-43286, an attacker must first find a way to pass their carefully crafted JSON payload to the target system. This might be achieved through tactics like social engineering or other forms of unauthorized access.

Once the attacker has triggered the heap-use-after-free, they are in position to potentially take control of the vulnerable system by executing arbitrary code. Depending on the specific system configuration, the attacker might be able to gain unauthorized access to sensitive data, compromise the integrity of the system, or even perform denial of service attacks.

Defending Against CVE-2022-43286

To protect your systems against the CVE-2022-43286 vulnerability, the best course of action is to update your Nginx NJS version to the latest version, which at the time of writing is v.8.. This release includes a fix for the heap-use-after-free bug, making it essential to promptly update your software.

In addition to updating your software, it's always a good idea to follow best security practices like regularly updating all software, using strong and unique passwords, and employing robust network security measures to minimize the risk of attackers exploiting any vulnerabilities in your systems.


CVE-2022-43286 is a critical heap-use-after-free vulnerability in Nginx NJS v.7.2. Understanding how this vulnerability affects the underlying code and how attackers can exploit it is crucial for security professionals and developers alike. By keeping software up-to-date and following best security practices, you can better defend against potential attacks that could compromise your systems and expose sensitive data.


Published on: 10/28/2022 21:15:00 UTC
Last modified on: 10/31/2022 17:48:00 UTC