nginx-c-module-debugging
Audited by Socket on Feb 16, 2026
3 alerts found:
Obfuscated Filex2AnomalyThe code demonstrates a critical memory-safety bug: storing pointers into request-scoped pool memory in connection-scoped state leads to use-after-free when the request ends and the connection context is later accessed (e.g., on keepalive). The corrected pattern (deep-copy into connection pool) is the appropriate fix. This is a stability/availability risk (crashes, memory corruption) rather than malicious code or data exfiltration.
This code sample contains a critical concurrency bug in the "Incorrect" example: shared memory structures (rbtree and slab metadata) are modified without acquiring the shared memory mutex, which can lead to cross-worker slab corruption and crashes. The provided "Correct" example demonstrates the appropriate fix (hold shmtx, use ngx_slab_alloc_locked, and use atomics for simple counters). There is no evidence of malicious behavior, network exfiltration, obfuscation, or hidden backdoors in the provided code. The risk is functional/security-related (data structure corruption and crashes) and should be treated as high-severity for correctness and availability but not malware.
The provided incorrect implementation contains a deterministic 2-byte buffer overrun when building the key (writes separator and null terminator past the allocated buffer). Because ngx_pnalloc returns contiguous pool memory, this leads to silent corruption of the next pool allocation and can cause crashes or data corruption later. The corrected code (compute prefix->len + 1 + uri->len and allocate key->len + 1) resolves the issue. This is a critical stability/security bug to be fixed; it appears to be an inadvertent programming error rather than malicious code.