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

Crash when signing large payloads #122

Closed
ebourg opened this issue Feb 21, 2023 · 2 comments
Closed

Crash when signing large payloads #122

ebourg opened this issue Feb 21, 2023 · 2 comments

Comments

@ebourg
Copy link

ebourg commented Feb 21, 2023

Using the firmware 1.2.2-alpha.20221130, signing a too large payload crashes the Nitrokey (the LED turns red, the key is unresponsive and must be unplugged). Here is an example with a RSA 2048 key:

CommmandAPDU: 11 bytes, nc=6, ne=0
00000000 00 20 00 81 06 31 32 33 34 35 36                . ...123456

ResponseAPDU: 2 bytes, SW=9000 (50 ms)

CommmandAPDU: 263 bytes, nc=256, ne=0
00000000 00 2A 9E 9A 00 01 00 00 00 00 00 00 00 00 00 00 .*..............
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000100 00 00 00 00 00 00 00                            .......

I guess the size of the payload should be checked, and an error 0x6700 (Wrong Length) returned if it's too big.

@sosthene-nitrokey
Copy link
Collaborator

Thank you for the report.

This was caused by a bug in the RSA integration in Trussed for which a fix is ready: Nitrokey/trussed#11

The issue was on the contrary that the length was checked, but the error was not handled, which translated to a Rust panic, aka red LED + the key stops working.

Future releases will actually use a different approach to RSA integration in Trussed that also contains the fix: #116

@sosthene-nitrokey
Copy link
Collaborator

This was fixed by #116 which is now included in the 1.4.0 Nitrokey 3 stable firmware.

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

No branches or pull requests

2 participants