Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp694273ybg; Wed, 3 Jun 2020 11:05:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv1ibpVJk3y/4X5m+ANA3DYcDqUvnsYHP0PoeoJEdHAUBFO0kZSFGUA7ozHrtZ3FlWZzHj X-Received: by 2002:a50:8b05:: with SMTP id l5mr616797edl.276.1591207537404; Wed, 03 Jun 2020 11:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591207537; cv=none; d=google.com; s=arc-20160816; b=rSrt899ouifi8W6qFuL0XXWfZuOKdNTIV+gpMDKYmsb5B8CMaq6oGoMXGW7Es4em98 ETrhDm33GAZ/JI+rsHvaoJ0cMhdFrVOJp70Xk6Sbr0rTSWRlZy3nlE3fp7iily+5YzL6 w+0VkEmSrMDlfnDoyZOgPjEn18BBAIrd3emJBfTHjTGiBCFUQRWBvT7nESE/3ozQrSAc 4i1C1pESyoFXvuUWLEOIqTGvaUzqhoW7dFrXxQXMYyz3XY1hoCweVBeKal4hCHyDgZRq tN83+IH6UxelOo39/v5axzUo7G5VGo6VxXcEoKxX4Wxwgo1nddtB+cupf93T63sovbzL EZbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=uRHUpBAnZO6giO++kuaKSA6d3jo4vVEbxD6shL+S1kE=; b=b+mPHARjHpplfPeiM53OOYLQYUiPAUmU/gX2PTMhfBpcZpgRer3LlprYDpcAOaMcUD xLr9wvqk9HdbnnT00YYECdSkjSgOB7hM0xxH7QbvcSx8xIdg2oJ4V/Iuv3gXWDSz5d+9 KfsdTj9Bun6drtwJ9HCQ1ayxdbZkhY4PBx2HYlkW0dDrkdHLs+WUFcO3QqAMFEGS93Zg pWZ7m8KL2VJ+dkEdhWsJpbpIW7YV0fisFrhA/hMJM0yidLW1VqMJ03OSlY/4/MBP7zp7 OPWJfNxOk+L7QkHXyNIGM0x+M1csxIP2+ZMNCby10f8qP8VneN2bl8r3K4zC95c+d3tO rkSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar16si182370ejc.521.2020.06.03.11.05.11; Wed, 03 Jun 2020 11:05:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbgFCSCp convert rfc822-to-8bit (ORCPT + 99 others); Wed, 3 Jun 2020 14:02:45 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38965 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726103AbgFCSCp (ORCPT ); Wed, 3 Jun 2020 14:02:45 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 5C180CED2E; Wed, 3 Jun 2020 20:12:31 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 2/4] Bluetooth: Fix assuming EIR flags can result in SSP authentication From: Marcel Holtmann In-Reply-To: Date: Wed, 3 Jun 2020 20:02:42 +0200 Cc: Luiz Augusto von Dentz , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: <154FE28A-B5DA-40C5-801E-F5F881F1FD51@holtmann.org> References: <20200519202519.219335-1-luiz.dentz@gmail.com> <20200519202519.219335-2-luiz.dentz@gmail.com> <23C4DB2B-4C5E-45E7-A777-6F26A675EB92@holtmann.org> <6F17F57F-8AF4-4539-8564-C3F13BC6FBF5@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, >>>>>>> Starting with the 2.1 specification, it is my interpretation that it >>>>>>> is not valid to support EIR but not SSP. I understand that SSP may be >>>>>>> disabled from BlueZ's point of view, but this doesn't seem to be a >>>>>>> legitimate/qualifiable configuration. Should we instead fail the >>>>>>> legacy pairing if EIR was received as an invalid condition? >>>>>> >>>>>> I know that using EIR requires to also use SSP. However this is just a precaution in case the other device is an attacked and tries to trick us. >>>>>> >>>>>> You might get an inquiry result and not extended inquiry result, but you are still talking to a SSP device. This has to do with the fact that the reception of EIR is not guaranteed. In case of radio interference you might miss one and only get an ordinary inquiry result. >>>>>> >>>>>> If we indeed received an EIR and then get legacy pairing request, we could try to reject the pairing. However keep in mind that our inquiry cache is time limited and we through outdated information away. This might cause some race condition. So I rather read the remote host features to ensure we know the actual host features of the remote device. >>>>> >>>>> You are correct, the EIR response is not a guaranteed thing. For this >>>>> reason, the host should try to resolve the name of the device before >>>>> initiating bonding where a Remote Host Supported Feature Notification >>>>> Event is generated to signal the remote side's support of SSP. As you >>>>> allude to, a remote spoofing a legitimate SSP device may always just >>>>> jam and downgrade to not SSP, but if you have any signals that SSP is >>>>> supported by the device, it may be a good defensive posture. >>>> >>>> trying to resolve the name before connected is a waste of time. Resolving the name after connecting will not give you that event. You should just read the remote features. >>> >>> I have a vague memory that there was an interoperability issue around >>> this that required the initiator to know ahead of time if SSP was >>> supported by the remote host before connecting which was the reason >>> why this was added in the first place. However, I agree that this can >>> also be read after you are connected rather than just waiting for a >>> RNR page to complete just to page again. The point here however is >>> about the signals that SSP should be supported and the conditions >>> where we let legacy pairing go through. My assertion is that EIR >>> implies SSP, so legacy pairing shouldn't be allowed in that case. >>> It's not a definitive security measure, but IMO, every signals that we >>> can get will help close a door to downgrade attacks. >> >> Legacy pairing is still indicated with MGMT_DEV_FOUND_LEGACY_PAIRING >> so for what is worth this didn't change any logic regarding how legacy >> pairing is detected, in fact hci_conn_ssp_enabled is used to determine >> if encryption is required or not for low security it was never used to >> detect if the paring method used was really SSP or legacy. > The general idea is to both "try" to protect against a downgrade > attack but also to encrypt all channels (other than SDP) if SSP is > supported by the remote. If the later is already handled, we just > need to make sure we use all available signals that the remote side > supports SSP. Receiving an EIR is a valid signal, the absence of EIR > doesn't imply the remote doesn't support SSP. >> >>>> >>>>> Receiving an EIR response or a Remote Host Supported Feature Event >>>>> with the SSP bit set is a good indication that the device supports SSP >>>>> and you should expect SSP to take place. Again, it is not a valid >>>>> configuration to have EIR enabled but not SSP per my interpretation of >>>>> the 2.1 specification. >>>> >>>> If you have an idea on how to tighten this and fail, please send a patch. It is just that our inquiry cache was never designed for that. It was just to speed up the connection process. >>> Ack. This definitely looks like an opportunity. We can add it to the backlog. >> >> If you guys agree I can prepare a patch requiring SSP to be used, but >> first we will need to agree on what action we would take under such >> situation, shall we disconnect if we figure out the SSP bit is >> disabled? Btw, if the remote device has dropped SSP for some reason (I >> suppose the spec allows doing it) and we have a EIR on the cache >> (which we keep for 30 seconds) that doesn't necessarily mean the >> device is broken since the use of EIR may have been dropped in the >> meantime. > Right, but if we do have the EIR signal, then we should expect SSP to > be used. It is legitimate, in my interpretation, to fail anything > less than SSP in that case. lets try this then. Worst case we have to revert such a patch if it turns out it cause interop issues. Regards Marcel