Skip to content

Commit 48b58d9

Browse files
author
Jussi Kukkonen
committed
Metadata API: Don't peek into Key internals
There was an attempt at ensuring key content uniqueness in verify_delegate() by making sure the values corresponding to "public" keys in Key.keyval dictionaries are unique. This had two issues: * it wasn't a security measure: it's not difficult to produce two different "public" values of the same key content * Spec does not actually guarantee the existence of "public" key in the keyval dictionary (the three keys included in the spec just all happen to have it) Luckily the spec does require KEYIDs to be unique so we do not need to do all this: Just count keyids of keys with verified signatures. Keep building a Set of keyids as a belt-and-suspenders strategy: Role keyids are currently guaranteed to be unique but we'd notice here if they weren't. Add a logger call for failed verifys: this might useful to figure out which keys exactly are the issue when a delegate can not be verified. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent d00af4c commit 48b58d9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tuf/api/metadata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818
import abc
1919
import io
20+
import logging
2021
import tempfile
2122
from collections import OrderedDict
2223
from datetime import datetime, timedelta
@@ -49,6 +50,8 @@
4950

5051
# pylint: disable=too-many-lines
5152

53+
logger = logging.getLogger(__name__)
54+
5255
# We aim to support SPECIFICATION_VERSION and require the input metadata
5356
# files to have the same major version (the first number) as ours.
5457
SPECIFICATION_VERSION = ["1", "0", "19"]
@@ -309,10 +312,9 @@ def verify_delegate(
309312
key = keys[keyid]
310313
try:
311314
key.verify_signature(delegate, signed_serializer)
312-
# keyids are unique. Try to make sure the public keys are too
313-
signing_keys.add(key.keyval["public"])
315+
signing_keys.add(key.keyid)
314316
except exceptions.UnsignedMetadataError:
315-
pass
317+
logger.info("Key %s failed to verify %s", keyid, role_name)
316318

317319
if len(signing_keys) < role.threshold:
318320
raise exceptions.UnsignedMetadataError(

0 commit comments

Comments
 (0)