Summary
A command injection vulnerability in the wifiNetworks() function of the Node.js systeminformation library allows arbitrary OS command execution when an attacker controls the network interface parameter.
The initial call sanitizes the interface value, but a retry path reuses the original unsanitized parameter in an execSync('iwlist ${iface} scan') call, enabling command execution with the privileges of the Node.js process when user input is passed through.
Affected context
The vulnerability occurs in Node.js applications that use the systeminformation library's wifiNetworks() function to enumerate Wi-Fi networks on Linux systems.
It is specifically exposed when application code passes user-influenced or otherwise untrusted data as the iface (network interface) parameter.
The risky behavior arises only along the retry path: when the initial sanitized scan returns no results, the library schedules a follow-up call using the original, unsanitized interface string in an OS command.
Exploit preconditions
- Attack surface: Any API endpoint, CLI option, configuration value, or integration that forwards an attacker-controlled string into
si.wifiNetworks(iface). - Required access: Ability to supply or influence the
ifaceargument (e.g., HTTP request parameter, web form field, query string, or environment/config entry). - Trigger point: The initial
wifiNetworks()call must yield an empty scan result so that the retry logic executes and invokesgetWifiNetworkListIw(iface)with the unsanitized parameter. - Why exploitation is possible: The retry path bypasses earlier sanitization and interpolates the raw
ifacestring intoexecSync('iwlist ${iface} scan'), enabling injection of shell metacharacters and additional commands.
Why this happens
The root cause is incomplete and inconsistent input sanitization around command construction.
In wifiNetworks(), the iface parameter is sanitized for the initial scan, but the retry logic later reuses the original, untrusted value and passes it directly into a shell command: execSync('iwlist ${iface} scan').
This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, where user-controllable input is concatenated into a command string without proper escaping or safe argument handling.
The bug illustrates a common pattern: secondary code paths (retries, fallbacks, and error handlers) are not held to the same sanitization and validation standards as the primary execution path.
Potential impact
- Execution of arbitrary shell commands with the privileges of the Node.js process
- Access to local files, environment variables, and service credentials available to the application
- Lateral movement within the host via installed tools or scripts
- Data exfiltration or destruction on the underlying system
- Use of the compromised process as a foothold for broader infrastructure compromise
General mitigation guidance
Effective mitigation focuses on avoiding string-based command construction and minimizing trust in external inputs:
- Prefer command execution APIs that accept argument arrays and do not invoke a shell by default, reducing opportunities for injection.
- Apply strict validation to any
ifaceparameter at the application boundary, enforcing a whitelist of expected network interface names and character sets. - Ensure that all code paths, including retries and fallbacks, operate only on sanitized or validated values rather than original raw inputs.
- Run Node.js processes with least privilege and constrained OS capabilities so that, if command execution occurs, the blast radius is limited.
- Consider separating Wi-Fi scanning into a dedicated, locked-down helper service or process with reduced permissions, instead of invoking system tools directly within the main application runtime.
How teams detect issues like this
Detection can rely on both code-centric and operational approaches:
- Static analysis: Scan for uses of
child_process.exec/execSyncwhere user-influenced parameters are interpolated into command strings, especially within utility libraries and retry logic. - Code review signals: Flag any API that accepts an interface or command-like string and later builds shell commands, paying special attention to error-handling and retry branches that may bypass sanitization.
- Policy enforcement: Establish coding standards that discourage shell-based command composition in shared libraries and require centralized validation helpers for OS-level interactions.
- Runtime monitoring: Observe application logs and process monitoring data for unusual invocations of
iwlistor unexpected child processes spawned by Node.js services, which may indicate exploitation attempts.

