Summary
sysPass through version 3.2.11 contains an OS command injection flaw in its backup feature that lets authenticated administrators run arbitrary commands as the web server user.
By configuring a crafted backup path, an attacker can inject shell syntax into the tar command built by FileBackupService, causing the injected commands to execute on every backup trigger.
Affected context
This vulnerability occurs in sysPass instances where the backup functionality is enabled and administrators can configure the siteBackupPath setting. The FileBackupService constructs a tar shell command via direct string concatenation and passes it to exec() without properly sanitizing or escaping the path segment. Under these conditions, any shell metacharacters embedded in the backup path can be interpreted by the underlying shell, turning configuration data into executable commands whenever a backup is started.
Exploit preconditions
- Attack surface: Application backup configuration and backup execution endpoint or workflow.
- Required access: Authenticated administrator-level access to modify the
siteBackupPathsetting, or equivalent privilege to influence backup configuration. - Trigger point: Initiation of the backup process (manual backup trigger, scheduled backup job, or any code path that invokes FileBackupService).
- Why exploitation is possible: The backup path value is interpolated directly into a shell command string without using
escapeshellarg()or equivalent safeguards, and the command is executed viaexec(), allowing shell metacharacters to alter command behavior and run arbitrary OS commands.
Why this happens
The underlying bug is a classic OS command injection pattern: user-configurable input is concatenated into a shell command and executed without strict validation or safe escaping. In sysPass, FileBackupService builds a tar command string by inserting the configured siteBackupPath directly into the command line, then hands it to exec(). Because this input is not constrained to a benign filename/path format and is interpreted by a shell, attackers can inject additional commands using shell metacharacters. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where application logic fails to neutralize or avoid special characters before command execution.
Potential impact
- Arbitrary command execution as the web server process user.
- Reading or exfiltrating sensitive data accessible to the application.
- Modifying or deleting application data and backup archives.
- Installing backdoors or additional malicious tooling on the server.
- Using the compromised server as a pivot for further internal network attacks.
General mitigation guidance
Effective mitigation focuses on removing or strictly constraining the use of shell commands built from dynamic input. Common defensive patterns include:
- Avoiding shell-based command construction for backups and using library APIs or safe process invocation mechanisms that accept structured arguments rather than free-form command strings.
- Treating all configuration values, including administrator-supplied paths, as untrusted and enforcing strict validation (e.g., allowing only expected path formats without shell metacharacters).
- Applying robust escaping or argument-quoting routines when invoking external tools, ensuring user-controlled data is passed as individual arguments instead of being embedded in a full shell command line.
- Running the web server and application components under least-privilege accounts, and limiting file system and OS-level privileges to minimize the impact if command execution occurs.
- Designing backup routines so that high-risk operations (like external tool invocation) are centralized and scrutinized, reducing opportunities for subtle injection via configuration options.
How teams detect issues like this
Detection typically involves a combination of code-level and operational checks:
- Static analysis rules that flag uses of
exec(),shell_exec(),system(), or similar functions when they are fed concatenated strings with user- or configuration-controlled data. - Secure code review practices that focus on backup and maintenance scripts, looking for command construction patterns using configuration values such as paths, filenames, or options without clear validation or escaping.
- Application security testing that attempts to inject simple shell metacharacters into configurable paths and observes whether backup or maintenance tasks behave unexpectedly.
- Policy-based enforcement in CI/CD pipelines that restrict or require justification for shell command usage, coupled with automated tooling to identify and highlight high-risk patterns.

