Skip to content

Commit aa05fe7

Browse files
committed
fix: prevent command injection by specifing arbitrary filename
1 parent 2adb15e commit aa05fe7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Util/XML.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public static function decodeP7M($file)
9595

9696
$output_file = $directory.'/'.basename($file, '.p7m');
9797

98+
// Validate that file path doesn't contain shell metacharacters
99+
if (preg_match('/[;&|`$(){}\\[\\]<>]/', $file)) {
100+
throw new \Exception('Invalid file path');
101+
}
102+
98103
try {
99104
if (function_exists('exec')) {
100105
exec('openssl smime -verify -noverify -in "'.$file.'" -inform DER -out "'.$output_file.'"', $output, $cmd);

0 commit comments

Comments
 (0)