From 28ff1eed4862b8e0a135971a9086f9ef1efdd200 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 1 Mar 2024 02:46:10 -0500 Subject: [PATCH] fix: when we have a proof, the body also has a metadata type byte that needs to be validated --- metadata/media_metadata.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/metadata/media_metadata.go b/metadata/media_metadata.go index 4a0a969..d0940ac 100644 --- a/metadata/media_metadata.go +++ b/metadata/media_metadata.go @@ -152,7 +152,18 @@ func (m *MediaMetadata) decodeProof(dec *msgpack.Decoder) error { m.provenPubKeys = provenPubKeys - return m.decodeMedia(msgpack.NewDecoder(bytes.NewReader(bodyBytes))) + mediaDec := msgpack.NewDecoder(bytes.NewReader(bodyBytes)) + + mediaByte, err := mediaDec.DecodeUint8() + if err != nil { + return err + } + + if types.MetadataType(mediaByte) != types.MetadataTypeMedia { + return errors.New("Invalid metadata type") + } + + return m.decodeMedia(mediaDec) } func (m *MediaMetadata) decodeMedia(dec *msgpack.Decoder) error {