-
Notifications
You must be signed in to change notification settings - Fork 278
repository_tool: Root pre-verification during metadata writes misses possible verification failures #883
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
Comments
Signed-off-by: Aditya Saky <[email protected]>
Which is what's expected, right? And shouldn't the same count for
Same as above goes for Am I missing something? |
It's possible to go that way (referring to the prior trusted root file). If we were talking about the client, that is certainly the direction we'd go (and do go btw; client preserves current and previous metadata). It's less clear to me that when working with It should be noted that the issue above describes the current scheme (noting changes when they're made) and how it is broken and how to make it work without a paradigm change. You could rebuild it a bit by developing a sense of which written metadata files are the preceding finished files, but this could be slightly trickier than the straight fixes. |
As for your specific question about If this doesn't clear things up, I'll provide a detailed example, so LMK. |
Signed-off-by: Lukas Puehringer <[email protected]>
Signed-off-by: Lukas Puehringer <[email protected]>
Closing this issue as it was filed against (what is now known as) the legacy codebase: issue seems to not be relevant anymore. Please re-open or file a new issue if you feel that the issue is revelant to current python-tuf. Specifically on validation before writing:
More detailsCurrent source code (and upcoming 1.0 release) only contains the modern components
Legacy components (e.g. tuf.client, tuf.repository_tool, tuf.repository_lib as well as the repo and client scripts) are no longer included. See announcement and API reference for more details. |
Summary and Impact
This is a bug that occurs when root metadata is being verified before being written. This pre-write verification is intended to prevent the writing of metadata that would not be verifiable by a client. The code is flawed, and so it is readily possible to produce root metadata that will not be verifiable by a client.
Note that this bug does not result in incorrect client verification behavior, and so is not strictly a security issue. Problems can result from this behavior, however.
Background and Details
When writing new metadata (e.g. using
repository_tool.write*
), the write stack employsrepository_lib._generate_and_write_metadata()
._generate_and_write_metadata
:roledb._roledb_dict[<repo>][<role>]['signing_keyids']
There is a substantial bug in step 2 that results in this verification check failing to catch root metadata that a client might reject. Note that the way that step 1 works will be altered by #846 (alters internal metadata storage to match the written metadata format) and that the bug in step 2 will also be fixed by #846. It may be worth fixing this bug in parallel, however, and it must in any case be recorded.
Root metadata is a bit special. Any other top-level metadata can be verified by simply looking at the contemporaneous root metadata. Root metadata itself dictates the keys expected for verification of root metadata, however, and that means that (e.g.) clients will use version 5 of root to verify version 6 of root. To generalize: in order to verify version V of root, you must verify that it has good signatures from BOTH:
We don't want users of
repository_tool
to write metadata that can't be verified, so we check that; however, we do the verification against expected keyids & threshold from root version V-1 incorrectly. In particular, when we userepository_tool
to update root's expectations of root (usingrepository_tool.add_verification_key()
,repository_tool.remove_verification_key()
, andrepository_tool.threshold()
), old values are saved inroledb._roledb_dict[<repo>][<role>]['previous_threshold']
and...['previous_keyids']
, but:remove_verification_key
doesn't note prior values in those variablesadd_verification_key
andthreshold
overwrite what they last added to those variables, resulting in the wrong values if e.g. you add two verification keys between one root version and the next, or if (much less likely) you switch the threshold value twice before writing.The Fix:
...['previous_keyids']
, don't overwrite it. The same goes for `...['previous_threshold'].#846 should also result in a fix to this, with slightly different properties, as those values will be moved.
The text was updated successfully, but these errors were encountered: