fix(native): require Apple origin for platform facets and keep cancellation
- Treat a CodeDirectory platform identifier as a platform binary only when the signature satisfies `anchor apple`, checked with `codesign --verify -R="anchor apple"`; otherwise the dependent facets are unknown. Developer ID code chains to Apple Root CA but fails this check. - Report every security facet as unknown when architecture slices differ in signing state. - Map an aborted signal that escapes a native helper, such as ticket hashing, to AnalysisCancelledError instead of an output error. - Treat a target as an app bundle only when it was opened from a bundle directory, so a regular file named X.app is verified as a bare Mach-O. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
73eb20a4b9
commit
ce8e969112
@@ -195,6 +195,10 @@ class NativeMacOSClient implements AnalysisClient {
|
||||
)
|
||||
: observation;
|
||||
} catch (cause: unknown) {
|
||||
if (cause instanceof AnalysisError) return err(cause);
|
||||
// A helper that observed the abort escapes as a DOMException.
|
||||
if (options?.signal?.aborted)
|
||||
return err(new AnalysisCancelledError(operation));
|
||||
return err(
|
||||
new AnalysisOutputError(operation, "Native output parsing failed", {
|
||||
cause,
|
||||
@@ -351,6 +355,23 @@ class NativeMacOSClient implements AnalysisClient {
|
||||
entitlements.value,
|
||||
verify.value,
|
||||
];
|
||||
// A platform identifier means a platform binary only in Apple's own
|
||||
// signatures, which satisfy `anchor apple`; Developer ID code does not.
|
||||
let appleOrigin = false;
|
||||
if (
|
||||
!unsigned &&
|
||||
(parsed.code_directory?.platform_identifier ?? null) !== null
|
||||
) {
|
||||
const anchor = await this.#run(
|
||||
"inspect_signature",
|
||||
"codesign",
|
||||
["--verify", "-R=anchor apple", verifyPath],
|
||||
{ signal, acceptNonZero: true },
|
||||
);
|
||||
if (!anchor.ok) return anchor;
|
||||
captures.push(anchor.value);
|
||||
appleOrigin = anchor.value.exitCode === 0;
|
||||
}
|
||||
const limitations = [
|
||||
...parsed.limitations,
|
||||
...SIGNATURE_POSTURE_LIMITATIONS,
|
||||
@@ -391,6 +412,8 @@ class NativeMacOSClient implements AnalysisClient {
|
||||
codeDirectory: parsed.code_directory,
|
||||
entitlements: entitlementValue.value,
|
||||
entitlementsKnown: unsigned || entitlements.value.exitCode === 0,
|
||||
mixedSlices: mixedSigning,
|
||||
appleOrigin,
|
||||
}),
|
||||
provenance,
|
||||
limitations,
|
||||
|
||||
@@ -13,10 +13,18 @@ const HASH_CHUNK_BYTES = 64 * 1024;
|
||||
export const signedCodePath = (target: {
|
||||
readonly path: string;
|
||||
readonly sourcePath?: string;
|
||||
}): string =>
|
||||
target.sourcePath?.toLowerCase().endsWith(".app") === true
|
||||
? target.sourcePath
|
||||
: target.path;
|
||||
readonly bundleInfoPlist?: string;
|
||||
}): string => appBundle(target) ?? target.path;
|
||||
|
||||
/**
|
||||
* The app bundle directory a target was opened from. Only a bundle opened as a
|
||||
* directory carries its Info.plist; a regular file named `X.app` is not one.
|
||||
*/
|
||||
const appBundle = (target: {
|
||||
readonly sourcePath?: string;
|
||||
readonly bundleInfoPlist?: string;
|
||||
}): string | undefined =>
|
||||
target.bundleInfoPlist === undefined ? undefined : target.sourcePath;
|
||||
|
||||
/**
|
||||
* Project a local `codesign --verify --strict` capture without reinterpreting
|
||||
@@ -59,11 +67,11 @@ export const signatureVerification = (
|
||||
* Apple's notarization record are not checked, because that needs the network.
|
||||
*/
|
||||
export const stapledTicket = async (
|
||||
target: { readonly sourcePath?: string },
|
||||
target: { readonly sourcePath?: string; readonly bundleInfoPlist?: string },
|
||||
signal?: AbortSignal,
|
||||
): Promise<InspectSignature["stapled_ticket"]> => {
|
||||
const bundle = target.sourcePath;
|
||||
if (bundle?.toLowerCase().endsWith(".app") !== true)
|
||||
const bundle = appBundle(target);
|
||||
if (bundle === undefined)
|
||||
return {
|
||||
status: "not-applicable",
|
||||
path: null,
|
||||
|
||||
Reference in New Issue
Block a user