Limit launch integrity checks to signed Dayu Color executables

这个提交包含在:
mac 于 2026-11-06 10:33:18 +08:00 提交
1 父节点 14afd3382c
当前提交 9f5f065977
3 个文件已更改
+19 -11

没有与搜索条件相匹配的文件

+14 -6
查看文件
@@ -39,22 +39,22 @@ static OSStatus DYValidateBundle(NSURL *url, NSString *identifier, SecCSFlags fl
SecStaticCodeRef code = NULL;
status = SecStaticCodeCreateWithPath((__bridge CFURLRef)url, kSecCSDefaultFlags, &code);
if (status == errSecSuccess) {
status = SecStaticCodeCheckValidity(code, flags | kSecCSStrictValidate | kSecCSCheckAllArchitectures,
requirement);
status = SecStaticCodeCheckValidity(code, flags, requirement);
CFRelease(code);
}
CFRelease(requirement);
return status;
}
OSStatus DYValidateSignedInstallation(NSURL *wrapperURL, NSString **failedComponent) {
static OSStatus DYValidateInstallation(NSURL *wrapperURL, SecCSFlags wrapperFlags, SecCSFlags serviceFlags,
NSString **failedComponent) {
if (failedComponent) *failedComponent = @"wrapper";
OSStatus status = DYValidateBundle(wrapperURL, DYWrapperIdentifier, kSecCSDefaultFlags);
OSStatus status = DYValidateBundle(wrapperURL, DYWrapperIdentifier, wrapperFlags);
if (status != errSecSuccess) return status;
if (failedComponent) *failedComponent = @"service";
NSURL *serviceURL = [wrapperURL URLByAppendingPathComponent:DYPluginRelativePath isDirectory:YES];
status = DYValidateBundle(serviceURL, DYServiceIdentifier, kSecCSCheckNestedCode);
status = DYValidateBundle(serviceURL, DYServiceIdentifier, serviceFlags);
if (status != errSecSuccess) return status;
// A separately signed older service with the same identity must not be mixed into this build.
@@ -68,6 +68,11 @@ OSStatus DYValidateSignedInstallation(NSURL *wrapperURL, NSString **failedCompon
return errSecSuccess;
}
OSStatus DYValidateSignedInstallation(NSURL *wrapperURL, NSString **failedComponent) {
const SecCSFlags strict = kSecCSStrictValidate | kSecCSCheckAllArchitectures;
return DYValidateInstallation(wrapperURL, strict, strict | kSecCSCheckNestedCode, failedComponent);
}
OSStatus DYValidateRunningInstallation(DYCodeRole role, NSString **failedComponent) {
BOOL isService = role == DYCodeRoleService;
if (failedComponent) *failedComponent = isService ? @"running-service" : @"running-wrapper";
@@ -84,5 +89,8 @@ OSStatus DYValidateRunningInstallation(DYCodeRole role, NSString **failedCompone
if (![wrapperURL.pathExtension isEqualToString:@"app"] ||
![bundleURL.path isEqualToString:expected.path]) return errSecCSBadBundleFormat;
}
return DYValidateSignedInstallation(wrapperURL, failedComponent);
// At launch, verify both native executables and their signed identities.
// Leave resource and nested-framework traversal to downloaded-package verification.
return DYValidateInstallation(wrapperURL, kSecCSDoNotValidateResources, kSecCSDoNotValidateResources,
failedComponent);
}