Skip to content

fix: escape shell arguments in SDE import command to prevent command injection#447

Open
cchopin wants to merge 1 commit into
eveseat:masterfrom
cchopin:fix/sde-command-injection
Open

fix: escape shell arguments in SDE import command to prevent command injection#447
cchopin wants to merge 1 commit into
eveseat:masterfrom
cchopin:fix/sde-command-injection

Conversation

@cchopin
Copy link
Copy Markdown

@cchopin cchopin commented May 11, 2026

Security Fix: Command Injection in SDE Update Command

Vulnerability

The seat:eve:update:sde Artisan command builds a mysql shell command by directly concatenating user-supplied options (database host, user, password, name) without escaping:

exec('mysql --user=' . $this->option('db-user') . ' ...');

Impact

An administrator running this command with malicious or unexpected characters in CLI options could trigger unintended shell execution. While this command requires administrative access to run, proper shell escaping is a fundamental security practice that prevents unexpected behavior from special characters (spaces, quotes, semicolons, backticks) in any configuration value.

Examples of inputs that would cause unexpected behavior without escaping:

  • A database name containing a space: my database → splits into two shell tokens
  • A password containing $(...) → triggers command substitution
  • A value containing ; → allows command chaining

Fix

Wrapped all dynamic values passed to shell commands with escapeshellarg(), which correctly quotes and escapes the value for safe use as a single shell argument regardless of its content.

This fix covers both the MySQL and PostgreSQL import paths, including:

  • importMysqlSde(): username, password (replacing the incorrect escapeshellcmd() usage), host, port, database name, and the extracted SQL file path
  • importPgSqlSde(): password (in PGPASSWORD env var assignment), database name, host, port, username, table names, and the extracted dump file path

References

@cchopin cchopin force-pushed the fix/sde-command-injection branch from ff5fc81 to 298e00b Compare May 11, 2026 18:35
…injection

All values interpolated into the mysql and pg_restore shell commands
(username, password, host, port, database, file path, table names)
are now wrapped with escapeshellarg() to prevent shell injection if
any configuration value contains special characters.
@cchopin cchopin force-pushed the fix/sde-command-injection branch from 298e00b to 4cafa90 Compare May 11, 2026 18:51
@recursivetree
Copy link
Copy Markdown
Contributor

Thank you for the report. We will investigate it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants