Summary
WeKnora's MCP stdio configuration validation contains a command injection flaw that allows arbitrary command execution through crafted configuration values.
Because user registration is unrestricted, any remote attacker can create an account and exploit the flawed validation logic to run OS commands with the application's privileges, risking full system compromise.
Affected context
This vulnerability affects WeKnora deployments using versions 0.2.5 up to but not including 0.2.10, where MCP stdio configuration is accepted from user-controlled input.
The risk is present when:
- The application processes user-supplied MCP stdio configuration without strict, structural validation
- Command execution is proxied through wrappers like
npxoruvxbased on this configuration - The backend process runs with privileges that provide access to sensitive data or host resources
Exploit preconditions
- Attack surface: Remote, over the application interface that accepts or uses MCP stdio configuration.
- Required access: Ability to register a user (registration is open) and submit or influence MCP stdio configuration.
- Trigger point: Invocation of MCP stdio commands via
npx(or similar) using the attacker-controlled configuration, including arguments such as-p node. - Why exploitation is possible: The validation logic relies on allowlisting wrappers (
npx,uvx) and partial blacklisting of arguments and environment variables, but does not enforce a strict command model. This allows an attacker to smuggle arbitrary commands through permitted tools and flags that were not accounted for by the filters.
Why this happens
The root cause is an OS command injection pattern where user-controlled configuration is incorporated into command-line invocations without a non-bypassable separation between data and executable logic.
Instead of constraining configuration to a declarative, structured schema, the validation attempts to secure dynamic command construction with whitelists and blacklists. This defense is incomplete: options such as -p with npx node effectively reintroduce arbitrary code paths, enabling attackers to execute commands under the application's account.
This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, where input intended as data is interpreted as command syntax or execution logic.
Potential impact
- Execution of arbitrary OS commands with the application's privileges
- Complete compromise of the WeKnora application instance
- Exfiltration or tampering of documents, embeddings, and model outputs
- Lateral movement to other services reachable from the compromised host
- Installation of persistence mechanisms or malware on the server
- Use of the compromised environment as a pivot point in the wider infrastructure
General mitigation guidance
Effective mitigation focuses on eliminating dynamic command construction from user-controlled configuration and enforcing a strictly declarative execution model.
Pattern-based mitigations include:
- Replacing shell or process invocation of user-influenced commands with fixed, parameterized APIs that do not interpret arguments as shell syntax.
- Restricting MCP stdio configuration to a strongly-typed schema (e.g., enumerated tools, boolean flags, numeric limits) rather than free-form command strings or flags.
- Implementing a positive security model where the backend maps a small set of user-selectable options to pre-defined, internal command templates that are not directly modifiable by users.
- Avoiding blacklists for command-line arguments and environment variables; instead, build commands by explicit, positional parameter binding without passing through intermediate toolchains like
npxor generic runners. - Running the application under a dedicated, minimally privileged account with restricted filesystem and network permissions to limit blast radius if a flaw appears elsewhere.
How teams detect issues like this
Detection typically combines code-centric and operational approaches:
- Static analysis and code review:
- Flag any use of shell execution APIs (e.g.,
exec,spawnwithshell: true, command strings) that incorporate configuration or user-supplied values. - Identify validation routines that rely on string-based allowlists/blacklists rather than structural typing or explicit mapping of user choices to internal commands.
- Enforce coding standards that require parameterized process execution (arrays of arguments, disabled shell parsing) and prohibit passing arbitrary flags through intermediaries like
npx. - Policy and CI enforcement:
- Add automated checks in CI to block new uses of unsafe command construction patterns and require security review for any new external command integrations.
- Use secret scanning and configuration linting to detect unexpected command endpoints or user-controlled execution hooks.
- Runtime monitoring:
- Monitor process creation logs for unusual
npx,node, or similar invocations originating from the application. - Alert on unexpected flags or execution patterns that indicate arbitrary code being run via configuration-controlled paths.

