Summary
XunRuiCMS has a code injection flaw in the Mobile Site Directory, where remote manipulation of the dirname argument used by str_replace can affect application code handling. If the affected code path is reachable, an attacker may be able to cause server-side code execution.
Affected context
The issue is reported in XunRuiCMS versions up to 4.7.4, in the Mobile Site Directory component's /var/www/html/zzmob/index.php file. The affected path involves the str_replace function and its dirname argument. The description indicates that the attack can be launched remotely; the exact deployment and access conditions may affect exposure.
Exploit preconditions
- Attack surface: A remotely reachable path in the Mobile Site Directory
- Required access: The description does not specify whether authentication is required.
- Trigger point: Handling of the
dirnameargument in the affectedstr_replacecode path - Why exploitation is possible: Manipulation of this argument is reported to result in code injection; the precise implementation details are not provided.
Why this happens
The reported behavior maps primarily to CWE-94: Improper Control of Generation of Code ('Code Injection'). It also relates to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component. At a general level, the flaw occurs when attacker-influenced input can alter content that is subsequently interpreted as code, rather than being constrained to ordinary data.
Potential impact
- An attacker may be able to execute code in the application server's context.
- The application or its data could be compromised.
- The server may be used to access other resources available to the application.
- Depending on the server's privileges and network access, the impact could extend to connected systems.
General mitigation guidance
Defensive approaches focus on preventing untrusted input from influencing executable code.
- Keep user-controlled values as data; avoid incorporating them into generated or evaluated code.
- Apply strict allowlist validation to directory-related inputs and reject unexpected values.
- Use safe APIs and fixed mappings for directory selection instead of constructing code or paths from raw input.
- Run the application with least-privilege access to files, processes, and connected services.
- Limit remote exposure of sensitive administrative and site-management functionality.
How teams detect issues like this
- Use static analysis to identify user-controlled values that flow into code-generation, evaluation, or sensitive string-processing paths.
- Review the
dirnamehandling and nearby data flows for validation, escaping, and use in downstream interpreters. - Add tests and policy checks that reject unexpected directory values and prevent input from becoming executable content.
- Monitor application and server logs for unusual requests targeting the Mobile Site Directory or repeated errors in the affected code path.
- Automated code review tools may help identify risky input-to-code flows.

