Return-Path: Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=james.feist@linux.intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48C2855PM3zDqL4 for ; Wed, 5 Feb 2020 11:12:51 +1100 (AEDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2020 16:12:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,403,1574150400"; d="scan'208";a="378583204" Received: from unknown (HELO [10.241.225.77]) ([10.241.225.77]) by orsmga004.jf.intel.com with ESMTP; 04 Feb 2020 16:12:47 -0800 Subject: Re: BMCWeb: rate-limit authentication failures To: Joseph Reynolds , openbmc References: <60250182-21b5-8bf2-9995-413c266f075f@linux.ibm.com> Cc: "Thomaiyar, Richard Marian" From: James Feist Message-ID: Date: Tue, 4 Feb 2020 16:12:47 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <60250182-21b5-8bf2-9995-413c266f075f@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Feb 2020 00:12:54 -0000 On 2/4/2020 2:41 PM, Joseph Reynolds wrote: > I would like to enhance BMCWeb to rate-limit password-based > authentication attempts (footnote1) to address [CWE-307][].  [Broken > Authentication][] is an OWASP top 10 item.  The goal is to protect > against CWE-307 without causing denial of service.  Specifically, when > excessive authentication attempts are happening, legitimate users should > be able to access the BMC (specifically an admin can login), and > degraded BMC performance is acceptable. > > The main idea for the design is to allow authentication at full speed, > and rate-limit only when needed.   This is consistent with the approach > OWASP outlines. > > Perhaps the design can be as simple as recording the 10 most recent > authentication failures (steady_clock time only, having them time out > after a minute) to define "excessive", and using the timestamp of the > most recent failure to determine when the next attempt will be allowed. > When authentication is requested but not allowed, return HTTP status > code 429 (Too Many Requests) with HTTP response header "Retry-After: > 3".  ==> This will slow down attackers (for example, to 30 tries per > minute, even when multiple connections are used) and allow legitimate > users to compete for authentication attempts. > > However, I think even this apparently simple design might be tricky to > get right.  Is there an open source solution we can use?  What do you > think?  Let me know if this is important to you.  I would like to hear > ideas how to proceed. I know we plan to look into this in the near future. > > - Joseph > > TL;DR (too long; don't read): > > A counterpart to this design is to delay any failed authentication > attempt for a few seconds.  This is intended to slow down malfunctioning > network agents that repeatedly fail to authenticate to the BMC.  This > won't slow down attackers who can use multiple connections to the BMC. > > I looked at using Linux-PAM.  For example, [OpenBMC uses pam_tally2][] Did you look into Pam_abl? Haven't looked much into it, but reading a couple articles it looks promising. Using lockouts based on host instead of account seems like it would be a good approach. > but does not configure account lockouts.  I don't want to pursue using > the pam_tally2 lockout mechanism because that can lead to denial of > service.  I believe rate-limiting is a better approach. > > I only want to protect access via BMCWeb.  The protection techniques may > also apply to network IPMI and SSH, but the direction is to disable > these accesses, so I am less interested.  Access via the BMC's serial > console would not be protected.  Access via the BMC's host should have > similar protections, but I am not investigating that now. > > CWE-307 is a problem only because OpenBMC offers password-based > authentication without requiring multi-factor authentication (MFA). > Disabling password-based auth remains a popular use case, and OpenBMC > has no MFA capabilities.  So I need CWE-307 protection as a stop-gap > solution. > > References and footnotes: > [CWE-307]: https://cwe.mitre.org/data/definitions/307.html > [OpenBMC uses pam_tally2]: > https://github.com/openbmc/openbmc/blob/master/meta-phosphor/recipes-extended/pam/libpam/pam.d/common-auth > > (footnote1): BMCWeb's password-based authentication includes Basic Auth, > login via /login, and creating a Redfish session.  It does not include > authentication via mTLS or using an X-Auth-Token or a cookie from an > established session. > [Broken Authentication]: > https://owasp.org/www-project-top-ten/OWASP_Top_Ten_2017/Top_10-2017_A2-Broken_Authentication >