Skip to content

tuf: use bundled trusted root if available#542

Merged
woodruffw merged 16 commits intosigstore:mainfrom
trail-of-forks:andrew/bundled-trust-root
Mar 23, 2023
Merged

tuf: use bundled trusted root if available#542
woodruffw merged 16 commits intosigstore:mainfrom
trail-of-forks:andrew/bundled-trust-root

Conversation

@tnytown
Copy link
Contributor

@tnytown tnytown commented Mar 12, 2023

Summary

This changeset modifies the TUF component to fetch keys from the trusted_root.json target, if available. trusted_root.json is a rollup of Sigstore component public keys. Using this target reduces the number of network roundtrips necessary to fetch keys individually.

Resolves #488.

Release Note

Documentation

@tnytown tnytown force-pushed the andrew/bundled-trust-root branch from f25a78c to 27f6dc9 Compare March 12, 2023 17:49
@woodruffw woodruffw requested a review from tetsuo-cpp March 13, 2023 17:06
@woodruffw woodruffw added the component:tuf TUF related components label Mar 13, 2023
Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

@tetsuo-cpp can do a full review, but as a small nit: needs a CHANGELOG entry 🙂

@tnytown
Copy link
Contributor Author

tnytown commented Mar 14, 2023

I've left this one on draft because I haven't adjusted the tests to exercise the new codepaths. Most of the new logic seems trivial except for the stuff that ensures that a given target in a trusted root is active/expired. I'll work on adding some basic testing for that.

@tnytown tnytown force-pushed the andrew/bundled-trust-root branch from 8737363 to ce334bc Compare March 15, 2023 20:39
Signed-off-by: Andrew Pan <[email protected]>
@tnytown tnytown marked this pull request as ready for review March 15, 2023 20:44
@tnytown tnytown changed the title [WIP] tuf: use bundled trusted root if available tuf: use bundled trusted root if available Mar 15, 2023
Co-authored-by: William Woodruff <[email protected]>
Signed-off-by: Andrew Pan <[email protected]>
tetsuo-cpp
tetsuo-cpp previously approved these changes Mar 22, 2023
Copy link
Contributor

@tetsuo-cpp tetsuo-cpp left a comment

Choose a reason for hiding this comment

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

LGTM!

@woodruffw
Copy link
Member

sigstore/_internal/keyring.py:81:39: F841 [*] Local variable `e` is assigned to but never used

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

Small nits 🙂

Comment on lines +288 to +289
if not _is_timerange_valid(ca.valid_for, allow_expired=True):
continue
Copy link
Member

Choose a reason for hiding this comment

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

This is a no-op, right? If so maybe we can just omit it entirely, and perhaps just leave a comment to the effect of "we could check _is_timerange_valid here but don't bother to, since expired Fulcio chains are considered valid for verification purposes."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_is_timerange_valid also checks that the current timestamp is after valid_for's start, so in the off chance where that is not the case, this check will fail.

That being said, this detail is not too clear. I'll add a docstring to _is_timerange_valid :)

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks!

@tnytown tnytown requested a review from woodruffw March 23, 2023 05:13
@tnytown tnytown self-assigned this Mar 23, 2023
Co-authored-by: William Woodruff <[email protected]>
Signed-off-by: Andrew Pan <[email protected]>
Comment on lines +156 to +157
@lru_cache()
def _updater(self) -> Updater:
Copy link
Member

Choose a reason for hiding this comment

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

Once we upgrade to 3.8 this can become cached_property, which will be nice. But until then, this LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep! I was intending to use cached_property until I saw that it was 3.8+ :( Apparently cryptography polyfills it though!

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM. Two thoughts:

  1. Assuming the Sigstore TUF repo maintainers are okay with it, I think we can transition to codebase to assuming a trust root bundle (and failing if not present) after a migration period. We could retain an explicit opt-in flag (like --tuf-unbundled-trust-root), if necessary. CC @asraa for thoughts 🙂

  2. We should add some more unit tests for the bundled trust root. @tnytown could you make a follow-up issue for that?

@woodruffw woodruffw merged commit 7b390f4 into sigstore:main Mar 23, 2023
@woodruffw woodruffw deleted the andrew/bundled-trust-root branch March 23, 2023 23:22
Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

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

This is amazing!!

Yes - we are planning to have this be the stable trusted root target from now on. We will leave the existing targets in there for likely a year, and then deprecate them, so the current code with defaults for the trusted_root.json looks good to me.

Honestly, I wouldn't add an option to use the fallback old unbundled targets. IMO there's no need to, the behavior and targets are the same in both the bundled and unbundled so users wouldn't see any difference

@woodruffw
Copy link
Member

Makes sense, thanks @asraa!

@tnytown: In that case, let's plan to remove support for the old "standalone" targets in an upcoming release. This is entirely an implementation detail in a private API, so we can do it with a patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:tuf TUF related components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUF: Support "bundled" trust root

4 participants