Skip to content

Commit

Permalink
Disable Entity Loader before reading XML
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Suarez committed Feb 19, 2019
1 parent 9f98417 commit a7e0833
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/recurly/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ public function getLinks() {
// Use a valid Recurly_Response to populate a new object.
protected static function __parseResponseToNewObject($response, $uri, $client) {
$dom = new DOMDocument();

// Attempt to prevent XXE that could be exploited through loadXML()
libxml_disable_entity_loader(true);

if (empty($response->body) || !$dom->loadXML($response->body, LIBXML_NOBLANKS)) {
return null;
}
Expand All @@ -305,6 +309,10 @@ protected function _afterParseResponse($response, $uri) { }
protected function __parseXmlToUpdateObject($xml)
{
$dom = new DOMDocument();

// Attempt to prevent XXE that could be exploited through loadXML()
libxml_disable_entity_loader(true);

if (empty($xml) || !$dom->loadXML($xml, LIBXML_NOBLANKS)) return null;

$rootNode = $dom->documentElement;
Expand Down
4 changes: 4 additions & 0 deletions lib/recurly/push_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function __construct($post_xml)

function parseXml($post_xml)
{

// Attempt to prevent XXE that could be exploited through simplexml_load_string()
libxml_disable_entity_loader(true);

if (!@simplexml_load_string ($post_xml)) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/recurly/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public function assertValidResponse()

private function parseErrorXml($xml) {
$dom = new DOMDocument();

// Attempt to prevent XXE that could be exploited through loadXML()
libxml_disable_entity_loader(true);

if (empty($xml) || !$dom->loadXML($xml)) return null;

$rootNode = $dom->documentElement;
Expand Down

0 comments on commit a7e0833

Please sign in to comment.