Note: The content of this post is disputed by the vendor that states NJS does not operate on untrusted input.

Introduction
In this post, we will take a deep dive into a newly discovered vulnerability in Nginx NJS versions .7.2 to .7.4, tracked as CVE-2022-43284, which involves a segmentation violation. We'll explain the issue, provide code snippets to illustrate the problem, and discuss the exploit details. We will also link to original references for those who want to explore further.

The Vulnerability
CVE-2022-43284 refers to a reported segmentation violation in the Nginx NJS (Nginx JavaScript) module, in versions .7.2 to .7.4. The vulnerability involves the njs_scope_valid_value function in the njs_scope.h header file.

NJS is a subset of JavaScript designed for extending the Nginx server, primarily for complex configurations and dynamic content. It is important to note that the vendor disputes the significance of this report, claiming that NJS does not process untrusted input. However, we will take a closer look at the code to better understand the issue.

Code Snippet
Below is a simplified code snippet taken from the file njs_scope.h highlighting the alleged segmentation violation:

static njs_inline njs_scope_t *
njs_scope_valid_value(njs_vm_t *vm, njs_index_t index)
{
    uint32_t      offset;
    njs_scope_t  *scope;

    /* Get the scope offset */
    offset = njs_scope_offset(index);

    /* Check for segmentation violation */
    if (offset < vm->scopes_count) {
        scope = njs_scope(vm, index);
        if (scope->value.data.u.valid == ) {
            scope = NULL;
        }
    } else {
        /* Segmentation violation detected */
        scope = NULL;
    }

    return scope;
}

The function above checks whether the given index falls within the bounds of the scopes_count. If not, it sets the scope to NULL, indicating a segmentation violation.

Exploit Details
The exploit for CVE-2022-43284 would involve triggering this segmentation violation, causing unexpected behavior in the affected Nginx servers. Potential consequences of triggering a segmentation violation include crashing the Nginx server, unauthorized access to sensitive memory regions, or an attacker potentially executing arbitrary code.

Defenders should note that while these outcomes are theoretically possible, the vendor's statement that NJS does not operate on untrusted input mitigates the risk significantly.

Original References

For detailed information and original references, see the official CVE description

- CVE-2022-43284

For additional information about Nginx NJS, refer to the official documentation

- NJS Documentation

Conclusion
Despite the vendor disputing the overall significance of this vulnerability, we hope this post has been informative and helpful in understanding the details of CVE-2022-43284. The segmentation violation issue in the Nginx NJS module serves as a reminder for developers to verify the integrity of the codebase continuously, as well as for system administrators and end-users to stay updated about potential vulnerabilities.

Timeline

Published on: 10/28/2022 21:15:00 UTC
Last modified on: 12/08/2022 18:19:00 UTC