Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1132027imj; Thu, 14 Feb 2019 01:38:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IamUsOoycg8g4JAea+LbwTfMbqMz3nJTshlCIHNIlr2rkn8BUzxVSZ/D9ZKoRoxnKKi0Ael X-Received: by 2002:a17:902:f096:: with SMTP id go22mr3201955plb.23.1550137133792; Thu, 14 Feb 2019 01:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550137133; cv=none; d=google.com; s=arc-20160816; b=IjovU7tQNtw6mFx3rl7k/CwDTtyV93n8dKepvM0sBB6o+ktqwHbj1zWpXM/E6uW2K7 xFTdTrWhSZvoKuavizjQgH2C79P2+vfS6j2mXpyj/8uXrfXA7gv+m9KdeQEZY/FO3kik GNmK9ucQ9ummverbZ+0DXMO/rAd+cEH97voy1t8HB80ZAPOu2XRMfdpW+2pxcnx2OjtL 7Q0ELJQxeC6ucUz5I1z9A+22aMAXpqm7q5y1ZRM0cQ3WIBqZMcaMOu0fZSXwdO3WhriA FIOAOknKMepkfqCkd/tZIb48VjEk3nnk7PRfRwGctrAcWBUcGihcx15W1/yL579ZsbxW b0Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date; bh=62m5VBNnq6B1XqwPIwr8KIoXvSxupyoNRHL2vs3pjwA=; b=NXNbLsF06Roefthq5sbURVfWK9GHIXOt+UwbcXuv0Q5JrerW5bh0snNCef9hmEqFhY mt+8cGNq5lUxUuEa8YD9Pd/VJPFM7VVvU3T4ilxGd+GJG9oCRPrq2Dcjm07RB24Fp/2O YZ9a2TGzqiXIme886kQ+QK4JtbKsat2TuM8zpSeu2IcJY3EvAE7waj9Z2Sg2vG8hmCYu 39rVw7ecN5PFVPGmJfMydssDSW/Y2aVqblTFl+vOwETBZbJ6amKnFyfQvkYt4fK5Ql1T VQcZnbrlmvzGk4xXhLulZSA6REolkS/jCZdeeLTGHZM7YXJhfCCqtK3kUJqu7NvVLrBk MKvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12si1875126plv.4.2019.02.14.01.38.37; Thu, 14 Feb 2019 01:38:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392724AbfBMWtD (ORCPT + 99 others); Wed, 13 Feb 2019 17:49:03 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:47447 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfBMWtC (ORCPT ); Wed, 13 Feb 2019 17:49:02 -0500 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 68E6B802DD; Wed, 13 Feb 2019 23:48:53 +0100 (CET) Date: Wed, 13 Feb 2019 23:48:59 +0100 From: Pavel Machek To: marcel@holtmann.org, johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, kernel list Subject: [PATCH] pre-shared passcode: secure pairing for "no keyboard, no display" devices Message-ID: <20190213224859.GA7151@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! Currently, "no keyboard, no display" devices can be paired, but pairing is not secure against active attacker. Can we do better? Not for the first pairing; but for the next ones -- yes, I believe we can. BLE device in this case has internal storage, and Linux running there. From factory, random 6-digit number is stored in the flash. Legitimate user knows the number, and system is manipulated so that pairing passkey will be this pre-shared passkey. After pairing, user is allowed to change it. [Or maybe passkey is 000000 from the factory; this is still win for the user, as long as he can change the key to something random in a secure cave.] Fortunately, kernel support for this is rather easy; patch is attached below. Does someone see a security issue with proposal above? What would be suitable interface for setting pre-shared passkey? Module parameter is really easy. Signed-off-by: Pavel Machek diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 621146d..7a2b06595 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -2674,6 +2674,11 @@ static u8 sc_select_method(struct smp_chan *smp) return method; } =20 +static int preshared_passkey =3D -1; + +module_param(preshared_passkey, int, 0600); +MODULE_PARM_DESC(preshared_passkey, "Preshared passkey for device w/o keyb= oard or display"); + static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) { struct smp_cmd_public_key *key =3D (void *) skb->data; @@ -2752,9 +2757,11 @@ static int smp_cmd_public_key(struct l2cap_conn *con= n, struct sk_buff *skb) set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); =20 if (smp->method =3D=3D DSP_PASSKEY) { get_random_bytes(&hcon->passkey_notify, sizeof(hcon->passkey_notify)); + if (preshared_passkey !=3D -1) + hcon->passkey_notify =3D preshared_passkey; hcon->passkey_notify %=3D 1000000; hcon->passkey_entered =3D 0; smp->passkey_round =3D 0; if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --9amGYk9869ThD9tj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlxkntsACgkQMOfwapXb+vKt1ACdEdWMXJbwcY4nEoON81kJvwGH 7K8AoJJDg2oeh8zFZpa3xAMZxzTnpiOO =Yhc6 -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--