fix(protocol): always expect & validate block hash in requests (#10738)
Verify that block requests have a hash and that it's correct. This helps prevent certain races and ensure that only expected data is ever returned in response to a request. (In Syncthing prior to 1.28.1 the block hash was omitted for encrypted requests from trusted devices. This breaks compatibility with that specific config on those versions.) --------- Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -560,6 +560,7 @@ func TestRequestMaxSize(t *testing.T) {
|
||||
Id: 1,
|
||||
Name: "valid",
|
||||
Size: MaxRequestSize,
|
||||
Hash: []byte{42},
|
||||
}
|
||||
|
||||
res := <-c.outbox
|
||||
@@ -573,6 +574,7 @@ func TestRequestMaxSize(t *testing.T) {
|
||||
Id: 2,
|
||||
Name: "invalid",
|
||||
Size: int32(s),
|
||||
Hash: []byte{42},
|
||||
}
|
||||
|
||||
select {
|
||||
@@ -606,6 +608,7 @@ func TestRequestZeroSize(t *testing.T) {
|
||||
Id: 1,
|
||||
Name: "valid",
|
||||
Size: 0,
|
||||
Hash: []byte{42},
|
||||
}
|
||||
|
||||
select {
|
||||
@@ -632,6 +635,7 @@ func TestRequestInvalidFilename(t *testing.T) {
|
||||
Id: 1,
|
||||
Name: "../escape",
|
||||
Size: 1024,
|
||||
Hash: []byte{42},
|
||||
}
|
||||
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user