Add UUID to manifest and verify integrity before decompression
- Add UUID field to both inner and outer manifest messages - Generate random v4 UUID when creating manifest - Hash compressed data (not uncompressed) for integrity check - Verify hash before decompression to prevent malicious payloads - Validate UUIDs are proper format and match between inner/outer - Sign string format: MAGIC-UUID-MULTIHASH
This commit is contained in:
+27
-6
@@ -218,8 +218,10 @@ type MFFileOuter struct {
|
||||
CompressionType MFFileOuter_CompressionType `protobuf:"varint,102,opt,name=compressionType,proto3,enum=MFFileOuter_CompressionType" json:"compressionType,omitempty"`
|
||||
// these are used solely to detect corruption/truncation
|
||||
// and not for cryptographic integrity.
|
||||
Size int64 `protobuf:"varint,103,opt,name=size,proto3" json:"size,omitempty"`
|
||||
Sha256 []byte `protobuf:"bytes,104,opt,name=sha256,proto3" json:"sha256,omitempty"`
|
||||
Size int64 `protobuf:"varint,103,opt,name=size,proto3" json:"size,omitempty"`
|
||||
Sha256 []byte `protobuf:"bytes,104,opt,name=sha256,proto3" json:"sha256,omitempty"`
|
||||
// uuid must match the uuid in the inner message
|
||||
Uuid []byte `protobuf:"bytes,105,opt,name=uuid,proto3" json:"uuid,omitempty"`
|
||||
InnerMessage []byte `protobuf:"bytes,199,opt,name=innerMessage,proto3" json:"innerMessage,omitempty"`
|
||||
// detached signature, ascii or binary
|
||||
Signature []byte `protobuf:"bytes,201,opt,name=signature,proto3,oneof" json:"signature,omitempty"`
|
||||
@@ -289,6 +291,13 @@ func (x *MFFileOuter) GetSha256() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MFFileOuter) GetUuid() []byte {
|
||||
if x != nil {
|
||||
return x.Uuid
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MFFileOuter) GetInnerMessage() []byte {
|
||||
if x != nil {
|
||||
return x.InnerMessage
|
||||
@@ -463,6 +472,9 @@ type MFFile struct {
|
||||
Version MFFile_Version `protobuf:"varint,100,opt,name=version,proto3,enum=MFFile_Version" json:"version,omitempty"`
|
||||
// required manifest attributes:
|
||||
Files []*MFFilePath `protobuf:"bytes,101,rep,name=files,proto3" json:"files,omitempty"`
|
||||
// uuid is a random v4 UUID generated when creating the manifest
|
||||
// used as part of the signature to prevent replay attacks
|
||||
Uuid []byte `protobuf:"bytes,102,opt,name=uuid,proto3" json:"uuid,omitempty"`
|
||||
// optional manifest attributes 2xx:
|
||||
CreatedAt *Timestamp `protobuf:"bytes,201,opt,name=createdAt,proto3,oneof" json:"createdAt,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -513,6 +525,13 @@ func (x *MFFile) GetFiles() []*MFFilePath {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MFFile) GetUuid() []byte {
|
||||
if x != nil {
|
||||
return x.Uuid
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MFFile) GetCreatedAt() *Timestamp {
|
||||
if x != nil {
|
||||
return x.CreatedAt
|
||||
@@ -527,12 +546,13 @@ const file_mf_proto_rawDesc = "" +
|
||||
"\bmf.proto\";\n" +
|
||||
"\tTimestamp\x12\x18\n" +
|
||||
"\aseconds\x18\x01 \x01(\x03R\aseconds\x12\x14\n" +
|
||||
"\x05nanos\x18\x02 \x01(\x05R\x05nanos\"\xdc\x03\n" +
|
||||
"\x05nanos\x18\x02 \x01(\x05R\x05nanos\"\xf0\x03\n" +
|
||||
"\vMFFileOuter\x12.\n" +
|
||||
"\aversion\x18e \x01(\x0e2\x14.MFFileOuter.VersionR\aversion\x12F\n" +
|
||||
"\x0fcompressionType\x18f \x01(\x0e2\x1c.MFFileOuter.CompressionTypeR\x0fcompressionType\x12\x12\n" +
|
||||
"\x04size\x18g \x01(\x03R\x04size\x12\x16\n" +
|
||||
"\x06sha256\x18h \x01(\fR\x06sha256\x12#\n" +
|
||||
"\x06sha256\x18h \x01(\fR\x06sha256\x12\x12\n" +
|
||||
"\x04uuid\x18i \x01(\fR\x04uuid\x12#\n" +
|
||||
"\finnerMessage\x18\xc7\x01 \x01(\fR\finnerMessage\x12\"\n" +
|
||||
"\tsignature\x18\xc9\x01 \x01(\fH\x00R\tsignature\x88\x01\x01\x12\x1c\n" +
|
||||
"\x06signer\x18\xca\x01 \x01(\fH\x01R\x06signer\x88\x01\x01\x12*\n" +
|
||||
@@ -564,10 +584,11 @@ const file_mf_proto_rawDesc = "" +
|
||||
"\x06_ctimeB\b\n" +
|
||||
"\x06_atime\".\n" +
|
||||
"\x0eMFFileChecksum\x12\x1c\n" +
|
||||
"\tmultiHash\x18\x01 \x01(\fR\tmultiHash\"\xc2\x01\n" +
|
||||
"\tmultiHash\x18\x01 \x01(\fR\tmultiHash\"\xd6\x01\n" +
|
||||
"\x06MFFile\x12)\n" +
|
||||
"\aversion\x18d \x01(\x0e2\x0f.MFFile.VersionR\aversion\x12!\n" +
|
||||
"\x05files\x18e \x03(\v2\v.MFFilePathR\x05files\x12.\n" +
|
||||
"\x05files\x18e \x03(\v2\v.MFFilePathR\x05files\x12\x12\n" +
|
||||
"\x04uuid\x18f \x01(\fR\x04uuid\x12.\n" +
|
||||
"\tcreatedAt\x18\xc9\x01 \x01(\v2\n" +
|
||||
".TimestampH\x00R\tcreatedAt\x88\x01\x01\",\n" +
|
||||
"\aVersion\x12\x10\n" +
|
||||
|
||||
Reference in New Issue
Block a user