diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php
index f1363e6..f8b4725 100644
--- a/core/lib/Drupal/Core/Config/DatabaseStorage.php
+++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php
@@ -150,24 +150,65 @@ public function rename($name, $new_name) {
   }
 
   /**
-   * Implements Drupal\Core\Config\StorageInterface::encode().
+   * {@inheritdoc}
    */
   public function encode($data) {
-    return serialize($data);
+    return $this->encodeXml(new \SimpleXMLElement('<array></array>'), $data)->asXML();
   }
 
   /**
-   * Implements Drupal\Core\Config\StorageInterface::decode().
+   * Recursively encodes a value as XML.
    *
-   * @throws ErrorException
-   *   unserialize() triggers E_NOTICE if the string cannot be unserialized.
+   * @param \SimpleXMLElement $simplexml
+   *   The simplexml element to add the encoding too.
+   * @param mixed $value
+   *   The value to be encoded.
+   * @param string $key
+   *   The key in the parent array, NULL for the top element.
+   */
+  protected function encodeXml(\SimpleXMLElement $simplexml, $value, $key = NULL) {
+    if (isset($key)) {
+      $simplexml = $simplexml->addChild(gettype($value), is_array($value) ? '' : (string) $value);
+      $simplexml->addAttribute('key', $key);
+    }
+    if (is_array($value)) {
+      foreach ($value as $new_key => $new_value) {
+        $this->encodeXml($simplexml, $new_value, $new_key);
+      }
+    }
+    return $simplexml;
+  }
+
+  /**
+   * {@inheritdoc}
    */
   public function decode($raw) {
-    $data = @unserialize($raw);
+    $data = @$this->decodeXml(new \SimpleXMLElement($raw));
     return is_array($data) ? $data : FALSE;
   }
 
   /**
+   * Decodes the XML produced by encodeXml.
+   *
+   * @param \SimpleXMLElement $simplexml
+   *   This contains the XML.
+   */
+  protected function decodeXml(\SimpleXMLElement $simplexml) {
+    $type = $simplexml->getName();
+    if ($type == 'array') {
+      $value = array();
+      foreach ($simplexml as $element) {
+        $value[(string) $element['key']] = $this->decodeXml($element);
+      }
+    }
+    else {
+      $value = (string) $simplexml;
+      settype($value, $type);
+    }
+    return $value;
+  }
+
+  /**
    * Implements Drupal\Core\Config\StorageInterface::listAll().
    *
    * @throws PDOException
diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php
index 516bb9d..46463bd 100644
--- a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php
@@ -55,7 +55,7 @@ function setUp() {
 
   protected function read($name) {
     $data = db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name))->fetchField();
-    return unserialize($data);
+    return $this->storage->decode($data);
   }
 
   protected function insert($name, $data) {
