Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114107 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42517 invoked from network); 22 Apr 2021 22:18:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Apr 2021 22:18:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1561E1804CC for ; Thu, 22 Apr 2021 15:22:00 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 22 Apr 2021 15:21:59 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id h36so20403708lfv.7 for ; Thu, 22 Apr 2021 15:21:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1UE4Mbee0hc+L08QJmRgSTtnSbl1TMemvdmi5jkGprs=; b=KP+UZMun+P3U5cxztQvW5xRSTv9jlkmJJNPTfgE7NixEJjQ24BQyBRMjBhqsBzJTTz zORqxY3BQq6R3vhFjlFN47EAhG2kCx62Wvtrl71bMphxzo/gIAC7yr/6/JmwZL67YW/E V6owUJGo2M5fUMc82B1qnWXPuxb+H7A9Ujde9EnOjNkURgCRPil+rk9FMISAP/YEoPrk UKrNeMeNudR/Vi7EvssP8bqPKKN0m6Zf36kJWNEqplShDc3Cp55nP2lzmFysQG4shImi gnHsXICQiQ+d8w7vegBc+MbkA37h8tyPbnzep2eNdc0jnLkBxx4CSktIaRjs3hbSuQ+8 zomg== X-Gm-Message-State: AOAM532nGwywoaIg5jHOEg8+xp3fJ2DCWFPiVni6zalzFyolLSKX/XUc ysXWgNmIDBGNwfnKHdhyL5s7yHP16EQjcelqN0IFwpYOFhyLtw== X-Google-Smtp-Source: ABdhPJzkRflO35KUTD2gjexaw3Dn+QCF0+z7wZ2tCyrCyWI7YxcpOGw535+WNepQ3VuLmb8PGkpQzd4wjRmsZMOpy5w= X-Received: by 2002:a19:a40a:: with SMTP id q10mr401960lfc.302.1619130117447; Thu, 22 Apr 2021 15:21:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Apr 2021 17:21:46 -0500 Message-ID: To: Niklas Keller Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000007ef3ab05c0971b0f" Subject: Re: [PHP-DEV] Binary (un)safety of password_hash() used with PASSWORD_BCRYPT From: pollita@php.net (Sara Golemon) --0000000000007ef3ab05c0971b0f Content-Type: text/plain; charset="UTF-8" On Thu, Apr 22, 2021 at 3:27 PM Niklas Keller wrote: >> Do you have a link to places where frameworks are doing this? I built a >> contrived example which I think summarizes the behavior you described here: >> https://3v4l.org/6tunp > > I have links to a library / blog post: > > https://github.com/paragonie/password_lock > https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016#why-bcrypt > > We're probably better off returning false for verify then instead of throwing? Hash could hash a random password instead if NUL bytes are present. > So this library (which I'd need convincing is widely used) doesn't actually have any null byte problems. Yes, the digest produced by hash(...,true) could have null bytes, but it's immediately piped into base64_encode() which papers directly over that issue producing only ascii printable output. -Sara --0000000000007ef3ab05c0971b0f--