/

CVE-2025-51958

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in DokuWiki runcommand Plugin

CVE-2025-51958

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The aelsantex runcommand plugin for DokuWiki (version 2014-04-01) contains an OS command injection flaw that lets attackers execute arbitrary system commands via lib/plugins/runcommand/postaction.php.

Because the vulnerable endpoint is reachable without authentication, any remote user who can send HTTP requests to the DokuWiki instance may gain full command execution on the underlying server.

Affected context

This vulnerability appears in DokuWiki deployments that have the aelsantex runcommand plugin (2014-04-01) installed and enabled.

The issue resides in lib/plugins/runcommand/postaction.php, where user-controlled data influences shell command execution.

It becomes relevant when the DokuWiki instance is network-accessible and the plugin is exposed through web requests, especially when the web server user has access to sensitive system resources or other internal services.

Exploit preconditions

  • Attack surface: HTTP interface of a DokuWiki instance with the runcommand plugin enabled
  • Required access: No authentication required; attacker only needs network access to the DokuWiki web endpoint
  • Trigger point: A crafted web request to lib/plugins/runcommand/postaction.php that injects shell metacharacters or command fragments into parameters used by the plugin
  • Why exploitation is possible: The plugin passes unsanitized or insufficiently validated user input into command execution functions (e.g., shell, exec, or similar) without proper escaping or strict allowlisting, enabling arbitrary OS command concatenation

Why this happens

The root cause is an OS command injection flaw, aligning with CWE-78: Improper Neutralization of Special Elements used in an OS Command.

The runcommand plugin constructs shell commands that directly incorporate user-supplied data without robust neutralization of metacharacters and without constraining input to a safe, predefined set of operations.

By treating web request parameters as trusted command arguments, the code effectively delegates logic to the shell, allowing attackers to alter command behavior and inject new commands.

Potential impact

  • Remote execution of arbitrary system commands under the web server's privileges
  • Reading or modification of files accessible to the web server user
  • Retrieval of configuration secrets, API keys, or database credentials stored on the server
  • Pivoting to internal network services reachable from the DokuWiki host
  • Full server compromise if the web server runs with elevated privileges or can escalate further

General mitigation guidance

Mitigation usually centers on removing direct shell invocation paths and strictly limiting how external commands are called.

Useful defensive patterns include:

  • Avoiding shell-based command composition; use safer language-native APIs that do not invoke a shell, and pass arguments as structured parameters rather than concatenated strings
  • Applying strict allowlists of permitted commands and arguments, rejecting any input that does not match expected patterns
  • Rigorously validating and normalizing all user-supplied data before use, disallowing shell metacharacters and unexpected tokens
  • Isolating command-executing components using least-privilege accounts, chroot/jails, or containers to limit blast radius
  • Disabling or removing functionality that executes system commands unless it is essential and can be constrained by design

How teams detect issues like this

Detection typically combines code-centric and operational approaches:

  • Static analysis checks for dynamic command construction, especially uses of exec, shell_exec, system, passthru, or backticks with interpolated user input
  • Manual code reviews focused on plugin endpoints that process HTTP parameters and then build or execute shell commands
  • Security scanning rules that flag unvalidated parameters flowing into OS command execution APIs
  • Web application firewall (WAF) or reverse proxy rules tuned to detect and log suspicious command injection payloads (e.g., shell metacharacters, command separators)
  • Routine security testing (SAST/DAST) of plugins and extensions before deployment, with specific tests for command injection patterns

Sources

SourceLink
gist.github.comgist.github.com/NtustLin/f64528002e4f61874045799127dc49a4
github.comgithub.com/aelsantex/runcommand
dokuwiki.orgdokuwiki.org/plugin:runcommand

Frequently asked

questions

Yes. The vulnerable plugin endpoint is accessible over HTTP, and exploitation does not require local access or prior compromise, only network reachability to the DokuWiki server.

Based on the available information, no authentication is required. An unauthenticated attacker who can send requests to the affected endpoint can attempt to inject commands.

The safest pattern is to remove or redesign any feature that passes user input to a shell. When command execution is unavoidable, use non-shell APIs, enforce strict allowlists for commands and arguments, and avoid string concatenation with user-controlled data.

Adopt secure coding practices that prohibit direct shell calls with untrusted input, enforce input validation and output encoding policies, add security-focused code review for plugin features, and integrate static analysis and security testing into the development and deployment process.

Find out what's already
exploitable in your codebase.