Skip to content

Metadata API: Reject non-canonical bin names in SuccinctRoles - #3034

Open
Anandb71 wants to merge 1 commit into
theupdateframework:developfrom
Anandb71:succinct-roles-strict-bin-names
Open

Anandb71 wants to merge 1 commit into
theupdateframework:developfrom
Anandb71:succinct-roles-strict-bin-names

Conversation

@Anandb71

Copy link
Copy Markdown

Description of the changes being introduced by the pull request:

SuccinctRoles.is_delegated_role() parses the bin name suffix with int(suffix, 16), but int() also accepts a leading sign, surrounding whitespace, underscores between digits and upper case digits. Because of that, names like bin-+f, bin- f, bin-0F or bin-1_0 were reported as delegated even though get_roles() and get_role_for_target() never produce them.

I added a check that the suffix is exactly the zero-padded lower case hex form used when bin names are generated, and extended test_is_delegated_role_in_succinct_roles with these cases (the new cases fail without the fix).

Testing:

  • python3 -m unittest -k test_is_delegated_role_in_succinct_roles test_api: fails before the change, passes after
  • coverage run -m unittest: 205 tests OK, coverage 97% (--fail-under 97 passes)
  • ruff check, ruff format --diff and mypy on tuf/examples/tests/verify_release/.github/scripts: clean

Fixes #3033

SuccinctRoles.is_delegated_role() parsed the bin name suffix with
int(suffix, 16). int() also accepts a leading sign, surrounding
whitespace, underscores between digits and upper case digits, so names
like "bin-+f", "bin- f", "bin-0F" or "bin-1_0" were reported as
delegated even though get_roles() and get_role_for_target() never
produce them.

Only accept a suffix that matches the zero-padded lower case hex form
used when the bin names are generated.

Signed-off-by: Anand Biju <anandbiju71@gmail.com>
@Anandb71
Anandb71 requested a review from a team as a code owner October 18, 2026 23:10

This branch has not been deployed

No deployments
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.

Metadata API: SuccinctRoles.is_delegated_role() accepts non-canonical bin names

1 participant