Skip to content

Commit 286101e

Browse files
committed
update.php fixes
Re-check the resolved #command path stays inside the document root before executing it, so an authenticated request cannot use realpath() traversal (e.g. starting at $docroot then '../') to run a binary outside the webgui. Refs: OS-489
1 parent de7bf2f commit 286101e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

emhttp/update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function write_log($string) {
114114
if (strpos($command, $docroot) !== 0)
115115
$command = "$docroot/$command";
116116
$command = realpath($command);
117-
if ($command === false)
117+
if ($command === false || strpos($command, rtrim(realpath($docroot), '/') . '/') !== 0)
118118
syslog(LOG_INFO, "Invalid #command: {$_POST['#command']}");
119119
else {
120120
$command = escapeshellcmd($command);

0 commit comments

Comments
 (0)