-
Notifications
You must be signed in to change notification settings - Fork 29
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
bug: fail to verify COSE signature with extra attributes in the protected header #88
Comments
I will take this one. |
Can this cause issues if a plugin is expecting those attributes? Also, silently ignoring attributes doesn't look right. Do you have a specific usecase?
What will we do in case of a collision? IMO unless we have a specific usecase to support, we should continue to fail verification if we encounter non-string keys in signed attributes. |
Please correct me if I'm wrong, according to our implementation in notation-go executePlugin, we are only passing critical extended attributes to plugin.VerifySignatureRequest. In other words, if a plugin expects a certain attribute, it has to be marked as critical anyway. For COSE envelope, there could be non-string keys, for example, key of kid is 4. In this case, if it is non-critical, we can ignore it instead of failing the verification (one of our users is blocked due to this logic). If it's marked critical, we return an error requiring string type. If a plugin expects this extended attribute, then it needs to mark the attribute as critical for now. |
Yes, currently we only pass critical attributes to plugin but we don't want to limit it for future usecase. In cose both |
So we have 2 scenarios here:
For Notation, my understanding is that Sign and Verification are two separated operations. One can generate his own COSE Envelope somewhere else and use Notation to Verify it. Hence, I think we should accept a more general form of Signature Envelope like the one I mentioned above. |
@rgnote @priteshbandi Any further comments/concerns on this one? |
Ignoring keys silently doesn't seem the right approach here. It is a one-way door decision where notation will never be able to enforce string keys for non-critical extended attributes in the future. I agree that users should be able to verify signatures that are generated outside notation, but that doesn't mean notation allows verification of signatures that don't follow the notation guidelines. We should keep signatures restricted to what types notation is expecting today so that we can loosen these restrictions when we see new usecases (as opposed to the other way around) That being said, can you explain your usecase where x5t ( |
It's because the COSE Header Parameters regulates the label type of a COSE header, from which it can be string or integer. In other words, if we claim to support COSE format, then we need to follow the COSE standard (in standard, x5t has label 34 as int). |
LGTM |
Fixed issue #88. After this update: 1. JWS extended attribute keys still enforce string type. 2. COSE extended attribute keys will accept string and int type. Signed-off-by: Patrick Zheng <[email protected]>
Reopening as this is causing an issue with verification plugins. As part of |
@rgnote In the spec you've pointed, |
@shizhMSFT The issue is around |
@rgnote I propose that |
Can you clarify how we will pass the attribute values if it is a array?
non-critical attributes are not passed at all to the plugins. Please take a look at this code. extendedAttributes and unprocessedAttributes are tightly related. |
I raised this PR to unblock JWS signatures. Please raise a PR for spec updates once you have an idea on how verification plugins needs to deal with COSE extended attributes |
Temporary fix for notaryproject/notation-core-go#88 Signed-off-by: rgnote <[email protected]>
Closed by notaryproject/notation-go#188 and will follow up notaryproject/specifications#201 |
Temporary fix for notaryproject/notation-core-go#88 Signed-off-by: rgnote <[email protected]> Signed-off-by: Patrick Zheng <[email protected]>
When the COSE signature contains extra attribute keys, which are integers not strings, the code reports error:
Those keys should be ignored if not marked as critical, or report error if marked as critical. If they are known attributes, we may convert keys into strings so that it can fill in the
signature.Attribute
structure.Related code:
notation-core-go/signature/cose/envelope.go
Lines 531 to 544 in b5df54c
The text was updated successfully, but these errors were encountered: