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

fix(verify): Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) #369

Conversation

cedricvanrompay-datadog
Copy link
Contributor

Release Notes: Fixes a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs)

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of the changes being introduced by the pull request:

Go-TUF has a security vulnerability in the way it validates threshold signatures: it relies on the key IDs declared in the metadata file it is currently validating (varibale sig.KeyID) to tell if this new signature should count towards the threshold, assuming that these IDs will be the same as the one it generates (verifier.MarshalPublicKey().IDs()). This assumption can be made false and this can be leveraged to forge valid threshold signatures using a number of keys which, in theory, should be insufficient.

This PR adds a test demonstrating the vulnerability, then it fixes the vulnerability.

My opinion however is that Go-TUF should stop trying to be compatible with old versions of TUF implementations that were assigning several IDs to a same key, as this makes signature validation way too error-prone. Note that all versions of the TUF specification since version 1 are very clear on there being a single correct way to compute the key ID:

KEYID: The identifier of the key signing the ROLE object, which is a hexdigest of the SHA-256 hash of the canonical form of the key. The keyid MUST be unique in the "signatures" array: multiple signatures with the same keyid are not allowed.

source: https://theupdateframework.github.io/specification/v1.0.29/index.html#role-keyid

KEYID: A KEYID, which MUST be correct for the specified KEY. Clients MUST calculate each KEYID to verify this is correct for the associated key. Clients MUST ensure that for any KEYID represented in this key list and in other files, only one unique key has that KEYID.

source: https://theupdateframework.github.io/specification/v1.0.29/index.html#root-keyid

Also, I am aware that TAP 12 (which does not apply to TUF 1.0.x anyway) introduces key ID flexibility. A better solution than the one in this PR would be to apply the recommendation in TAP 12 to "use a standardized representation for keys, like the modulus and exponent for RSA or the point and curve for ECC". That's probably something we should do in Go-TUF without waiting for TUF 1.1.

Please verify and check that the pull request fulfills the following requirements:

  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

@cedricvanrompay-datadog cedricvanrompay-datadog changed the title Fix key id threshold signature Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) Sep 2, 2022
@cedricvanrompay-datadog
Copy link
Contributor Author

I realise I should probably have shared this privately with the maintainers instead of sending a public PR, apologies.

@trishankatdatadog
Copy link
Member

Thanks for reporting this. I had found a similar issue for python-tuf before, but unfortunately we never got around to publishing it, which may explain why no other implementations had noticed.

It looks good on a cursory glance, but let us review and merge ASAP.

@mnm678
Copy link
Collaborator

mnm678 commented Sep 2, 2022

I'll do a more detailed review, but it looks like this needs DCO and conventional commits

I realise I should probably have shared this privately with the maintainers instead of sending a public PR, apologies.

Yes, for future reference, but thanks for sharing this. We'll work to improve our security reporting docs to make the private reporting process more clear in the future.

@mnm678
Copy link
Collaborator

mnm678 commented Sep 2, 2022

LGTM. I'll approve pending the failing checks

@trishankatdatadog trishankatdatadog changed the title Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) fix: Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) Sep 2, 2022
@trishankatdatadog trishankatdatadog changed the title fix: Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) fix(verify): Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) Sep 2, 2022
Copy link
Member

@trishankatdatadog trishankatdatadog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @cedricvanrompay-datadog, @ethan-lowman-dd, and I discussed this over Zoom, thanks!

@trishankatdatadog trishankatdatadog merged commit 64ded18 into theupdateframework:master Sep 2, 2022
@znewman01 znewman01 mentioned this pull request Sep 2, 2022
znewman01 pushed a commit to znewman01/go-tuf that referenced this pull request Sep 7, 2022
…natures (due to handling of keys with multiple IDs) (theupdateframework#369)

* add test for several signatures same key diff ID

* fix verifying threshold signatures

* add some comments

* rename variables and add comments

Co-authored-by: Trishank Karthik Kuppusamy <trishank.kuppusamy@datadoghq.com>
znewman01 pushed a commit to znewman01/go-tuf that referenced this pull request Sep 7, 2022
…natures (due to handling of keys with multiple IDs) (theupdateframework#369)

* add test for several signatures same key diff ID

* fix verifying threshold signatures

* add some comments

* rename variables and add comments

Co-authored-by: Trishank Karthik Kuppusamy <trishank.kuppusamy@datadoghq.com>
Signed-off-by: Zachary Newman <z@znewman.net>
znewman01 added a commit that referenced this pull request Sep 7, 2022
…eshold si… (#375)

fix(verify):  Fix a vulnerability in the verification of threshold signatures (due to handling of keys with multiple IDs) (#369)

* add test for several signatures same key diff ID

* fix verifying threshold signatures

* add some comments

* rename variables and add comments

Co-authored-by: Trishank Karthik Kuppusamy <trishank.kuppusamy@datadoghq.com>
Signed-off-by: Zachary Newman <z@znewman.net>

Signed-off-by: Zachary Newman <z@znewman.net>
Co-authored-by: Cédric Van Rompay <97546950+cedricvanrompay-datadog@users.noreply.github.com>
Co-authored-by: Trishank Karthik Kuppusamy <trishank.kuppusamy@datadoghq.com>
@cedricvanrompay-datadog cedricvanrompay-datadog deleted the fix-key-id-threshold-signature branch September 7, 2022 16:59
arbll pushed a commit to DataDog/go-tuf that referenced this pull request Sep 28, 2022
…natures (due to handling of keys with multiple IDs) (theupdateframework#369)

* add test for several signatures same key diff ID

* fix verifying threshold signatures

* add some comments

* rename variables and add comments

Co-authored-by: Trishank Karthik Kuppusamy <trishank.kuppusamy@datadoghq.com>
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

Successfully merging this pull request may close these issues.

None yet

4 participants