Repository navigation
Mark reviewed DeviceCheck methods safe - #869
Open
LucaCappelletti94 wants to merge 1 commit into
Open
LucaCappelletti94 wants to merge 1 commit into
LucaCappelletti94 wants to merge 1 commit into
Conversation
madsmtm
reviewed
Oct 11, 2026
madsmtm
left a comment
Owner
There was a problem hiding this comment.
Thanks for working on this.
Same as with #864, could I get you to file a FB with Apple about this?
Surprisingly, we probably could work around this by adding this to lib.rs:
// #[ctor]
#[used]
#[link_section = "__DATA,__mod_init_func,mod_init_funcs"]
static INIT: extern "C" fn() = {
extern "C" fn init() {
let _ = DCAppAttestService::sharedService();
}
init
};Not sure how good of an idea this would be though, since the user could (very theoretically) still end up in a situation where they themselves spawn threads and use DCAppAttestService from a ctor that runs before this one, so I'd prefer to wait with doing that until we hear from Apple.
Comment on lines
+14
to
+16
| # The first call lazily creates the service's controller with an unsynchronized | ||
| # load and store, so it must not race another call on the same instance. | ||
| class.DCAppAttestService.methods.isSupported.unsafe = true |
Owner
There was a problem hiding this comment.
Am I misunderstanding? Isn't it DCAppAttestService.sharedService that should be unsafe, and the rest that are safe?
LucaCappelletti94
force-pushed
the
upstream/safe-device-check
branch
from
October 11, 2026 17:17
d4e0b78 to
d5a94df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enables the blanket safety defaults for
DeviceCheck, which makesDCDeviceandDCAppAttestService::sharedServicesafe. Their completion handlers already take aSendableBlock, and on macOS 26.6.2 the token handler does run on a framework thread, so nothing more is needed there.The four
DCAppAttestServiceinstance methods stayunsafe, and I checked them the way #864 checked LocalAuthentication. Each goes through-[DCAppAttestService appAttestController], which on macOS 26.6.2 creates its controller lazily with a plain load, store and release of the previous value, andsharedServicehands that one instance to every thread.Calling the getter from eight threads on fresh instances crashes in
objc_releaseinside it within a thousand rounds, while the same harness with the controller created beforehand runs 100,000 rounds cleanly. The precondition is therefore only that the first call must not race another call on the same instance, a bit of an unfortunate implementation choice.App Attest only works on iOS and iPadOS, since
isSupportedanswersNOon a Mac. The iOS 26.1 decompilation shows the same lazy_appAttestControllergetter, while the iOS 18.2 one has no such ivar. Other releases are unverified.Code that forbids
unsafestill cannot read the*mut NSDataand*mut NSErrorthese handlers receive until #837 lands.The regenerated bindings are in the generated fork.