Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(native): recover macOS command deadlines
Promote native_command_timeout_ms (default 60000), native_ui_deadline_ms
(default 180000), and pwntools_timeout_ms (default 30000) as validated
per-call settings. Keep cpuSeconds, byte allowances, LLDB grace, and plist
probes fixed, and say those caps have no runtime override.

Co-authored-by: morluto <morluto@users.noreply.github.com>
  • Loading branch information
cursoragent and morluto committed Oct 21, 2026
commit 4803c8107194aa0577257f2d6c595acce40408fb
3 changes: 2 additions & 1 deletion src/application/AppBundleOpenStepDepth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join } from "node:path";

import { describe, expect, it } from "vitest";

import { plistNestingLimitMessage } from "../domain/apple/plistValue.js";
import { resolveAppBundleExecutable } from "./AppBundleExecutable.js";
import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";

Expand Down Expand Up @@ -33,7 +34,7 @@ describe("OpenStep Info.plist nesting during app target resolution", () => {
error: {
path: join(app, "Contents", "Info.plist"),
cause: expect.objectContaining({
message: "Plist exceeds 128 nesting levels",
message: plistNestingLimitMessage(),
}),
},
});
Expand Down
7 changes: 6 additions & 1 deletion src/application/binaryDiagnostics/BinaryLayoutService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export class BinaryLayoutService {
this.provider.identity,
{
operation: OPERATION,
parameters: input.data,
parameters: {
path: input.data.path,
...(input.data.pwntools_timeout_ms === undefined
? {}
: { pwntools_timeout_ms: input.data.pwntools_timeout_ms }),
},
result: value,
// The decoded report is the only representation; do not repeat it.
rawResult: null,
Expand Down
8 changes: 7 additions & 1 deletion src/application/binaryDiagnostics/RecordedCrashService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ export class RecordedCrashService {
this.provider.identity,
{
operation: OPERATION,
parameters: input.data,
parameters: {
path: input.data.path,
include_debugger_context: input.data.include_debugger_context,
...(input.data.pwntools_timeout_ms === undefined
? {}
: { pwntools_timeout_ms: input.data.pwntools_timeout_ms }),
},
result: value,
// The decoded report is the only representation; do not repeat it.
rawResult: null,
Expand Down
8 changes: 7 additions & 1 deletion src/application/native/NativeMatchingAdmission.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setImmediate } from "node:timers/promises";
import { AnalysisResourceConstraintError } from "../../domain/analysisErrorCore.js";
import { fixedNativeAllowance } from "../../domain/native/nativeDeadlines.js";

const NATIVE_MATCHING_REPRESENTATION_BYTES = 96 * 1024 * 1024;

Expand All @@ -18,8 +19,13 @@ export class NativeMatchingAdmission {
throw new AnalysisResourceConstraintError(
this.operation,
"capacity",
"Native function matching exceeds representation capacity",
`Native function matching exceeds its ${String(NATIVE_MATCHING_REPRESENTATION_BYTES)}-byte (96 MiB) representation allowance. This release has no runtime override.`,
{ maximum_bytes: NATIVE_MATCHING_REPRESENTATION_BYTES },
fixedNativeAllowance(
"The native function-matching representation allowance",
"bytes",
`${String(NATIVE_MATCHING_REPRESENTATION_BYTES)} bytes`,
),
);
this.signal?.throwIfAborted();
if (++this.#work % 256 === 0)
Expand Down
4 changes: 2 additions & 2 deletions src/application/native/NativeValueTrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,15 @@ export const traceNativeValues = async (
limitations: [
"Static decompiler def-use graphs cover recovered block members; when membership is unavailable they exclude operations marked dead. Logical CALL argument positions bind to recovered HighParam ordinals and RETURN values bind to recovered CALL outputs; these are decompiler-derived dependencies, not original source or runtime observations. Missing parameters, variadic arguments and alias dependencies remain unknown.",
"LOAD and STORE are memory operations; object fields, persistent state and RNG semantics are not inferred from names or pseudocode.",
"Traversal caps depth, decompilations, call-site resolutions, nodes, edges and node payloads (8 MiB). Complete serialized output is bounded to 32 MiB. Pagination reruns analysis and returns edges whose source is on the node page; endpoints outside the page retain stable identities.",
"Traversal caps depth, decompilations, call-site resolutions, nodes, edges and node payloads (8388608 bytes, 8 MiB). This release has no runtime override for the 8388608-byte node-payload allowance. Complete serialized output is bounded to 33554432 bytes (32 MiB) and that output allowance has no runtime override. Pagination reruns analysis and returns edges whose source is on the node page; endpoints outside the page retain stable identities.",
...renderSourceLimitations(sourceLimitations),
],
});
if (Buffer.byteLength(JSON.stringify(result)) > 32 * 1024 * 1024)
return err(
new AnalysisOutputError(
"trace_native_values",
"Graph output exceeds 32 MiB; lower max_nodes, max_edges or page limit",
"Graph output exceeds 33554432 bytes (32 MiB). This release has no runtime override. Lower max_nodes, max_edges, or the page limit.",
),
);
return ok(result);
Expand Down
9 changes: 6 additions & 3 deletions src/artifacts/apple/KeyedArchiveReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
decodeKeyedArchiveBytes,
inspectBundleKeyedArchive,
} from "./KeyedArchiveReader.js";
import { unknownDateLimitation } from "../../domain/apple/plistValue.js";
import {
plistNestingLimitMessage,
unknownDateLimitation,
} from "../../domain/apple/plistValue.js";
import { deeplyNestedXmlPlist } from "../../../tests/fixtures/keyedArchiveXmlNesting.js";
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
import { scanBinaryPlistScalars } from "./PlistScalars.js";
Expand Down Expand Up @@ -791,7 +794,7 @@ describe("XML plist nesting preflight", () => {
Buffer.from(deeplyNestedXmlPlist(depth)),
selection,
),
).toThrow(new RangeError("Plist exceeds 128 nesting levels"));
).toThrow(new RangeError(plistNestingLimitMessage()));
},
);

Expand All @@ -808,6 +811,6 @@ describe("XML plist nesting preflight", () => {
it("rejects one nesting level past the limit before decoding", () => {
expect(() =>
decodeKeyedArchiveBytes(deeplyNestedArchive(127), selection),
).toThrow(new RangeError("Plist exceeds 128 nesting levels"));
).toThrow(new RangeError(plistNestingLimitMessage()));
});
});
20 changes: 18 additions & 2 deletions src/cli/binaryDiagnosticsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { withCommandCancellation } from "./commandCancellation.js";
import { inspectBinaryLayoutInputSchema } from "../domain/native/binaryLayout.js";
import { inspectRecordedCrashInputSchema } from "../domain/native/recordedCrash.js";
import { inspectPeResourcesInputSchema } from "../domain/native/peResources.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
Expand Down Expand Up @@ -60,11 +62,20 @@ export const registerBinaryDiagnosticsCommands = (
args: z.object({
path: z.string().describe("Local ELF binary or relocatable object"),
}),
run: ({ args }) =>
options: z.object({
pwntoolsTimeoutMs:
inspectBinaryLayoutInputSchema.shape.pwntools_timeout_ms,
}),
run: ({ args, options }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, CLI_COMMANDS.inspectBinaryLayout, async () => {
const result = await service.inspectAndClose(
{ path: absoluteCallerPath(args.path) },
{
path: absoluteCallerPath(args.path),
...(options.pwntoolsTimeoutMs === undefined
? {}
: { pwntools_timeout_ms: options.pwntoolsTimeoutMs }),
},
{ signal },
);
return result.ok ? result.value : projectAnalysisError(result.error);
Expand All @@ -85,6 +96,8 @@ export const registerBinaryDiagnosticsCommands = (
.boolean()
.default(false)
.describe("Add BYO core-only GDB/pwndbg mapping candidates"),
pwntoolsTimeoutMs:
inspectRecordedCrashInputSchema.shape.pwntools_timeout_ms,
}),
run: ({ args, options }) =>
withCommandCancellation((signal) =>
Expand All @@ -93,6 +106,9 @@ export const registerBinaryDiagnosticsCommands = (
{
path: absoluteCallerPath(args.path),
include_debugger_context: options.debuggerContext,
...(options.pwntoolsTimeoutMs === undefined
? {}
: { pwntools_timeout_ms: options.pwntoolsTimeoutMs }),
},
{ signal },
);
Expand Down
57 changes: 49 additions & 8 deletions src/cli/utilityCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { AnalysisInputError } from "../domain/analysisErrorCore.js";
import { projectInputIssues } from "../domain/inputIssueProjection.js";
import { safeParseJson } from "../domain/safeJson.js";
import { nativeUiScenarioInputSchema } from "../domain/native/nativeUiObservation.js";
import {
nativeCommandTimeoutField,
nativeUiDeadlineField,
} from "../domain/native/nativeDeadlines.js";
import { PRODUCT_IDENTITY } from "../identity.js";
import { logCliCommand } from "../cliLogging.js";
import { CLI_COMMANDS } from "../cliCommandNames.js";
Expand Down Expand Up @@ -59,6 +63,7 @@ const nativeUiScopeOptions = {
.safe()
.default(500)
.describe("Maximum accessibility nodes per capture"),
nativeUiDeadlineMs: nativeUiDeadlineField,
};

const nativeUiScope = (options: {
Expand All @@ -67,12 +72,16 @@ const nativeUiScope = (options: {
readonly screenshot: boolean;
readonly accessibility: boolean;
readonly maxNodes: number;
readonly nativeUiDeadlineMs?: number | undefined;
}) => ({
pid: options.pid,
window_id: options.windowId,
screenshot: options.screenshot,
accessibility: options.accessibility,
max_nodes: options.maxNodes,
...(options.nativeUiDeadlineMs === undefined
? {}
: { native_ui_deadline_ms: options.nativeUiDeadlineMs }),
});

/**
Expand Down Expand Up @@ -138,7 +147,15 @@ const registerNativeUiCommands = (
...(options.steps === undefined ? {} : { steps: decoded.value }),
}),
);
return runProviderAnalysis(args.path, operation, parsed.data, logger);
const { native_ui_deadline_ms: deadline, ...scenario } = parsed.data;
return runProviderAnalysis(
args.path,
operation,
deadline === undefined
? scenario
: { ...scenario, native_ui_deadline_ms: deadline },
logger,
);
}),
});
};
Expand Down Expand Up @@ -183,9 +200,19 @@ const registerNativeCommands = (
cli.command(command, {
description: `Run ${tool} without launching Hopper`,
args: z.object({ path: z.string().describe("Mach-O or app path") }),
run: ({ args }) =>
options: z.object({
nativeCommandTimeoutMs: nativeCommandTimeoutField,
}),
run: ({ args, options }) =>
logCliCommand(logger, command, () =>
runProviderAnalysis(args.path, tool, {}, logger),
runProviderAnalysis(
args.path,
tool,
options.nativeCommandTimeoutMs === undefined
? {}
: { native_command_timeout_ms: options.nativeCommandTimeoutMs },
logger,
),
),
});
}
Expand All @@ -199,15 +226,21 @@ const registerNativeCommands = (
.describe(
"Plist path relative to the app root, or an absolute path (default: the bundle's Info.plist)",
),
nativeCommandTimeoutMs: nativeCommandTimeoutField,
}),
run: ({ args, options }) =>
logCliCommand(logger, "inspect-plist", () =>
runProviderAnalysis(
args.path,
"inspect_plist",
options.relativePath === undefined
? {}
: { path: options.relativePath },
{
...(options.relativePath === undefined
? {}
: { path: options.relativePath }),
...(options.nativeCommandTimeoutMs === undefined
? {}
: { native_command_timeout_ms: options.nativeCommandTimeoutMs }),
},
logger,
),
),
Expand All @@ -218,12 +251,20 @@ const registerNativeCommands = (
path: z.string().describe("Artifact path used for evidence identity"),
symbols: swiftSymbolsSchema.describe("Swift mangled symbols to demangle"),
}),
run: ({ args }) =>
options: z.object({
nativeCommandTimeoutMs: nativeCommandTimeoutField,
}),
run: ({ args, options }) =>
logCliCommand(logger, "demangle-swift", () =>
runProviderAnalysis(
args.path,
"demangle_swift",
{ symbols: args.symbols },
{
symbols: args.symbols,
...(options.nativeCommandTimeoutMs === undefined
? {}
: { native_command_timeout_ms: options.nativeCommandTimeoutMs }),
},
logger,
),
),
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/native/binaryDiagnosticsToolContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const BINARY_DIAGNOSTICS_TOOL_CONTRACTS = [
...toolContractMetadata("inspect_binary_layout"),
kind: "native-provider",
description:
"Inspect an explicit local binary without launching it as a host process. Returns file-backed section/segment ranges, linked addresses, original symbol/REL/RELA table identities, complete encoded RELR tables and upstream-derived offsets with unknown per-word locations/addends, raw name bytes, dependency/interpreter names and static mitigation inferences inline with artifact SHA-256 Evidence. Initial profile: ELF64 x86-64 little-endian EXEC/DYN/REL on Linux x64 via caller-supplied Python with unchanged pwntools 4.15.0, pyelftools 0.33 and Unicorn 2.1.2. Runtime addresses/library paths, overall relocation inventory completeness and complete derived GOT/PLT coverage remain unknown. Zero executable entry values mean absence; relocatable entries are not applicable. Upstream can emulate PLT instructions with Unicorn for derived static maps. Uses bounded complete output and owned temporary files/processes; malformed, unsupported or oversized objects return no partial success. Select detail summary to retain the complete layout Evidence in this session and receive only its summary view, then inspect sections, symbols, mitigations or linkage with inspect_analysis_view.",
"Inspect an explicit local binary without launching it as a host process. Returns file-backed section/segment ranges, linked addresses, original symbol/REL/RELA table identities, complete encoded RELR tables and upstream-derived offsets with unknown per-word locations/addends, raw name bytes, dependency/interpreter names and static mitigation inferences inline with artifact SHA-256 Evidence. Initial profile: ELF64 x86-64 little-endian EXEC/DYN/REL on Linux x64 via caller-supplied Python with unchanged pwntools 4.15.0, pyelftools 0.33 and Unicorn 2.1.2. Runtime addresses/library paths, overall relocation inventory completeness and complete derived GOT/PLT coverage remain unknown. Zero executable entry values mean absence; relocatable entries are not applicable. Upstream can emulate PLT instructions with Unicorn for derived static maps. Uses bounded complete output and owned temporary files/processes; malformed, unsupported or oversized objects return no partial success. Select detail summary to retain the complete layout Evidence in this session and receive only its summary view, then inspect sections, symbols, mitigations or linkage with inspect_analysis_view. pwntools_timeout_ms is each owned pwntools command's deadline (omitted means 30000 ms, range 1..2147483647, next call). cpuSeconds 30 and the output, diagnostic, and address-space byte allowances have no runtime override.",
inputSchema: inspectBinaryLayoutRequestSchema,
outputSchema: analysisDetailOutputSchemaOf(
binaryLayoutSchema,
Expand All @@ -67,7 +67,7 @@ export const BINARY_DIAGNOSTICS_TOOL_CONTRACTS = [
...toolContractMetadata("inspect_recorded_crash"),
kind: "native-provider",
description:
"Inspect a supplied Linux ELF64 amd64 or AArch64 little-endian core without launching its target or attaching to any live PID. Returns all recorded segments, raw note owners/descriptors and source ranges, every Linux CORE PRSTATUS thread/register and SIGINFO fields inline with SHA-256 Evidence. Historical PID is recorded metadata; current process/file identity, note coverage and signal-thread associations stay unknown. Optionally add derived core-only GDB/pwndbg mapping candidates through explicit BYO configuration; zero map flags mean unknown permissions. Uses the same stable snapshot for both stages, bounded complete output and owned cleanup. Linux x64 host profile: unchanged pwntools 4.15.0/pyelftools 0.33/Unicorn 2.1.2; optional unchanged pwndbg 2026.09.15. No implicit executable/library pairing, GDB command language, host configuration changes or dependency installation.",
"Inspect a supplied Linux ELF64 amd64 or AArch64 little-endian core without launching its target or attaching to any live PID. Returns all recorded segments, raw note owners/descriptors and source ranges, every Linux CORE PRSTATUS thread/register and SIGINFO fields inline with SHA-256 Evidence. Historical PID is recorded metadata; current process/file identity, note coverage and signal-thread associations stay unknown. Optionally add derived core-only GDB/pwndbg mapping candidates through explicit BYO configuration; zero map flags mean unknown permissions. Uses the same stable snapshot for both stages, bounded complete output and owned cleanup. Linux x64 host profile: unchanged pwntools 4.15.0/pyelftools 0.33/Unicorn 2.1.2; optional unchanged pwndbg 2026.09.15. No implicit executable/library pairing, GDB command language, host configuration changes or dependency installation. pwntools_timeout_ms is each owned pwntools command's deadline (omitted means 30000 ms, range 1..2147483647, next call). cpuSeconds 30 and the output, diagnostic, and address-space byte allowances have no runtime override.",
inputSchema: inspectRecordedCrashInputSchema,
outputSchema: evidenceResultOf(recordedCrashSchema),
examples: [
Expand Down
Loading
Loading