TOTP mit PIN und Berührung wird ignoriert

Guten Morgen, wenn ich:

nk3 secrets add-otp --protect-with-pin --touch-button --hash sha1 --kind totp <NAME> <SCHLÜSSEL>

aufrufe, wird ein Eintrag erzeugt, welcher weder durch den PIN noch durch die Berührung geschützt ist. Das ist doch ein echtes Sicherheitsproblem.

Denn beim Auflisten wird der neu Eintrag auch ohne alles angezeigt. Der NK3 selbst hat den PIN Schutz, welcher auch für bestehende Einträge wirkt.

Mit

nitropy nk3 secrets update --touch-button true <EINTRAG>

Kann ich zwar das mit der Berührung nachrüsten, aber das ist ja nicht Sinn der Sache. Zumal den PIN Schutz kann man ja nicht nachrüsten.

FW: 1.8.3

Modell: NK3C

1 Like

Funktioniert bei mir anscheinend wie erwartet (NK3Amini, ebenfalls FW 1.8.3)

> nitropy-v0.11.3-x64-windows-binary.exe nk3 secrets  add-otp --protect-with-pin --touch-button --hash sha1 --kind totp Test AAAAAAAAAAAA
Command line tool to interact with Nitrokey devices 0.11.3
Please touch the device if it blinks
PIN is required to run this command.
Current PIN (8 attempts left):
Please touch the device if it blinks
Done

> nitropy-v0.11.3-x64-windows-binary.exe nk3 secrets list
Command line tool to interact with Nitrokey devices 0.11.3
Please provide PIN to show PIN-protected entries (if any), or press ENTER to skip
Please touch the device if it blinks
Current PIN (8 attempts left):
No PIN provided
01. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

> nitropy-v0.11.3-x64-windows-binary.exe nk3 secrets list
Command line tool to interact with Nitrokey devices 0.11.3
Please provide PIN to show PIN-protected entries (if any), or press ENTER to skip
Please touch the device if it blinks
Current PIN (8 attempts left):
Please touch the device if it blinks
01. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
02. Test        Totp/Sha1       touch required,PIN required

Ich habe hier nitropy 0.12.0 unter Linux laufen.

Test mit NK3A NFC

georg@heka:~> nitropy nk3 secrets add-otp --protect-with-pin --touch-button --hash sha1 --kind totp Test AAAAAAAAAAAA
Command line tool to interact with Nitrokey devices 0.12.0
Please touch the device if it blinks
PIN is required to run this command.
Current PIN (8 attempts left):
Please touch the device if it blinks
Done
georg@heka:~> nitropy nk3 secrets list
Command line tool to interact with Nitrokey devices 0.12.0
Please provide PIN to show PIN-protected entries (if any), or press ENTER to skip
Please touch the device if it blinks
Current PIN (8 attempts left):
Please touch the device if it blinks
01. HmacSlot2 Hmac/Sha1
02. Test Totp/Sha1 touch required,PIN required
georg@heka:~>

Habe ich hier ein FW Bug getroffen?

Denn das Ganze ist reproduzierbar mit meinem NK3.

Welche python version läuft denn?

georg@heka:~> python3 --version
Python 3.13.12
georg@heka:~>

Genau die Selbe:

python3 --version
Python 3.13.12

Ich glaube ich habe das Problem gefunden, es schaut wie ein Bug im nitropy aus. Denn im Log (/tmp/nitropy-*.log) ist folgendes zu sehen:

227        INFO pynitrokey.cli Cli arguments: [‘nk3’, ‘secrets’, ‘add-otp’, ‘–protect-with-pin’, ‘–touch-button’, ‘–hash’, ‘sha1’, ‘–kind’, ‘totp’, ‘muhh’, ‘DDD’]

otpapp Setting new credential: b’muhh’, Kind.Totp, Algorithm.Sha1, counter: 0, touch_button_required=False, pin_based_encryption=False

Das sieht für mich so aus, als wird dem Programm überheben, aber nicht dem NK.

Ich habe zwischenzeitlich meine secret app mittels NitokeyApp2 zurückgesetzt, den Befehl abgesetzt, in der NitrokeyApp2 die pin gesetzt, nochmals den Befehl abgesetzt und credentials gelistet.

Parallel habe ich mir das in der NitrokeyApp2 auch angeschaut. Ich denke, das ist das erwartbare Ergebnis.

georg@heka:~> nitropy nk3 secrets add-otp --protect-with-pin --touch-button --hash sha1 --kind totp Test AAAAAAAAAAAA
Command line tool to interact with Nitrokey devices 0.12.0
Please touch the device if it blinks
PIN is required to run this command.
Health check notes:
- Application does not have a PIN. Set PIN before the first use.
Aborted!
georg@heka:~> nitropy nk3 secrets add-otp --protect-with-pin --touch-button --hash sha1 --kind totp Test AAAAAAAAAAAA
Command line tool to interact with Nitrokey devices 0.12.0
Please touch the device if it blinks
PIN is required to run this command.
Current PIN (8 attempts left):
Please touch the device if it blinks
Done
georg@heka:~> nitropy nk3 secrets list
Command line tool to interact with Nitrokey devices 0.12.0
Please provide PIN to show PIN-protected entries (if any), or press ENTER to skip
Please touch the device if it blinks
Current PIN (8 attempts left):
Please touch the device if it blinks
01. Test Totp/Sha1 touch required,PIN required
georg@heka:~>

Das Skurrile ist, das die NitrokeyApp2 funktioniert. Nur bei pynitrokey tritt das Problem auf.

Kommandozeilenargumente in pynitrokey werden vom Python-Paket click verarbeitet. Und wenn man in dessen Issue-Tracker schaut, gab es wohl den einen oder anderen Bug beim Verarbeiten von Flags. Ein Beispiel: Options of type=bool and is_flag=true are not set with click 8.2.0 · Issue #2914 · pallets/click · GitHub

Vielleicht könnt Ihr mal Eure click-Versionen abgleichen…

Sorry, aber da bin ich zu zu dusselig zu.:grin:

Es gibt einen offenen bug für HMAC-SHA1 mit touch: allow setting touch required and/or pin required for hmac-sha1 · Issue #487 · Nitrokey/pynitrokey · GitHub

Könnte sein das es zusammen hängt, @daringer wüsste die Antwort sicher.

Könntest probieren ob es funktioniert –touch-pin über ein update hinzuzufügen, wie hier: allow setting touch required and/or pin required for hmac-sha1 · Issue #487 · Nitrokey/pynitrokey · GitHub

Das mit dem click kann es nicht sein:

~/Nitrokey/pynitrokey/bin/pip list
Package            Version




certifi            2025.4.26
cffi               1.17.1
charset-normalizer 3.4.2
click              8.3.2
click-aliases      1.0.5
crcmod             1.7
cryptography       44.0.3
ecdsa              0.19.1
fido2              2.0.0
fire               0.7.0
hidapi             0.14.0.post2
idna               3.10
intelhex           2.3.0
libusb1            3.3.1
nethsm             2.1.0
nitrokey           0.4.2
nkdfu              0.2
pip                26.0.1
protobuf           5.29.4
pycparser          2.22
pynitrokey         0.12.0
pyserial           3.5
python-dateutil    2.9.0.post0
pyusb              1.3.1
requests           2.32.3
semver             3.0.4
setuptools         80.7.1
six                1.17.0
termcolor          3.1.0
tlv8               0.10.0
tqdm               4.67.1
typing_extensions  4.3.0
urllib3            2.0.7

@ion Das mit dem HMAC scheint ja auf die FW abzuzielen wenn ich das richtig verstehe. Wie ich aber dem Log entnehmen konnte, werden die Optionen einfach nicht an den NK3 gesendet.

Habe hier die ältere click version, (distrobox debian/trixie container unter openSUSE Leap 16)

📦[georg@debian001 ~]$ pip list
Package         Version
--------------- ---------
argcomplete     3.6.3
babel           2.17.0
click           8.1.8
ghp-import      2.1.0
iniconfig       2.1.0
Jinja2          3.1.6
joblib          1.5.2
livereload      2.7.1
lunr            0.8.0
Markdown        3.10.2
MarkupSafe      3.0.3
mergedeep       1.3.4
mkdocs          1.6.1
mkdocs-get-deps 0.2.0
nltk            3.9.3
numpy           2.3.5
packaging       26.0
pathspec        1.0.4
pip             26.0.1
pipx            1.11.1
platformdirs    4.9.4
pluggy          1.6.0
psutil          7.1.0
pyasyncore      1.0.2
Pygments        2.19.2
pyinotify       0.9.6
pytest          9.0.2
python-dateutil 2.9.0
PyYAML          6.0.3
pyyaml_env_tag  1.1
regex           2025.9.18
tornado         6.5.5
tqdm            4.67.3
userpath        1.9.2
watchdog        6.0.0
wheel           0.46.3
📦[georg@debian001 ~]$

Habe es nun auch mit nitropy Version 0.12.0 unter Linux getestet:

sudo ./bin/nitropy nk3 secrets add-otp --protect-with-pin --touch-button --hash sha1 --kind totp Test AAAAA

Funktioniert wie erwartet. (sudo, da ich mich für den Test nicht mit udev auseinandersetzen wollte.)

Vielleicht entdeckst Du im Vergleich zu Deinem Log-File ja den entscheidenden Unterschied:

904        INFO pynitrokey.cli Python version: 3.11.2
904        INFO pynitrokey.cli Cli arguments: ['nk3', 'secrets', 'add-otp', '--protect-with-pin', '--touch-button', '--hash', 'sha1', '--kind', 'totp', 'Test', 'AAAAA']
905        INFO pynitrokey.cli pynitrokey version: 0.12.0
907        INFO pynitrokey.cli cryptography version: 46.0.7
908        INFO pynitrokey.cli fido2 version: 2.1.1
910        INFO pynitrokey.cli nethsm version: 2.1.0
911        INFO pynitrokey.cli nitrokey version: 0.4.2
912        INFO pynitrokey.cli pyusb version: 1.3.1
1369      DEBUG       root print: Please touch the device if it blinks
1369       INFO     otpapp Sending CCIDInstruction.Select (data: 12 bytes)
1417       INFO     otpapp Received [9000] (data: 14 bytes)
1417       INFO     otpapp TLV-decoding of data successful
1417       INFO     otpapp Setting new credential: b'Test', Kind.Totp, Algorithm.Sha1, counter: 0, touch_button_required=True, pin_based_encryption=True
1417       INFO     otpapp Sending Instruction.Put (data: 20 bytes)
1561       INFO     otpapp Received [6982] (data: 0 bytes)
1561      DEBUG       root print: PIN is required to run this command.
1561       INFO     otpapp Sending CCIDInstruction.Select (data: 12 bytes)
1597       INFO     otpapp Received [9000] (data: 14 bytes)
1597       INFO     otpapp TLV-decoding of data successful
1597       INFO     otpapp Sending CCIDInstruction.Select (data: 12 bytes)
1633       INFO     otpapp Received [9000] (data: 14 bytes)
1633       INFO     otpapp TLV-decoding of data successful
1633       INFO     otpapp Sending CCIDInstruction.Select (data: 12 bytes)
1669       INFO     otpapp Received [9000] (data: 14 bytes)
1669       INFO     otpapp TLV-decoding of data successful
4548      DEBUG       root print: Please touch the device if it blinks
4548       INFO     otpapp Sending Instruction.VerifyPIN (data: 13 bytes)
8554       INFO     otpapp Received [9000] (data: 0 bytes)
8554       INFO     otpapp Setting new credential: b'Test', Kind.Totp, Algorithm.Sha1, counter: 0, touch_button_required=True, pin_based_encryption=True
8555       INFO     otpapp Sending Instruction.Put (data: 20 bytes)
8806       INFO     otpapp Received [9000] (data: 0 bytes)
8806      DEBUG       root print: Done

Das ist ein nitropy bug report. Einfach mal die update Methode aus dem zweiten Link probieren.

@czietz siehe meinem Log, es wird nicht an den NK übergeben.
So wie bei dir in dem Block 1417. Bei mir ist das alles false. Obwohl in Block 904 wie bei dir die Option gesetzt sind.
@ion
Das anschließenden setzen der Touch Anforderung geht, nur die PIN kann man nicht nachträglich setzen.

1 Like