The njs module is NGINX’s JavaScript extension for adding custom logic to HTTP and Stream request handling. It lets operators script how requests are routed, transformed, or forwarded, and can call features such as ngx.fetch() during processing. That flexibility makes NGINX more programmable, but it also expands the attack surface beyond static configuration.
In security terms, njs matters because request-processing code can become a trust-boundary problem. If client-controlled data is fed into directives such as js_fetch_proxy, an attacker may influence sensitive runtime behavior and trigger crashes or, in some cases, memory corruption. Defenders should inventory where njs is enabled, review any use of variables in proxy or fetch paths, and remove unnecessary dynamic logic. Keeping proxy destinations static, patching promptly, and preserving protections like ASLR reduce the risk when njs is part of an exposed edge deployment.



