Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.0.6 breaks U2Fzero devices #97

Closed
nbraud opened this issue May 26, 2018 · 11 comments
Closed

Version 1.0.6 breaks U2Fzero devices #97

nbraud opened this issue May 26, 2018 · 11 comments

Comments

@nbraud
Copy link
Contributor

nbraud commented May 26, 2018

I'm forwarding Debian bug #898519, where a user become unable to authenticate using their U2Fzero device after upgrading from 1.0.4 to 1.0.6.

A full debug log is included in the original bug, for both versions of libpam-u2f, showing that the USB communication with the device times out. I was unable to confirm the bug independently, as I do not have a U2Fzero device.

@maximbaz
Copy link
Contributor

Looks like #87, ping @cjoster to confirm.

@nbraud nbraud changed the title Version 1.0.6 breaks U2F devices Version 1.0.6 breaks U2Fzero devices May 26, 2018
@cjoster
Copy link

cjoster commented May 27, 2018

Well,

The U2F specification available here[0] specifies two different authentication modes; a "check-only" and a "require-user-presence" mode.

What confuses me the most about this bug[1] is that it succeeds once and then fails on a second try.

It's possible that this token doesn't like the check-only authentication attempt, which was what the nodetect option was added for. Give that a try and respond back letting us know.

My second hunch is that the double-authentication from sudo su is somehow also getting in the way of the authentication protocol. It's tough to say right now.

@nbraud Is there a chance you could loan me a u2fzero token for testing?

[0] - https://fidoalliance.org/specs/u2f-specs-1.0-bt-nfc-id-amendment/fido-u2f-raw-message-formats.html
[1] - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=898519

@jkur
Copy link

jkur commented May 28, 2018

Hi,
i'am the original reporter on this issue in Debian.

I tried many variants of configuration with the current debian packages but they all fail.
I was using all permutations of options: cue interactive nodetect

See output here (Debian packages):

$ LC_ALL="C" sudo su
[sudo] password for jkur:
debug(pam_u2f): ../pam-u2f.c:89 (parse_cfg): called.
debug(pam_u2f): ../pam-u2f.c:90 (parse_cfg): flags 32768 argc 4
debug(pam_u2f): ../pam-u2f.c:92 (parse_cfg): argv[0]=authfile=/etc/u2f_keys
debug(pam_u2f): ../pam-u2f.c:92 (parse_cfg): argv[1]=interactive
debug(pam_u2f): ../pam-u2f.c:92 (parse_cfg): argv[2]=nodetect
debug(pam_u2f): ../pam-u2f.c:92 (parse_cfg): argv[3]=debug
debug(pam_u2f): ../pam-u2f.c:94 (parse_cfg): max_devices=0
debug(pam_u2f): ../pam-u2f.c:95 (parse_cfg): debug=1
debug(pam_u2f): ../pam-u2f.c:96 (parse_cfg): interactive=1
debug(pam_u2f): ../pam-u2f.c:97 (parse_cfg): cue=0
debug(pam_u2f): ../pam-u2f.c:98 (parse_cfg): manual=0
debug(pam_u2f): ../pam-u2f.c:99 (parse_cfg): nouserok=0
debug(pam_u2f): ../pam-u2f.c:100 (parse_cfg): openasuser=0
debug(pam_u2f): ../pam-u2f.c:101 (parse_cfg): alwaysok=0
debug(pam_u2f): ../pam-u2f.c:102 (parse_cfg): authfile=/etc/u2f_keys
debug(pam_u2f): ../pam-u2f.c:103 (parse_cfg): origin=(null)
debug(pam_u2f): ../pam-u2f.c:104 (parse_cfg): appid=(null)
debug(pam_u2f): ../pam-u2f.c:105 (parse_cfg): prompt=(null)
debug(pam_u2f): ../pam-u2f.c:146 (pam_sm_authenticate): Origin not specified, using "pam://durruti"
debug(pam_u2f): ../pam-u2f.c:156 (pam_sm_authenticate): Appid not specified, using the same value of origin (pam://durruti)
debug(pam_u2f): ../pam-u2f.c:165 (pam_sm_authenticate): Maximum devices number not set. Using default (24)
debug(pam_u2f): ../pam-u2f.c:183 (pam_sm_authenticate): Requesting authentication for user jkur
debug(pam_u2f): ../pam-u2f.c:194 (pam_sm_authenticate): Found user jkur
debug(pam_u2f): ../pam-u2f.c:195 (pam_sm_authenticate): Home directory for jkur is /home/jkur
debug(pam_u2f): ../pam-u2f.c:235 (pam_sm_authenticate): Using authentication file /etc/u2f_keys
debug(pam_u2f): ../util.c:102 (get_devices_from_authfile): Authorization line: jkur:kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR,0492f1faa4b785a3ae1b12874d5200414b506d261d7c5763335bc67146ebc76684eaea1f72e1d29189ddf60203dc33cf5cc20e776a6be4a59abd40eb8391bec519
debug(pam_u2f): ../util.c:107 (get_devices_from_authfile): Matched user: jkur
debug(pam_u2f): ../util.c:134 (get_devices_from_authfile): KeyHandle for device number 1: XXXXXXXXXXXXXXXXXXXXXXXXX
debug(pam_u2f): ../util.c:153 (get_devices_from_authfile): publicKey for device number 1: 0492f1faa4b785a3ae1b12874d5200414b506d261d7c5763335bc67146ebc76684eaea1f72e1d29189ddf60203dc33cf5cc20e776a6be4a59abd40eb8391bec519
debug(pam_u2f): ../util.c:164 (get_devices_from_authfile): Length of key number 1 is 65
debug(pam_u2f): ../util.c:191 (get_devices_from_authfile): Found 1 device(s) for user jkur
Insert your U2F device, then press ENTER.
USB send: 00ffffffff8600080807060504030201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
USB write returned 65
now trying with timeout 2
now trying with timeout 4
USB read rc read 64
USB recv: ffffffff8600110807060504030201cafebabe0202000003110c8e77845de9eeae4735b0f0815b8ecaded09b5e12b65312a26343758002b4f7abeae7cb3f773e
device /dev/hidraw3 discovered as 'U2F Zero'
version (Interface, Major, Minor, Build): 2, 2, 0, 0 capFlags: 3
debug(pam_u2f): ../util.c:269 (do_authentication): Device max index is 0
debug(pam_u2f): ../util.c:300 (do_authentication): Attempting authentication with device number 1
debug(pam_u2f): ../util.c:322 (do_authentication): Challenge: { "keyHandle": "kkm0rAC-egXXXXXXXXXXXXXXX", "version": "U2F_V2", "challenge": "poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo", "appId": "pam://durruti" }
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo", "appId": "pam://durruti" }
JSON challenge URL-B64: poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo
client data: { "challenge": "poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo", "origin": "pam://durruti", "typ": "navigator.id.getAssertion" }
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo", "appId": "pam://durruti" }
JSON app_id pam://durruti
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "poCIyzHVrYbR6yod1whmMwrizE40vrtmMqJHqCY_IIo", "appId": "pam://durruti" }
JSON keyHandle URL-B64: kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR
USB send: 00cafebabe83006e000207000000652a7ef94b83cc0ebf8d2f846bfbd3ba91f52028ec5a2b846b81aaf2f370bfa6b339e9eb27ecdb0c00b8e469121d93a9d569
USB write returned 65
USB send: 00cafebabe00021d4f2cbc287aea8b36c7eba054249249b4ac00be7a0069c48382c060c261387e43d8d8b5ddcc1aaf0a6b325bd740cdf0531100000000000000
USB write returned 65
now trying with timeout 2
now trying with timeout 4
now trying with timeout 8
now trying with timeout 16
now trying with timeout 32
USB read rc read 64
USB rc -2
debug(pam_u2f): ../util.c:348 (do_authentication): Device for this keyhandle is not present.
device /dev/hidraw3 looks dead.
debug(pam_u2f): ../util.c:355 (do_authentication): Unable to discover devices
debug(pam_u2f): ../pam-u2f.c:293 (pam_sm_authenticate): do_authentication returned -2
debug(pam_u2f): ../pam-u2f.c:312 (pam_sm_authenticate): done. [Authentication failure]
Sorry, try again.

So this fails.

Then i tried the current source versions (master branch with libu2f-server, libu2f-host, pam-u2f)
The "nodetect" is now available, and it works!
See log here (i forgot the LC_ALL="C", well...):

jkur@durruti:~$ sudo su
[sudo] Passwort für jkur:
debug(pam_u2f): pam-u2f.c:94 (parse_cfg): called.
debug(pam_u2f): pam-u2f.c:95 (parse_cfg): flags 32768 argc 4
debug(pam_u2f): pam-u2f.c:97 (parse_cfg): argv[0]=authfile=/etc/u2f_keys
debug(pam_u2f): pam-u2f.c:97 (parse_cfg): argv[1]=interactive
debug(pam_u2f): pam-u2f.c:97 (parse_cfg): argv[2]=nodetect
debug(pam_u2f): pam-u2f.c:97 (parse_cfg): argv[3]=debug
debug(pam_u2f): pam-u2f.c:99 (parse_cfg): max_devices=0
debug(pam_u2f): pam-u2f.c:100 (parse_cfg): debug=1
debug(pam_u2f): pam-u2f.c:101 (parse_cfg): interactive=1
debug(pam_u2f): pam-u2f.c:102 (parse_cfg): cue=0
debug(pam_u2f): pam-u2f.c:103 (parse_cfg): nodetect=1
debug(pam_u2f): pam-u2f.c:104 (parse_cfg): manual=0
debug(pam_u2f): pam-u2f.c:105 (parse_cfg): nouserok=0
debug(pam_u2f): pam-u2f.c:106 (parse_cfg): openasuser=0
debug(pam_u2f): pam-u2f.c:107 (parse_cfg): alwaysok=0
debug(pam_u2f): pam-u2f.c:108 (parse_cfg): authfile=/etc/u2f_keys
debug(pam_u2f): pam-u2f.c:109 (parse_cfg): authpending_file=(null)
debug(pam_u2f): pam-u2f.c:110 (parse_cfg): origin=(null)
debug(pam_u2f): pam-u2f.c:111 (parse_cfg): appid=(null)
debug(pam_u2f): pam-u2f.c:112 (parse_cfg): prompt=(null)
debug(pam_u2f): pam-u2f.c:157 (pam_sm_authenticate): Origin not specified, using "pam://durruti"
debug(pam_u2f): pam-u2f.c:169 (pam_sm_authenticate): Appid not specified, using the same value of origin (pam://durruti)
debug(pam_u2f): pam-u2f.c:180 (pam_sm_authenticate): Maximum devices number not set. Using default (24)
debug(pam_u2f): pam-u2f.c:198 (pam_sm_authenticate): Requesting authentication for user jkur
debug(pam_u2f): pam-u2f.c:209 (pam_sm_authenticate): Found user jkur
debug(pam_u2f): pam-u2f.c:210 (pam_sm_authenticate): Home directory for jkur is /home/jkur
debug(pam_u2f): pam-u2f.c:251 (pam_sm_authenticate): Using authentication file /etc/u2f_keys
debug(pam_u2f): util.c:102 (get_devices_from_authfile): Authorization line: jkur:kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR,0492f1faa4b785a3ae1b12874d5200414b506d261d7c5763335bc67146ebc76684eaea1f72e1d29189ddf60203dc33cf5cc20e776a6be4a59abd40eb8391bec519
debug(pam_u2f): util.c:107 (get_devices_from_authfile): Matched user: jkur
debug(pam_u2f): util.c:134 (get_devices_from_authfile): KeyHandle for device number 1: kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR
debug(pam_u2f): util.c:153 (get_devices_from_authfile): publicKey for device number 1: 0492f1faa4b785a3ae1b12874d5200414b506d261d7c5763335bc67146ebc76684eaea1f72e1d29189ddf60203dc33cf5cc20e776a6be4a59abd40eb8391bec519
debug(pam_u2f): util.c:164 (get_devices_from_authfile): Length of key number 1 is 65
debug(pam_u2f): util.c:191 (get_devices_from_authfile): Found 1 device(s) for user jkur
debug(pam_u2f): pam-u2f.c:317 (pam_sm_authenticate): Using file '/var/run/user/1000/pam-u2f-authpending' for emitting touch request notifications
Insert your U2F device, then press ENTER.
USB send: 00ffffffff8600080807060504030201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
USB write returned 65
now trying with timeout 2
now trying with timeout 4
USB read rc read 64
USB recv: ffffffff8600110807060504030201cafebabf020200000300000000000000000000000000000000000000000000000000000000000000000000000000000000
device /dev/hidraw3 discovered as 'U2F Zero'
version (Interface, Major, Minor, Build): 2, 2, 0, 0 capFlags: 3
debug(pam_u2f): util.c:272 (do_authentication): Device max index is 0
debug(pam_u2f): util.c:298 (do_authentication): nodetect option specified, suitable key detection will be skipped
debug(pam_u2f): util.c:306 (do_authentication): Attempting authentication with device number 1
debug(pam_u2f): util.c:330 (do_authentication): Challenge: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "appId": "pam://durruti" }
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "appId": "pam://durruti" }
JSON challenge URL-B64: Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0
client data: { "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "origin": "pam://durruti", "typ": "navigator.id.getAssertion" }
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "appId": "pam://durruti" }
JSON app_id pam://durruti
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "appId": "pam://durruti" }
JSON keyHandle URL-B64: kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR
USB send: 00cafebabf83006e0002030000006547406e0b282e8beb81e4995efe321a6eb3b98977680e0faa45c3f432718cc7fa39e9eb27ecdb0c00b8e469121d93a9d569
USB write returned 65
USB send: 00cafebabf00021d4f2cbc287aea8b36c7eba054249249b4ac00be7a0069c48382c060c261387e43d8d8b5ddcc1aaf0a6b325bd740cdf0531100000000000000
USB write returned 65
now trying with timeout 2
now trying with timeout 4
now trying with timeout 8
now trying with timeout 16
now trying with timeout 32
now trying with timeout 64
now trying with timeout 128
now trying with timeout 256
now trying with timeout 512
now trying with timeout 1024
now trying with timeout 2048
USB read rc read 64
USB recv: cafebabf83004e01000000023045022016812d12643e4e0618bed0c7b5a2a3dabe95b8e654db2d846d15554705c244ea022100cb454f1554d7cfd84941a2ca1f
now trying with timeout 2
now trying with timeout 4
USB read rc read 64
USB recv: cafebabf0034e2bb98c239a179cb1035f3058ec5cbfb95c490000000000000000000000000000000000000000000000000000000000000000000000000000000
USB data (len 78): 01000000023045022016812d12643e4e0618bed0c7b5a2a3dabe95b8e654db2d846d15554705c244ea022100cb454f1554d7cfd84941a2ca1f34e2bb98c239a179cb1035f3058ec5cbfb95c49000
JSON: { "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR", "version": "U2F_V2", "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "appId": "pam://durruti" }
JSON keyHandle URL-B64: kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR
debug(pam_u2f): util.c:344 (do_authentication): Response: { "signatureData": "AQAAAAIwRQIgFoEtEmQ-TgYYvtDHtaKj2r6VuOZU2y2EbRVVRwXCROoCIQDLRU8VVNfP2ElBosofNOK7mMI5oXnLEDXzBY7Fy_uVxA", "clientData": "eyAiY2hhbGxlbmdlIjogIkRzdnJweXV0c3IwQ0dvRnk2TVpUNjhLMmJEQXN3QnJuRThYQkRZTVh1ZTAiLCAib3JpZ2luIjogInBhbTpcL1wvZHVycnV0aSIsICJ0eXAiOiAibmF2aWdhdG9yLmlkLmdldEFzc2VydGlvbiIgfQ", "keyHandle": "kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR" }
signatureData: AQAAAAIwRQIgFoEtEmQ-TgYYvtDHtaKj2r6VuOZU2y2EbRVVRwXCROoCIQDLRU8VVNfP2ElBosofNOK7mMI5oXnLEDXzBY7Fy_uVxA
clientData: eyAiY2hhbGxlbmdlIjogIkRzdnJweXV0c3IwQ0dvRnk2TVpUNjhLMmJEQXN3QnJuRThYQkRZTVh1ZTAiLCAib3JpZ2luIjogInBhbTpcL1wvZHVycnV0aSIsICJ0eXAiOiAibmF2aWdhdG9yLmlkLmdldEFzc2VydGlvbiIgfQ
keyHandle: kkm0rAC-egBpxIOCwGDCYTh-Q9jYtd3MGq8KazJb10DN8FMR
signatureData Hex:
01 00 00 00 02 30 45 02 20 16 81 2d 12 64 3e 4e
06 18 be d0 c7 b5 a2 a3 da be 95 b8 e6 54 db 2d
84 6d 15 55 47 05 c2 44 ea 02 21 00 cb 45 4f 15
54 d7 cf d8 49 41 a2 ca 1f 34 e2 bb 98 c2 39 a1
79 cb 10 35 f3 05 8e c5 cb fb 95 c4
clientData: { "challenge": "Dsvrpyutsr0CGoFy6MZT68K2bDAswBrnE8XBDYMXue0", "origin": "pam://durruti", "typ": "navigator.id.getAssertion" }
debug(pam_u2f): pam-u2f.c:386 (pam_sm_authenticate): done. [Erfolg]

So it seems, that the "nodetect" option works with the u2fzero device.

This is a Debian packaging issue then.

Best regards!

P.S.: is it save tp publish all the information from the debug log here? I wondered if you could find interesting information in all the keyhandle, challenge, etc information that is copied and pasted here.

@a-dma
Copy link
Member

a-dma commented May 28, 2018

Ah cool, I was having a look at the log you posted on the Debian bugtracker and it seemed to me that the device was taking a long time to respond to a chunked message for no obvious reason. I also don't have a U2F Zero device so reproducing was a bit tricky.

If everything works with latest things and it's just a packaging problem all is well then. Is it OK to close this issue?

I don't know how U2F Zero encodes keyhandles, but it's typically safe to post those logs. The only stuff that you can get out is your user name, host name and the authentication counter.

@jkur
Copy link

jkur commented May 28, 2018

Besides, i have spare U2Fzero token around. If you (@cjoster) or someone else is located in germany, it would be possible to send a token for testing purposes. Otherwise i think it wouldn't make much sense, since a new token would be cheaper then sending it around.

And yes, for me it's okay to close the issue, but maybe we could wait for @nbraud, because he is the maintainer involved.

@nbraud
Copy link
Contributor Author

nbraud commented May 29, 2018

@jkur FYI, I have packaged the latest pam-u2f, but it is waiting on a sponsored upload.

Regarding how to resolve this, I'm OK with the status quo, but it would be much better if there was a way to make the default configuration work with all devices.

@cjoster
Copy link

cjoster commented May 29, 2018

@jkur I have ordered a U2Fzero token and will experiment with it as you're right, by the time we ship the thing once, it's paid for.

@nbraud I'm all for "make the default configuration work with all devices", which is what standards are for. Until I can prove it, I'm not going to accuse U2FZero of not following the standard, but I suspect that's what's occurring here. I'm also going to hit up U2FZero and see what they have to say about it.

@conorpp
Copy link

conorpp commented May 29, 2018

@jkur @cjoster Sorry for the headaches, this is likely my fault. There was some U2F Zero tokens in Europe with firmware version that had a bug with the check-only 0x07 command. The latest firmware and units sold in the U.S. should be fine. Anyone that purchased a EU token, feel free to reach out to me ([email protected]) for a refund.

The EU stock listings have all been closed but unfortunately some tokens with this bug are in circulation. I appreciate it if anyone that can share this with anyone that purchased a token in europe.

https://u2fzero.com/#support

@cjoster
Copy link

cjoster commented May 31, 2018

I can confirm that a U2FZero device purchased from Amazon US two days ago works fine against pam-u2f v1.0.7 without the nodetect option specified. Confirming that this is indeed a bug with the 0x07 check-only interrogation in the U2FZero device, and that the US Amazon stock is free from this bug. @conorpp @jkur @nbraud

@a-dma
Copy link
Member

a-dma commented Jun 1, 2018

Thanks for looking into this. I'll close the issue.

@a-dma a-dma closed this as completed Jun 1, 2018
@nbraud
Copy link
Contributor Author

nbraud commented Jun 20, 2018

@cjoster @conorpp Thanks a lot for looking into it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants