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

PKCS#11 URI query attribute parsing broken #142

Closed
lkundrak opened this issue Jan 11, 2017 · 7 comments
Closed

PKCS#11 URI query attribute parsing broken #142

lkundrak opened this issue Jan 11, 2017 · 7 comments
Labels

Comments

@lkundrak
Copy link

According to the grammar on page 5 of RFC 7512, the p11-value attribute is a query attribute, not a path attribute.

These are correct:

pkcs11:token=test-token;object=client;type=private?pin-value=123456
pkcs11:token=test-token;object=client;type=private?vendor-attribute=666&pin-value=123456

This is not (well, technically it might be considered a vendor specific attribute...):

pkcs11:token=test-token;object=client;type=private;pin-value=123456

Therefore, the URI parser should look for it in the query part. Moreover, it should preferrably reject it in the path, as unlike the path part of the URI it's potentially sensitive information and applications may be assuming that it's okay to handle the path as non-sensitive (e.g. print it into log files). Not sure how feasible would that be though, since it will probably break user configurations.

@mtrojnar
Copy link
Member

@dwmw2 What do you think?
The RFC 7512 parser was your contribution: OpenSC/engine_pkcs11@853a087...

@mtrojnar mtrojnar added the bug label Jan 12, 2017
@mouse07410
Copy link
Contributor

Hmm... I for one see no problem with this:

pkcs11:token=test-token;object=client;type=private;pin-value=123456

and don't see why it should stop working.

@mtrojnar
Copy link
Member

We don't have to (and probably we should not) detect invalid URIs. We just need to accept valid ones. Accepting "?" and "&" as alternative separators besides ";" should do the job.
Does it make sense?

@mouse07410
Copy link
Contributor

Makes perfect sense, thank you!

@dwmw2
Copy link
Contributor

dwmw2 commented Jan 13, 2017

By this point I'm quite keen on ditching my own implementation of the parser altogether, and just using libp11-kit instead...

@lo1ol
Copy link

lo1ol commented Jun 15, 2021

Sorry for too late comment. I think it's was not a good decicion to accept ";?&" as common seporators.

The problem may become when pk11-pattr attributes contains "&" inside values. For example, take a "pkcs11:token=token&serial=12345678?pin-value=1234567" URI.

  1. RFC parser parses for this:
    token="token&serial=12345678"
    pin-value="1234567"
  2. Your parser parses for this:
    token="token"
    serial="12345678"
    pin-value="1234567"

So, what do your think about changing your parser to the right RFC version in future?

@dwmw2
Copy link
Contributor

dwmw2 commented Jun 15, 2021

I still think we should ditch it and use the p11-kit one.

In fact since OpenSSL has deprecated ENGINEs entirely, I think there's a lot of scope for building a new OpenSSL 'provider' around p11-kit directly.

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

No branches or pull requests

5 participants