Summary
Synway SMG Gateway Management Software contains an OS command injection flaw in the RADIUS configuration endpoint, where user-controlled parameters are interpolated directly into a sed command without sanitization.
An unauthenticated remote attacker can send crafted POST requests to execute arbitrary shell commands on the underlying system, leading to full remote code execution when RADIUS configuration is saved and enabled.
Affected context
This vulnerability occurs in the web-based management interface of Synway SMG Gateway when handling RADIUS configuration requests at /en/9-2radius.php.
The issue is present where parameters such as radius_address, radius_address2, shared_secret2, source_ip, timeout, and retry are accepted from HTTP POST data and subsequently used to construct shell commands (via sed) without robust sanitization.
The risk is highest in deployments where the management interface is network-accessible from untrusted networks or exposed to the internet, and where the web server process has broad system privileges.
Exploit preconditions
- Attack surface: HTTP POST endpoint
/en/9-2radius.phpwithin the gateway management web application. - Required access: None; exploitation is possible by an unauthenticated remote user able to reach the management interface over the network.
- Trigger point: Submission of a crafted POST request that includes parameters such as
radius_address,radius_address2,shared_secret2,source_ip,timeout, orretryalong withsave=1andenable_radius=1. - Why exploitation is possible: User-supplied values are split and interpolated directly into a
sedshell command without proper escaping or validation, allowing shell metacharacters or command separators to alter the intended command and execute arbitrary OS commands under the web server's privileges.
Why this happens
The root cause maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
The application dynamically builds a shell command (using sed) incorporating untrusted input fields from the HTTP POST body.
Because these values are not strictly validated, constrained, or safely escaped, shell metacharacters and additional command fragments can be injected.
This design pattern—constructing command-line strings from user input and passing them to a shell interpreter—creates a direct channel for attackers to execute arbitrary commands rather than just influencing configuration content.
Potential impact
- Remote execution of arbitrary system commands under the account running the web management service.
- Installation of backdoors, web shells, or persistence mechanisms on the device.
- Exfiltration or tampering with configuration data, including RADIUS secrets and other authentication-related settings.
- Use of the compromised gateway as a pivot point for further attacks within the internal network.
- Disruption of telephony or network services managed by the gateway, potentially causing denial of service.
General mitigation guidance
Effective mitigation focuses on eliminating direct shell command construction from untrusted input and constraining how configuration changes are applied.
Recommended patterns include:
- Avoid invoking shell utilities for configuration updates; prefer native language APIs or libraries to manipulate configuration files directly in memory.
- Where external commands are unavoidable, use parameterized execution interfaces (e.g., exec-family calls with argument arrays) and avoid passing through a shell.
- Apply strict allowlists and validation on all configuration parameters, limiting them to expected formats (e.g., IP addresses, hostnames, numeric ranges) and rejecting any unexpected characters or patterns.
- Run the management interface with least privilege, ensuring that even if command execution occurs, the process has minimal access to system resources.
- Reduce exposure of the management interface by segmenting it onto dedicated management networks, enforcing strong access controls, and disabling remote access from untrusted networks.
How teams detect issues like this
Detection can leverage both code-level and operational monitoring techniques:
- Static analysis: Configure rules or linters to flag instances where user-supplied variables are concatenated into command strings or passed to shell execution functions. Look for patterns such as
system(),exec*(),shell_exec(), or backtick operators that incorporate request parameters. - Code review: During security-focused reviews, identify any reliance on shell utilities (
sed,awk,sh, etc.) for configuration handling and verify that all inputs are strictly validated and escaped or replaced with safer alternatives. - Runtime monitoring: Observe logs for anomalous RADIUS configuration changes, unexpected process invocations, or unusual commands spawned by the web server process.
- WAF and IDS/IPS policies: Deploy detection signatures looking for shell metacharacters and typical command injection patterns in HTTP POST bodies targeting management endpoints, while tuning to reduce false positives in normal administrative traffic.

