Harden against serialization vulnerabilities (#46)
authorTim Otten <totten@civicrm.org>
Tue, 5 Mar 2019 00:05:06 +0000 (16:05 -0800)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 14 May 2019 21:44:41 +0000 (07:44 +1000)
CRM/Utils/AutoClean.php

index 558ca34adb7ff157ca04ad43b869c070335432e0..c2c21dc1849a2222fced03049b4d99de5f7a1afa 100644 (file)
@@ -102,4 +102,24 @@ class CRM_Utils_AutoClean {
     \Civi\Core\Resolver::singleton()->call($this->callback, $this->args);
   }
 
+  /**
+   * Prohibit (de)serialization of CRM_Utils_AutoClean.
+   *
+   * The generic nature of AutoClean makes it a potential target for escalating
+   * serialization vulnerabilities, and there's no good reason for serializing it.
+   */
+  public function __sleep() {
+    throw new \RuntimeException("CRM_Utils_AutoClean is a runtime helper. It is not intended for serialization.");
+  }
+
+  /**
+   * Prohibit (de)serialization of CRM_Utils_AutoClean.
+   *
+   * The generic nature of AutoClean makes it a potential target for escalating
+   * serialization vulnerabilities, and there's no good reason for deserializing it.
+   */
+  public function __wakeup() {
+    throw new \RuntimeException("CRM_Utils_AutoClean is a runtime helper. It is not intended for deserialization.");
+  }
+
 }