cultcache-ts inspector: recoverCatalogEntry reads through the same bounded door as previewPayload

Finding inspector-recover-unwalked: one decodeBoundedPayload (walk, then decode) serves both the stamp recovery and the preview, so a payload past the limit is never decoded by either.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-12 01:04:26 +02:00
commit ef682ad7b0

View file

@ -219,7 +219,7 @@ function decodeV1Record(value: unknown, catalogBySchemaId: Map<string, Inspected
function recoverCatalogEntry(schemaId: string, payload: Uint8Array): InspectedCatalogEntry | undefined {
let payloadPreview: unknown;
try {
payloadPreview = decode(payload);
payloadPreview = decodeBoundedPayload(payload);
} catch {
return undefined;
}
@ -287,6 +287,12 @@ function decodeLegacyEnvelope(value: unknown): InspectedRecord {
};
}
// The inspector's one payload read: the depth walk first, so a payload past the limit is refused before any decoder sees it.
function decodeBoundedPayload(payload: Uint8Array): unknown {
checkPayloadDepth(payload);
return decode(payload);
}
function previewPayload(payload: Uint8Array): Pick<InspectedRecord, "payloadPreview" | "payloadDecodeError"> {
try {
checkPayloadDepth(payload);