Summary
serializeAnchor in ios/Serializers.swift encodes HKQueryAnchor using the deprecated NSKeyedArchiver.archivedData(withRootObject:) API (no requiringSecureCoding
// Current (buggy)
let data = NSKeyedArchiver.archivedData(withRootObject: anchor)
The modern replacement NSKeyedUnarchiver.unarchivedObject(ofClass:from:) internally
sets requiresSecureCoding = true. When it encounters an archive written without that flag
it silently returns nil (via try?), not an error.
Any native code that reads back an anchor written by this library using the modern unarchiver
will silently get nil, treating every query as if no anchor exists. The result is a full
re-sync from the beginning instead of an incremental delta
Affected versions
Confirmed in v12.1.2 and v14.0.0. Helpers.swift in v14 still has the same pattern:
func toBase64(_ data: Any?) -> String? {
if let data = data {
let data = NSKeyedArchiver.archivedData(withRootObject: data)
let encoded = data.base64EncodedString()
return encoded
}
return nil
}
PR: #349
Summary
serializeAnchorinios/Serializers.swiftencodesHKQueryAnchorusing the deprecatedNSKeyedArchiver.archivedData(withRootObject:)API (norequiringSecureCodingThe modern replacement
NSKeyedUnarchiver.unarchivedObject(ofClass:from:)internallysets requiresSecureCoding = true. When it encounters an archive written without that flag
it silently returns nil (via try?), not an error.
Any native code that reads back an anchor written by this library using the modern unarchiver
will silently get nil, treating every query as if no anchor exists. The result is a full
re-sync from the beginning instead of an incremental delta
Affected versions
Confirmed in v12.1.2 and v14.0.0. Helpers.swift in v14 still has the same pattern:
Apple deprecation notice for archivedData(withRootObject:):
https://developer.apple.com/documentation/foundation/nskeyedarchiver/archiveddata(withrootobject:)
HKQueryAnchor conforms to NSSecureCoding:
https://developer.apple.com/documentation/foundation/nssecurecoding
https://developer.apple.com/documentation/healthkit/hkqueryanchor
PR: #349