Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99523 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22842 invoked from network); 15 Jun 2017 09:35:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2017 09:35:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-io0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:32801] helo=mail-io0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/85-49155-4D452495 for ; Thu, 15 Jun 2017 05:35:16 -0400 Received: by mail-io0-f170.google.com with SMTP id t87so8585889ioe.0 for ; Thu, 15 Jun 2017 02:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qeSrqihQ7dD8L8pED0i2ILPtcfeXDzeP2RpffY8EPE0=; b=NVOseFvBHprcBz6UVfp4/lqflWyZqGiotusRrhaHrw8umEYD7JY9XebLi+D+tGZBAa e4ZzxjpcOloz3RSAOW4deWqu/W1cQvYc6uKOqwN0Jc1UBmGcNHgAOJqbX8uF6yzFojzy 5VubiPGuUwCCNb+/0ydOZTPz7B5RO/C+gXSRznmtPkG3H1dnblmP0CZ0LC99M1L2P3fP bG+TlUuzkX7ReYCzj/ledFpBLUx/SZ0i1aY/x5uTbRuKqeOVqrcECiXU7uHFgvOe1t5f /ItQZg7dUPsV+AO76o+jDQPO//dO3GQPRKhVpgoipmxMlEEdDLXk8Gvp5+WOt+yBzuru 8RUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qeSrqihQ7dD8L8pED0i2ILPtcfeXDzeP2RpffY8EPE0=; b=mc1XQ4Wc4kAyWAujVp/VOYAUUR2ats0gZXvsaCdLVRVesYWRjaFkccRdkKTTJPbilZ fMozsYQ+zWBhJ9c7CUtJpFgjTeoXSXD2uPsda5DySbE/34ABCn86jRvHbObLhLmnH3nD wrjAUkXjASbNkcdxHFUdROF8unJrU/fGG4zMKdl5qwA4Q4tL4EAQZ+7TRNXOsecuI96P fhkXOTNuM0aiRri+z289ApMHHCa2tiBbX+ilRHD0Cv+twJAQt/kR+fGWQXneXVUO5cEw 7kcrGbOHif4QrkinNRHpGqb791zZJw+zFNAp7dsiwA1I0X4xINsONIP1W+dOdUd8mSFr gmjg== X-Gm-Message-State: AKS2vOygbE1AaEC1cUM8J854EMCtgBkKQAmpQU/UE1IeojEDe8rA/3RK KAMLBiM4LS6dmuojEm6ZnqipBwXapw== X-Received: by 10.107.12.144 with SMTP id 16mr4268253iom.150.1497519313320; Thu, 15 Jun 2017 02:35:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.50.78 with HTTP; Thu, 15 Jun 2017 02:35:12 -0700 (PDT) In-Reply-To: References: Date: Thu, 15 Jun 2017 11:35:12 +0200 Message-ID: To: David Strauss Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="001a113ee16ab705990551fc623c" Subject: Re: [PHP-DEV] Intended RFC Proposal: Side-Effect Filtering for unserialize() From: nikita.ppv@gmail.com (Nikita Popov) --001a113ee16ab705990551fc623c Content-Type: text/plain; charset="UTF-8" On Mon, Jun 12, 2017 at 10:48 PM, David Strauss wrote: > Despite providing class whitelisting [1] and documentation about warnings > about security impacts [2], we continue to see vulnerable uses of > unserialize() in Drupal modules [3] and partially effective attempts to > mitigate vulnerabilities from user-supplied, serialized data [4]. > > Whitelisting legal classes for unserializing data is, unfortunately, not > seeing widespread uptake in community-created code that I review. It also > doesn't push us toward more secure defaults shipping with OS packages and > on PHP-supporting platforms. An additional option that would generally work > with existing, legitimate use but would also block use for exploits could > turn that tide. > > I propose adding a new key to the $options parameter for unserialize(). The > new key would be "exception_on_side_effects", have a Boolean value, and > would (if true) cause unserialization to halt (and an exception to be > thrown) if any of the data being unserialized contains objects with magic > methods that will automatically execute on object wakeup, destruction, or > other events that the PHP interpreter (almost) always triggers. > > To help push toward better defaults, I also suggest adding a related > configuration option: > > Name: unserialize_side_effect_protection > Default: 0 > Changeable: PHP_INI_ALL > > If enabled, it would cause "exception_on_side_effects" to be enabled by > default on all unserialize() calls that don't specify "allowed_classes" or > override the default. By making it PHP_INI_ALL, frameworks could lock down > usage during bootstrap (or at least before reading request data). > > I am a member of the Drupal Security Team and would also be the implementer > of this feature. My username on the wiki is "dts", and I'm requesting RFC > karma. > > [1] https://wiki.php.net/rfc/secure_unserialize > [2] https://secure.php.net/manual/en/function.unserialize.php > [3] https://www.ambionics.io/blog/drupal-services-module-rce > [4] > https://github.com/WordPress/WordPress/blob/efab6e06cae3ed14c6b681570dfd5f > 81917d9f9c/wp-includes/functions.php#L341-L394 Hi, how do you intend to handle internal classes in this regard? Internal classes (if they support serialization at all) will pretty much always use either __wakeup or Serializable::unserialize(). Does that mean that if exception_on_side_effects is enabled, most internal classes will be prohibited? Regards, Nikita --001a113ee16ab705990551fc623c--