feat(native): report code-signing posture in inspect_signature

inspect_signature reduced the CodeDirectory to a hardened-runtime boolean
and never verified the signature. It now also reports:

- the parsed CodeDirectory: version, flags decoded from their numeric
  value (runtime, library-validation, restrict, kill, adhoc,
  linker-signed, unknown bits in hex), code and special slot counts,
  location, hash type, platform identifier, runtime version, and
  executable-segment flags;
- sealed resources (version, rules, files, or none);
- a local `codesign --verify --strict` result on the opened bundle or
  Mach-O, with diagnostics and the sorted nested code it validated;
- whether a notarization ticket is stapled at Contents/CodeResources,
  with its digest. The ticket and Apple's records are not checked
  because that needs the network;
- derived security facets with their supporting evidence: library
  validation, DYLD_* handling, debugger attach, executable-memory
  policy, and App Sandbox. Facets stay unknown when flags or aggregate
  entitlements are unavailable.

verify:code-signature re-signs copies of the clang-built fixture with
real codesign (ad hoc, hardened runtime, hardened runtime with relaxing
entitlements, library,restrict). It also checks a platform binary and a
tampered bundle, with CLI/MCP parity, and runs in the macOS CI job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 11:16:55 +00:00
co-authored by Claude Opus 5.5
parent dcde958450
commit 25ca63f231
19 changed files with 1247 additions and 10 deletions
+34 -1
View File
@@ -53,6 +53,13 @@ import {
type NativeCommandRunner,
} from "./CommandRunner.js";
import { parseCodeSignature } from "./parsers/codesign.js";
import {
SIGNATURE_POSTURE_LIMITATIONS,
signatureVerification,
signedCodePath,
stapledTicket,
} from "./NativeSignaturePosture.js";
import { deriveSecurityFacets } from "../domain/codeSigningPosture.js";
import { parseDemangledSymbols } from "./parsers/demangle.js";
import { parseLipoArchitectures } from "./parsers/lipo.js";
import {
@@ -335,9 +342,23 @@ class NativeMacOSClient implements AnalysisClient {
/designated\s*=>\s*(.+)$/mu.exec(requirements.value.stdout)?.[1] ?? null;
// Entitlements XML is printed to stdout; stderr echoes the path.
const entitlementValue = parseEntitlements(entitlements.value.stdout);
const captures = [display.value, requirements.value, entitlements.value];
const verifyPath = signedCodePath(this.target);
const verify = await this.#run(
"inspect_signature",
"codesign",
["--verify", "--strict", "--verbose=2", verifyPath],
{ signal, acceptNonZero: true },
);
if (!verify.ok) return verify;
const captures = [
display.value,
requirements.value,
entitlements.value,
verify.value,
];
const limitations = [
...parsed.limitations,
...SIGNATURE_POSTURE_LIMITATIONS,
...(entitlementValue.omittedPrototypeKeys === 0
? []
: [
@@ -366,6 +387,18 @@ class NativeMacOSClient implements AnalysisClient {
...parsed,
designated_requirement: requirementText,
entitlements: entitlementValue.value,
verification: signatureVerification(
verify.value,
verifyPath,
isNonzeroUnsignedObservation(verify.value),
),
stapled_ticket: await stapledTicket(this.target, signal),
security_facets: deriveSecurityFacets({
signed: !unsigned,
codeDirectory: parsed.code_directory,
entitlements: entitlementValue.value,
entitlementsKnown: unsigned || entitlements.value.exitCode === 0,
}),
provenance,
limitations,
});