Repository navigation
Description
s5.6.7.1 of the specification reads (after some trimming):
Perform a pre-order depth-first search for metadata about the desired target, beginning with the top-level targets role. [...] If this role has been visited before, then skip this role (so that cycles in the delegation graph are avoided). [...]
A plain reading of this implies that throughout the entire depth-first search you cannot walk into the same delegation more than once even via different delegation chains. For instance, if there was a delegation from targets to roleA to roleB and a later delegation from targets to roleC to roleB then a plain reading would imply that the second delegation to roleB should be skipped because "[the] role has been visited before".
I noticed this a few months ago and it is how go-tuf/v2 currently implements the behaviour so I figured this was a TUF quirk we would need to work around for our usecase, but after speaking to @JustinCappos recently it seems that this is not the intended meaning of the sentence. Instead the intention was to stop a delegation chain delegating to some role already visited in that branch (for instance, roleA delegating to roleB delegating to roleA which would lead to a cycle) -- which explains the mention of cycles.
The current wording is quite problematic for a few reasons, as it makes large repositories with delegations controlled by different users (with different trust levels) quite fragile (a user earlier in the chain than you can cause your delegations to fail silently) and it also makes implementing features like listing all available targets in a repository very complicated (as it would require emulating this behaviour for later delegations and potentially computing inverse matches rather than treating each branch on its own).
I'd propose the wording be changed to clarify the expected behaviour. As a very rough proposal, something more like:
7. **Perform a pre-order depth-first search for metadata about the
- desired target, beginning with the top-level targets role.** Note: If
+ desired target, beginning with the top-level targets role**, taking note
+ of the delegation path taken when walking into each role.
+ Note: If
any metadata requested in steps 5.6.7.1 - 5.6.7.2 cannot be downloaded nor
validated, end the search and report that the target cannot be found.
- 1. If this role has been visited before, then skip this role
- (so that cycles in the delegation graph are avoided). Otherwise, if an
+ 1. If this role has been visited before in the delegation path used to reach
+ this role, then skip this role (so that cycles in the delegation graph are avoided).
+ Otherwise, if an
application-specific maximum number of roles have been visited, then go to
step [[#fetch-target]] (so that attackers cannot cause the client to waste excessive
bandwidth or time). Otherwise, if this role contains metadata about the
desired target, then go to step [[#fetch-target]].(Line breaks broken on purpose to keep the diff readable.)
Activity
joshuagl commentedon Aug 5, 2026
Thanks. I like the suggestion as it does indeed improve clarity.
Prior to landing this change we might want to reach out to maintainers of known implementations (go-tuf, python-tuf, rust-tuf, tough, php-tuf, ???) to see if they want to update their implementations.
cyphar commentedon Sep 11, 2026
Should we just ping them here or in Slack? IIRC @JustinCappos said that the go-tuf maintainers were recently made aware of this behaviour being unintended.
cyphar commentedon Sep 15, 2026
It would also be good to know if the next sentence:
Was also intended to be a global limit or not.
JustinCappos commentedon Sep 15, 2026
Yes, this is meant to be a global limit.
cyphar commentedon Sep 16, 2026
Hmmm, sadly that makes listing all the entries in a TUF repo a little more problematic -- because delegations are not walked if the patterns don't match the number of delegations you see depends on the target file name.
That's fine if you're just fetching one target file (which is the primary thing the spec talks about) but if you are getting a listing of all target files it becomes difficult to track whether a delegation should be permitted (or for what subset of target file names it should be permitted). You can restrict obviously bad things like straight-line delegation chains longer than your limit, as well as come up with some heuristics about the total number of hops, but it's all a bit ill-defined. :/
cyphar commentedon Sep 17, 2026
I was looking at the code in
go-tufwhile implementing this behaviour for our tooling and they will need to be quite careful to make sure that they do not accidentally introduce a security bug when changing their behaviour.loadTargetsis called for each step in the loop but it skips callingUpdateDelegatedTargets(which includes delegation verification) if the data is already inTrustedMetadata. If they were to just modifypreOrderDepthFirstWalkto track the delegation chain, they would introduce a pretty gnarly security issue (an earlier delegation trusting a role would cause the role to be trusted by later delegations even if it wasn't signed by the right keys)./cc @kommendorkapten @mnm678 @MDr164 @rdimitrov
(Sorry, not sure where was the best place to put this but I didn't want it to disappear into the ether.)