Skip to content

Commit e875e32

Browse files
committed
crypto: skip owner/signature mismatch check for objects below v2.18
Closes #3806. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
1 parent 71a8258 commit e875e32

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Changelog for NeoFS Node
88
### Fixed
99
- Resending the header after chunks have already been sent in object service `Get` handler (#3833)
1010
- GC deadlock on local object storage shutdown (#3837)
11+
- `owner mismatches signature` for stored objects (#3836)
1112

1213
### Changed
1314

internal/crypto/object.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88

9+
"github.com/nspcc-dev/neofs-node/pkg/core/version"
910
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
1011
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
1112
"github.com/nspcc-dev/neofs-sdk-go/object"
@@ -78,7 +79,9 @@ func AuthenticateObject(obj object.Object, fsChain HistoricN3ScriptRunner, ecPar
7879
if !verifyECDSAFns[scheme](*ecdsaPub, sig.Value(), obj.GetID().Marshal()) {
7980
return schemeError(scheme, errSignatureMismatch)
8081
}
81-
if sessionToken == nil && sessionTokenV2 == nil && !ecPart && user.NewFromECDSAPublicKey(*ecdsaPub) != obj.Owner() {
82+
if sessionToken == nil && sessionTokenV2 == nil && !ecPart &&
83+
user.NewFromECDSAPublicKey(*ecdsaPub) != obj.Owner() &&
84+
version.OwnerSignatureMatchRequired(obj.Version()) {
8285
return errors.New("owner mismatches signature")
8386
}
8487
case neofscrypto.N3:

pkg/core/version/version.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ func SysObjTargetShouldBeInHeader(v *version.Version) bool {
2222
(v.Major() == latestSysObjTargetInPayloadMjr && v.Minor() > latestSysObjTargetInPayloadMnr)
2323
}
2424

25+
// OwnerSignatureMatchRequired returns true if an object with the given version
26+
// must have the owner matching the signature's public key. Objects below version
27+
// 2.18 may have a mismatching owner due to a bug that allowed creating such
28+
// objects, so they should not be rejected.
29+
func OwnerSignatureMatchRequired(v *version.Version) bool {
30+
if v == nil || !IsValid(*v) {
31+
return true // assume latest
32+
}
33+
34+
const (
35+
ownerMatchMjr = 2
36+
ownerMatchMnr = 18
37+
)
38+
39+
return v.Major() > ownerMatchMjr ||
40+
(v.Major() == ownerMatchMjr && v.Minor() >= ownerMatchMnr)
41+
}
42+
2543
// IsValid checks if Version is not earlier than the genesis version of the NeoFS.
2644
func IsValid(v version.Version) bool {
2745
const (

0 commit comments

Comments
 (0)