fix: enhance security by validating and escaping database names, file paths, and proxy configuration filenames #7375
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances security across database backup operations, file storage management, PostgreSQL init scripts, and proxy configuration handling by implementing comprehensive input validation and shell argument escaping to prevent command injection attacks.
Changes
validateShellSafePath()validation calls for database names in backup operations (MongoDB, PostgreSQL, MySQL, MariaDB)escapeshellarg()escaping for all shell commands involving user-provided paths and filenamesTesting
Added comprehensive security test suites:
DatabaseBackupSecurityTest.php- Tests command injection prevention in database backup operationsFileStorageSecurityTest.php- Tests path validation and escaping for file storagePostgresqlInitScriptSecurityTest.php- Tests filename validation for PostgreSQL init scriptsProxyConfigurationSecurityTest.php- Tests filename validation for proxy configurationsAll tests verify that malicious inputs are rejected and legitimate inputs are properly escaped.