Summary
A critical PHP code injection vulnerability in DedeCMS allows unauthenticated attackers to influence template content through the HTTP Referer header. Under affected configurations, crafted requests may cause the application to interpret attacker-controlled content as PHP and execute arbitrary PHP or system commands.
A critical PHP code injection vulnerability in DedeCMS allows unauthenticated attackers to influence template content through the HTTP Referer header. Under affected configurations, crafted requests may cause the application to interpret attacker-controlled content as PHP and execute arbitrary PHP or system commands.
Affected context
The vulnerability occurs in DedeCMS deployments through 5.8.1-beta where the ShowMsg() function processes a Referer value through a DedeTemplate string and includes the resulting content. The relevant request flow involves the link-management endpoint at /plus/flink.php?dopost=save, with exploitation depending on the application accepting the request without a valid verification code.
The vulnerability occurs in DedeCMS deployments through 5.8.1-beta where the ShowMsg() function processes a Referer value through a DedeTemplate string and includes the resulting content. The relevant request flow involves the link-management endpoint at /plus/flink.php?dopost=save, with exploitation depending on the application accepting the request without a valid verification code.
Exploit preconditions
- Attack surface: Publicly reachable DedeCMS HTTP request handling
- Required access: No authenticated account is generally required
- Trigger point: Processing of the link-saving request and subsequent ShowMsg() template handling
- Relevant input: The HTTP Referer header and request validation state
- Why exploitation is possible: Attacker-controlled header data can reach a template inclusion path where it may be interpreted as PHP code rather than treated solely as data
- Attack surface: Publicly reachable DedeCMS HTTP request handling
- Required access: No authenticated account is generally required
- Trigger point: Processing of the link-saving request and subsequent ShowMsg() template handling
- Relevant input: The HTTP Referer header and request validation state
- Why exploitation is possible: Attacker-controlled header data can reach a template inclusion path where it may be interpreted as PHP code rather than treated solely as data
Why this happens
The underlying bug is an unsafe code-generation and template-inclusion pattern. Data derived from an HTTP header is inserted into a DedeTemplate string and included without reliably separating untrusted content from executable PHP logic. This behavior maps to CWE-94: Improper Control of Generation of Code, because externally influenced data can affect dynamically generated or evaluated code.
The underlying bug is an unsafe code-generation and template-inclusion pattern. Data derived from an HTTP header is inserted into a DedeTemplate string and included without reliably separating untrusted content from executable PHP logic. This behavior maps to CWE-94: Improper Control of Generation of Code, because externally influenced data can affect dynamically generated or evaluated code.
Potential impact
- Attackers may execute arbitrary PHP code in the web application process.
- Attackers could execute operating-system commands with the permissions of the hosting service.
- Website content, credentials, and application data may be exposed or modified.
- The server could be used for persistence, malware deployment, or further network access.
- Availability may be affected through destructive commands or resource consumption.
- Attackers may execute arbitrary PHP code in the web application process.
- Attackers could execute operating-system commands with the permissions of the hosting service.
- Website content, credentials, and application data may be exposed or modified.
- The server could be used for persistence, malware deployment, or further network access.
- Availability may be affected through destructive commands or resource consumption.
General mitigation guidance
Mitigation generally focuses on preventing request-derived data from reaching executable template or inclusion paths.
Defensive patterns include:
- Treating HTTP headers and other request values as untrusted data at every processing layer.
- Using context-safe output encoding and non-executable template rendering.
- Removing dynamic PHP generation or inclusion where static templates and explicit data binding are sufficient.
- Enforcing verification and authorization checks before any state-changing processing or response-template generation.
- Running the application with least-privilege service accounts and restricting filesystem and process permissions.
- Applying centralized web-application policies that limit suspicious requests and unexpected template-related input.
Mitigation generally focuses on preventing request-derived data from reaching executable template or inclusion paths.
Defensive patterns include:
- Treating HTTP headers and other request values as untrusted data at every processing layer.
- Using context-safe output encoding and non-executable template rendering.
- Removing dynamic PHP generation or inclusion where static templates and explicit data binding are sufficient.
- Enforcing verification and authorization checks before any state-changing processing or response-template generation.
- Running the application with least-privilege service accounts and restricting filesystem and process permissions.
- Applying centralized web-application policies that limit suspicious requests and unexpected template-related input.
How teams detect issues like this
High-level detection approaches include:
- Static analysis for request parameters or headers flowing into
include,require, dynamic evaluation, template compilation, or generated PHP. - Code review checks for response helpers that concatenate untrusted values into template source.
- Runtime monitoring for unusual PHP process behavior, child-process creation, command execution, or modifications to web-accessible files.
- Web-application logs focused on unexpected Referer values, repeated requests to link-management endpoints, and validation failures preceding successful state changes.
- CI and policy checks that prohibit dynamic code construction from externally controlled input.
- Neutral automated security-review tools may help identify tainted data flows, but findings should be validated against the application's actual rendering behavior.
High-level detection approaches include:
- Static analysis for request parameters or headers flowing into
include,require, dynamic evaluation, template compilation, or generated PHP. - Code review checks for response helpers that concatenate untrusted values into template source.
- Runtime monitoring for unusual PHP process behavior, child-process creation, command execution, or modifications to web-accessible files.
- Web-application logs focused on unexpected Referer values, repeated requests to link-management endpoints, and validation failures preceding successful state changes.
- CI and policy checks that prohibit dynamic code construction from externally controlled input.
- Neutral automated security-review tools may help identify tainted data flows, but findings should be validated against the application's actual rendering behavior.

