Summary
Roxy-WI's central EscapedString Pydantic validator incompletely validates user input, allowing directory traversal patterns to bypass filtering when combined with certain metacharacters.
An attacker who crafts specific payloads may inject dangerous path segments and shell-sensitive data into multiple fields, creating conditions for command or path manipulation where these values are later used.
Affected context
This vulnerability occurs in Roxy-WI deployments that rely on the EscapedString validator to sanitize user-controlled fields such as SSH credential names, usernames, descriptions, and similar metadata.
In these contexts, the validator strips certain metacharacters but fails to consistently block .. path traversal tokens, particularly when the payload is suffixed with characters like ;, &, |, $, or backticks.
The risk is elevated wherever these validated fields are later used to build file paths, log messages, or shell commands without additional escaping or quoting.
Exploit preconditions
- Attack surface: Web interface (HTTP(S)) endpoints that accept fields validated via EscapedString
- Required access: Ability to submit or modify records using fields such as SSH credential name, username, description, or similar text inputs
- Trigger point: Application code paths that consume these validated fields to construct file paths, log entries, or shell commands
- Why exploitation is possible: The conditional logic in EscapedString returns a metacharacter-stripped value but does not always enforce the
..blocking branch, and the resulting string is not safely quoted with mechanisms likeshlex.quote()before being incorporated into downstream operations
Why this happens
The core problem is an improper input validation pattern where a shared Pydantic validator attempts to sanitize many different fields via a hand-written if/elif/else chain.
The logic prioritizes stripping certain shell metacharacters over reliably rejecting or normalizing directory traversal sequences such as ... When an attacker appends ;, &, |, $, or backticks to a .. payload, execution flows into the branch that removes those metacharacters but leaves .. intact.
This behavior aligns with CWE-20 (Improper Input Validation) and is closely related to CWE-22 (Path Traversal), since untrusted values containing .. may later influence filesystem paths, and CWE-117 (Improper Output Neutralization for Logs) when unsafe values are written to logs. The validator also fails to apply robust output encoding (such as shell quoting) at the point where data is later consumed, leading to fragile security assumptions about "sanitized" inputs.
Potential impact
- Attackers may inject
..segments into values that are later used to construct filesystem paths, enabling directory traversal if no further checks exist. - User-controlled fields can carry shell-sensitive content that is not safely quoted, potentially enabling command injection in consuming code paths.
- Log files may capture unneutralized attacker-controlled strings, which can interfere with log parsing or facilitate log injection attacks.
- Misconfiguration or abuse of SSH-related metadata may lead to unauthorized access workflows or manipulation of automation scripts that rely on these fields.
General mitigation guidance
Effective mitigation typically involves replacing ad hoc sanitization logic with explicit, context-aware validation and encoding patterns.
Common defensive approaches include:
- Implement strict allowlists for fields like usernames, credential names, and descriptions, defining exactly which characters and patterns are permitted.
- Validate paths using dedicated path-handling utilities that normalize and enforce confinement to known base directories, rejecting any input containing
..or absolute paths. - Separate validation from output encoding: validate inputs for allowed structure, then apply context-specific encoding (e.g., shell quoting, URL encoding, HTML escaping) at each usage site.
- Avoid building shell commands via string concatenation; instead, use structured APIs (e.g., exec with argument vectors) and pass user input as separate parameters.
- Treat all user-controlled metadata as untrusted even after validation, and apply defense-in-depth by re-checking and constraining values near sensitive operations.
How teams detect issues like this
Detection efforts can focus on both code-level patterns and runtime behavior.
Code-focused strategies:
- Static analysis rules that flag manual sanitization routines handling shell metacharacters or
..patterns without strict allowlists. - Search-based reviews for conditional chains that treat multiple input types via a single validator, especially where different branches perform inconsistent checks.
- Identification of code paths that compose shell commands, filesystem paths, or log messages using user-controlled fields without context-specific encoding.
Runtime and process-focused strategies:
- Application security tests (SAST/DAST) that inject payloads combining
..and shell metacharacters into affected fields to observe traversal or injection behavior. - Log review and monitoring for suspicious path or command patterns derived from user-controlled inputs.
- Integration of automated security scanning tools in CI/CD pipelines to enforce policies on path handling and command construction.

