feat(native)!: give the native structural decoding allowance a per-call max_structure_bytes (#14626)

* feat(native)!: give the native structural decoding allowance a per-call max_structure_bytes

The 16 MiB structural budget on native header, section, load-command and
ELF dynamic-directory table reads, and on decoded section names, was a
fixed ceiling with no override. inspect_elf_unwind_ranges,
inspect_kernel_module, inspect_elf_debug_link, inspect_dwarf_units,
inspect_binary_hardening and inspect_native_initializers now accept
max_structure_bytes (64 bytes to 512 MiB, default 16 MiB) and report
details.limit when it stops them.

binaryContainer owns the default, the limit name and the failure
(nativeStructureFailure); the directory readers take a
NativeDirectoryBudgets object in place of the positional decoded-name
budget, and Mach-O, the ELF dynamic directory and the ELF pointer
relocation pass take the same budget. Other allowances that shared the
"structure" limit name now carry their own: the PE per-name decode, the
retained DWARF section bound (derived from the admitted image), and the
hardening table-entry count. The ELF dependency provider's structural
projection was unreachable and is removed.

Part of #14235.

BREAKING CHANGE: refusals at the structural budget report
reported_limits.boundary "max_structure_bytes" instead of "structure".

* fix(native): apply max_structure_bytes to the ELF hardening dynamic table and scope its help

inspect_binary_hardening read PT_DYNAMIC under its entry count only, so a sectionless ELF could exceed the selected max_structure_bytes; the dynamic table is now checked first. The shared help no longer names tables a reader does not bound, and the limits reference states hardening's Mach-O and PE coverage. The initializer CLI recovery test asserts a parsed successful report.

* fix(native): refuse a partial ELF hardening dynamic table as malformed before its budget
This commit is contained in:
morluto authored and GitHub committed 2026-11-25 22:04:06 -05:00
1 parent 4f66985978
commit e540cbdafd
43 files changed
+603 -252

No files matched your search

+4 -16
View File
@@ -12,7 +12,6 @@ import type { ExecutionOptions } from "../../ports/AnalysisProvider.js";
import { AnalysisResourceConstraintError } from "../../domain/analysisErrorCore.js";
import { classifyProviderFailure } from "../../providers/classifyProviderFailure.js";
import { offlineArtifactFailureDialect } from "../../providers/offlineArtifactFailure.js";
import { fixedAllowanceOptions } from "../../domain/fixedAllowanceRemediation.js";
import {
MAX_INSPECT_KERNEL_MODULE_ENTRIES,
MAX_INSPECT_KERNEL_MODULE_FILE_BYTES,
@@ -21,10 +20,8 @@ import {
} from "../../domain/native/kernelModule.js";
import { err, ok } from "../../domain/result.js";
import { KERNEL_MODULE_PROVIDER } from "../../domain/investigationProviders.js";
import {
BinaryResourceFailure,
binaryResourceCeiling,
} from "../../domain/binaryContainer.js";
import { isNativeStructureFailure } from "../../domain/binaryContainer.js";
import { nativeStructureConstraint } from "../nativeStructureConstraint.js";
import { parseKernelModuleFromHandle } from "./KernelModuleParser.js";
const OPERATION = "inspect_kernel_module";
@@ -112,17 +109,8 @@ const kernelModuleFailure = (
description: "kernel module",
fallbackMessage: "Kernel module inspection failed.",
recognise: (failure, origin) => {
if (failure instanceof BinaryResourceFailure)
return parseLimitConstraint(
OPERATION,
"memory",
failure,
fixedAllowanceOptions(
"The ELF structural decoding allowance",
"parser",
binaryResourceCeiling(failure),
),
);
if (isNativeStructureFailure(failure))
return nativeStructureConstraint(OPERATION, failure);
if (
origin === "owned-or-classified" &&
failure instanceof ArtifactReaderFailure &&