Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72893 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96502 invoked from network); 2 Mar 2014 00:13:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2014 00:13:02 -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.219.43 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.43 mail-oa0-f43.google.com Received: from [209.85.219.43] ([209.85.219.43:65190] helo=mail-oa0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/00-30643-C8772135 for ; Sat, 01 Mar 2014 19:13:01 -0500 Received: by mail-oa0-f43.google.com with SMTP id g12so5645391oah.30 for ; Sat, 01 Mar 2014 16:12:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7jHz4fNYm/1MIiKzR0FvIrBBzlhEw3a0xvDrzxID7D4=; b=XaR9fRz0vAqNGgdWSmKmIGQQqUQY2uwFVXiWqLO9s5jpxwOjp7L7kdKN5bpwkCHThb Nzs85eXqOVfq/ziMhigy4hf39IZCEsqDuAA53qGtQPjJGkrPu2STIsKhqnWL8rNk35Yr UsA4ZQc82b/QqN0hkaDS6iL4iECgeYd8cAfds+50TgDnZpuvpYI5BXec2lReCJgFlueY Usnm6J00BnTANFGYRY5/PIbAzUbsmZl5uCDx6pZON7u10MsL4cppqSo6YBuNDJRhVAu6 lvjcF1ufPvIkd0AXHpefbw+66yYnFuPTn6lOIjuT/uiJr2hlVuRlZL4xw+RQEn3vnLSv 5P+Q== MIME-Version: 1.0 X-Received: by 10.60.174.170 with SMTP id bt10mr9928693oec.47.1393719178073; Sat, 01 Mar 2014 16:12:58 -0800 (PST) Received: by 10.182.54.112 with HTTP; Sat, 1 Mar 2014 16:12:58 -0800 (PST) Date: Sun, 2 Mar 2014 01:12:58 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=047d7bd6c52c869d5804f394880c Subject: Stricter error handling in mcrypt extension From: nikita.ppv@gmail.com (Nikita Popov) --047d7bd6c52c869d5804f394880c Content-Type: text/plain; charset=ISO-8859-1 Hi internals! I would like to add a number of additional error checks in php_mcrypt_do_crypt - which affects the mcrypt_encrypt, mcrypt_decrypt and mcrypt_{BLOCK_CHAINING_MODE} userland functions. The proposed changes are: * Throw a warning and return bool(false) if the IV size is invalid. The old behavior was to throw a warning and use a NUL-byte IV. * Throw a warning and return bool(false) if no IV was specified, but the block chaining mode requires an IV. The old behavior was to throw a warning and use a NUL-byte IV. * Throw a warning and return bool(false) if the key size is invalid. The old behavior was to **silently** pad the string to the next valid key size with NUL bytes or, if the key is too long, to throw a warning and truncate it to the maximum valid key size. An implementation of these changes can be found in the PR https://github.com/php/php-src/pull/610. The reason why I'd like to make the mcrypt input handling stricter is to ensure that incorrectly implemented encryption will fail and fail violently. With the current lax input checking it is very easy to completely compromise confidentiality through simple mistakes - like using a password as the encryption key. Thanks, Nikita PS: I'm running this change by the list because stricter error handling is technically a BC break. Of course this change is targeting PHP 5.6 only. --047d7bd6c52c869d5804f394880c--