Skip to content
Snippets Groups Projects
Commit e60d4802 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Disable the loading of external entities in XML documents.

To prevent local and remote file inclusion attacks. This is in most cases
already disabled by default in system libraries, so this will be a no-op to
most systems, but to be safe we explicitly disable it also.

Fixes #74
parent 499e21fe
No related branches found
No related tags found
No related merge requests found
...@@ -1930,6 +1930,17 @@ class SimpleSAML_Utilities { ...@@ -1930,6 +1930,17 @@ class SimpleSAML_Utilities {
date_default_timezone_set($serverTimezone); date_default_timezone_set($serverTimezone);
} }
/**
* Disable the loading of external entities in XML documents to prevent local and
* remote file inclusion attacks. This is in most cases already disabled by default
* in system libraries, but to be safe we explicitly disable it also.
*/
public static function disableXMLEntityLoader() {
/* Function only present in PHP >= 5.2.11 while we support 5.2+ */
if ( function_exists('libxml_disable_entity_loader') ) {
libxml_disable_entity_loader();
}
}
/** /**
* Atomically write a file. * Atomically write a file.
......
...@@ -107,5 +107,5 @@ if (!file_exists($configdir . '/config.php')) { ...@@ -107,5 +107,5 @@ if (!file_exists($configdir . '/config.php')) {
/* Set the timezone. */ /* Set the timezone. */
SimpleSAML_Utilities::initTimezone(); SimpleSAML_Utilities::initTimezone();
/* Disable XML external entity loading explicitly. */
?> SimpleSAML_Utilities::disableXMLEntityLoader();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment