Summary
ShowDoc's Mock feature can evaluate stored mockjs templates as code, allowing an authenticated user to execute shell commands when a template is triggered. The risk is greatest when users who can create or manage mock templates are not fully trusted, and the official Docker image may run the resulting commands as root.
ShowDoc's Mock feature can evaluate stored mockjs templates as code, allowing an authenticated user to execute shell commands when a template is triggered. The risk is greatest when users who can create or manage mock templates are not fully trusted, and the official Docker image may run the resulting commands as root.
Affected context
The vulnerability is in ShowDoc's Mock feature, where templates are stored through the mock-management flow and evaluated when requested. It affects versions 2.8.14 through releases before 3.9.6 when an authenticated user can store a template that reaches an unsafe evaluation path. In the official Docker image, command execution may occur with root privileges.
The vulnerability is in ShowDoc's Mock feature, where templates are stored through the mock-management flow and evaluated when requested. It affects versions 2.8.14 through releases before 3.9.6 when an authenticated user can store a template that reaches an unsafe evaluation path. In the official Docker image, command execution may occur with root privileges.
Exploit preconditions
- Attack surface: The Mock feature's template creation and retrieval functionality
- Required access: Authentication and permission to add or manage mock templates
- Trigger point: A stored template is evaluated when the corresponding mock information is requested
- Why exploitation is possible: Template content reaches an evaluation mechanism that can interpret attacker-controlled content as executable code
- Attack surface: The Mock feature's template creation and retrieval functionality
- Required access: Authentication and permission to add or manage mock templates
- Trigger point: A stored template is evaluated when the corresponding mock information is requested
- Why exploitation is possible: Template content reaches an evaluation mechanism that can interpret attacker-controlled content as executable code
Why this happens
The underlying issue is code injection, mapped to CWE-94: Improper Control of Generation of Code. The Mock feature evaluates template content as code rather than treating it strictly as data. When users can influence content that reaches this evaluation path, the application may execute unintended commands.
The underlying issue is code injection, mapped to CWE-94: Improper Control of Generation of Code. The Mock feature evaluates template content as code rather than treating it strictly as data. When users can influence content that reaches this evaluation path, the application may execute unintended commands.
Potential impact
- An authenticated user could execute shell commands in the ShowDoc runtime
- The application environment could be compromised
- In the official Docker image, commands may run with root privileges
- An attacker could potentially access or alter data available to the compromised runtime
- An authenticated user could execute shell commands in the ShowDoc runtime
- The application environment could be compromised
- In the official Docker image, commands may run with root privileges
- An attacker could potentially access or alter data available to the compromised runtime
General mitigation guidance
Defensive patterns focus on keeping user-controlled template content out of executable evaluation paths.
- Prefer a data-only template engine or a restricted expression language over general-purpose evaluation.
- Treat templates as untrusted input and apply strict allowlisting and validation before storage and use.
- Separate template authorship from the ability to trigger or publish templates where practical.
- Run application containers and services with least privilege, avoiding root where possible.
- Use isolation and resource limits to reduce the consequences of a compromised runtime.
Defensive patterns focus on keeping user-controlled template content out of executable evaluation paths.
- Prefer a data-only template engine or a restricted expression language over general-purpose evaluation.
- Treat templates as untrusted input and apply strict allowlisting and validation before storage and use.
- Separate template authorship from the ability to trigger or publish templates where practical.
- Run application containers and services with least privilege, avoiding root where possible.
- Use isolation and resource limits to reduce the consequences of a compromised runtime.
How teams detect issues like this
- Use static analysis to identify dynamic evaluation functions and flows from user-controlled template fields.
- Review Mock template creation, storage, and retrieval paths for unsafe interpretation of stored content.
- Apply code review checks that flag user input passed to evaluators, interpreters, or shell execution APIs.
- Enforce policies that prohibit general-purpose evaluation of user-controlled content and monitor for unexpected child processes.
- Automated code review tools may help identify risky data flows for further assessment.
- Use static analysis to identify dynamic evaluation functions and flows from user-controlled template fields.
- Review Mock template creation, storage, and retrieval paths for unsafe interpretation of stored content.
- Apply code review checks that flag user input passed to evaluators, interpreters, or shell execution APIs.
- Enforce policies that prohibit general-purpose evaluation of user-controlled content and monitor for unexpected child processes.
- Automated code review tools may help identify risky data flows for further assessment.

