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

pkcs11-tool: Insecure default template attributes allow WRAP & DECRYPT attack #1913

Closed
crtxcr opened this issue Jan 25, 2020 · 5 comments · Fixed by #1915
Closed

pkcs11-tool: Insecure default template attributes allow WRAP & DECRYPT attack #1913

crtxcr opened this issue Jan 25, 2020 · 5 comments · Fixed by #1915

Comments

@crtxcr
Copy link

crtxcr commented Jan 25, 2020

Problem Description

pkcs11-tool sets wrap and unwrap to true. There is no way to unset wrap and unwrap when generating keys.
Furthermore, this default template is a classic PKCS#11 attack, see e. g. https://link.springer.com/content/pdf/10.1007%2F978-3-540-45238-6_32.pdf section 2.3

Proposed Resolution

  • Do not set CKA_WRAP and CKA_UNWRAP with the value of to true in templates by default
  • Allow specifcing by command line whether CKA_WRAP and CKA_UNWRAP should be set to true or not.
@frankmorgner frankmorgner added this to To do in Release 0.21.0 Jan 26, 2020
@frankmorgner
Copy link
Member

Thanks for the links. OpenSC has just released the first version which actually supports a card that's capable of wrapping a key, so I guess, you're talking about using pkcs11-tool with different pkcs11 modules. Anyway,

I'll look at this for the next release. Feel free to make a pull request if you find the time.

@frankmorgner
Copy link
Member

@hongquan the issues mostly relate to the token's implementation, you may want to have a look...

@frankmorgner
Copy link
Member

I've created #1915 which uses the proposed solution.

@crtxcr
Copy link
Author

crtxcr commented Jan 27, 2020

so I guess, you're talking about using pkcs11-tool with different pkcs11 modules

Correct. I am implementing (parts of) a pkcs11 token right now and I am testing some things with pkcs11-tool. This token prevents the WRAP & DECRYPT attack above by checking whether wrap and decryption related flags are set, although it will not implement the wrap & unwrap functionality soon. But I at least needed the option to disable disable wrap attribute, because my token would not allow me to create the keys.

The question now of course is whether OpenSC itself wants to take a similar approach. It probably was never relevant since it didn't support C_WrapKey until recently. It is unfortunate that by following PKCS#11 strictly you introduce problems like this though. But maybe this should be discussed in a separate issue?

@dengert
Copy link
Member

dengert commented Jan 27, 2020

A corollary to this issue is: Unless the card can prevent the WRAP & DECRYPT attack,(which your card can do, adding OpenSC support to prevent the attack does not stop a hacker from using other software or a modified OpenSC to still do the attack.

Release 0.21.0 automation moved this from To do to Done Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants