Repository navigation
Conversation
SimpleEnvelope.get_signed() documents that it raises DeserializationError if the payload cannot be deserialized, but only the JSON decoding and the role type lookup were inside the try block: the call to from_dict() was outside of it. A payload with a known role type but invalid content (for example missing fields) leaked KeyError, TypeError or ValueError instead. With EnvelopeType.SIMPLE this also reached ngclient: a malformed root passed to Updater() or TrustedMetadataSet() raised e.g. KeyError instead of a RepositoryError. Move the from_dict() call into the try block and add a test. Fixes theupdateframework#3048 Signed-off-by: Bahaa Mattar <bahaa.kmattar@gmail.com>
jku
enabled auto-merge
November 19, 2026 17:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the changes being introduced by the pull request:
SimpleEnvelope.get_signed()documents that it raisesDeserializationErrorif the payload cannot be deserialized. Only the JSON decoding and the role type lookup were inside thetryblock: theSigned.from_dict()call was outside of it. So a payload with a known role type but invalid content (a missing field, a wrong type, a bad date) leakedKeyError,TypeErrororValueError.This also reached ngclient: with
EnvelopeType.SIMPLE, a malformed root given toUpdater()orTrustedMetadataSet()(which loads the bootstrap root without a delegator, soget_signed()is the first thing that parses it) raised e.g.KeyErrorinstead of aRepositoryError.The change moves the
from_dict()call into thetryblock, so every failure becomes aDeserializationError(aRepositoryError), likeMetadata.from_bytes()/JSONDeserializeralready do.test_fail_invalid_payload_content_deserialization(new, inTestSimpleEnvelope) checks four invalid payloads (missing fields, wrong type,version: 0, bad date) and that the same envelope with valid content still deserializes. It fails on currentdevelop(4 errors: KeyError, TypeError, ValueError, ValueError) and passes with the change.Locally: the full unittest suite (207 tests) passes,
coverage report --fail-under 97passes,ruff check,ruff format --diffandmypyare clean on the changed files.Fixes #3048