File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 11
11
$ magentoObjectManager = $ magentoObjectManagerFactory ->create ($ _SERVER );
12
12
$ tokenModel = $ magentoObjectManager ->get (\Magento \Integration \Model \Oauth \Token::class);
13
13
14
- $ tokenPassedIn = urldecode ($ _POST ['token ' ]);
15
- $ command = urldecode ($ _POST ['command ' ]);
16
- $ arguments = urldecode ($ _POST ['arguments ' ]);
14
+ $ tokenPassedIn = urldecode ($ _POST ['token ' ] ?? '' );
15
+ $ command = urldecode ($ _POST ['command ' ] ?? '' );
16
+ $ arguments = urldecode ($ _POST ['arguments ' ] ?? '' );
17
17
18
18
// Token returned will be null if the token we passed in is invalid
19
19
$ tokenFromMagento = $ tokenModel ->loadByToken ($ tokenPassedIn )->getToken ();
22
22
$ magentoBinary = $ php . ' -f ../../../../bin/magento ' ;
23
23
$ valid = validateCommand ($ magentoBinary , $ command );
24
24
if ($ valid ) {
25
- $ fullCommand = escapeshellcmd ($ magentoBinary . " $ command " . " $ arguments " );
26
- $ process = new Symfony \Component \Process \Process ($ fullCommand );
25
+ $ fullCommand = $ magentoBinary . " $ command " . " $ arguments " ;
26
+ $ escapedCommand = escapeshellcmd ($ fullCommand );
27
+ if ($ fullCommand !== $ escapedCommand ) {
28
+ http_response_code (403 );
29
+ echo ("Unsafe characters detected, command was not executed. " );
30
+ return ;
31
+ }
32
+ $ process = new Symfony \Component \Process \Process ($ escapedCommand );
27
33
$ process ->setIdleTimeout (60 );
28
34
$ process ->setTimeout (0 );
29
35
$ idleTimeout = false ;
You can’t perform that action at this time.
0 commit comments