Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(apktool): disclose platform and release advisory windows
morlutod38f09969239
diff --git a/docs/apktool-resource-analysis.md b/docs/apktool-resource-analysis.mdindex 5b8967c4a..8c98f762f 100644--- a/docs/apktool-resource-analysis.md+++ b/docs/apktool-resource-analysis.md@@ -24,14 +24,29 @@ missing launcher reports `capability_unavailable` with the`binary_session` uses the same host probe for tool availability; it does notvalidate a particular APK or guarantee that the selected input can be decoded.-Client inspection and decode results disclose CVE-2024-21633 when the-reported version predates its upstream 2.9.2 fix. This advisory-specific-limitation preserves older supported distribution builds. A launcher version-does not prove the decoder's contents, downstream backports, or overall safety;-verify the selected decoder's patches before decoding untrusted APKs. See the-[upstream advisories](https://github.com/iBotPeaches/Apktool/security/advisories),-including the Windows follow-up and later regression; the compatibility floor-above is not a security recommendation.+Client inspection and decode results disclose the following reported-version+advisory windows without refusing otherwise compatible launchers:++| Advisory | Reported version window | Host scope |+| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ---------- |+| [CVE-2024-21633](https://github.com/iBotPeaches/Apktool/security/advisories/GHSA-2hqv-2xv4-5h5w) | Before 2.9.2 | All |+| [GHSA-vgwr-4w3p-xmjv](https://github.com/iBotPeaches/Apktool/security/advisories/GHSA-vgwr-4w3p-xmjv) | Before 2.9.3 | Windows |+| [CVE-2026-39973](https://github.com/iBotPeaches/Apktool/security/advisories/GHSA-m8mh-x359-vm8m) | 3.0.0 release line through versions before 3.0.2 | All |++The 2026 advisory names 3.0.1 and its 3.0.2 fix. Inclusion of 3.0.0 is+source-derived: [tagged 3.0.0](https://github.com/iBotPeaches/Apktool/blob/f770b39e425af4fa6ac4ca1e9ea6c4824339c6d3/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResTypeSpec.java)+passes type names through unchanged; the [3.0.2 patch](https://github.com/iBotPeaches/Apktool/commit/65dd8480dfcb63068562ffaa527f71bb0a9f772c)+validates those names at their owner before they reach the output-path producer.+Prereleases before the fixed release are conservatively disclosed; the exact+`-dirty` downstream marker is compared as a release while preserving its spelling.+This is version guidance, not verification of a particular prerelease or decoder.++A launcher version does not prove the decoder's contents, execution platform,+downstream backports, or overall safety. Windows applicability uses the selected+local host; an opaque wrapper may run another engine. A missing warning means+only that none of these version/host windows matched. Verify the selected+decoder's patches before decoding untrusted APKs; the compatibility floor above+is not a security recommendation. REA does not fetch advisories at runtime.On Windows, a `.bat` or `.cmd` launcher (such as Chocolatey's `apktool.bat`)runs through an explicit `cmd.exe /d /s /c` call. That call has no AutoRun,diff --git a/src/apktool/ApktoolConfiguration.test.ts b/src/apktool/ApktoolConfiguration.test.tsindex 07b70b7f4..ea75c5a5f 100644--- a/src/apktool/ApktoolConfiguration.test.ts+++ b/src/apktool/ApktoolConfiguration.test.ts@@ -149,6 +149,65 @@ describe("reported Apktool version policy", () => {);});+describe("reported advisory applicability (#4818)", () => {+ it.each([+ ["2.7.0-dirty", true],+ ["2.9.2", true],+ ["2.9.2+patched", true],+ ["2.9.3-rc.1", true],+ ["2.9.3", false],+ ["2.9.3-dirty", false],+ ["3.0.1", false],+ ] as const)(+ "binds the Windows advisory for %s to the selected host",+ (version, affected) => {+ for (const platform of ["win32", "linux", "darwin"] as const) {+ const identity = parseApktoolVersionOutput(version, platform);+ if (identity.version === null) throw new Error("Expected version");+ expect(identity.version).toBe(version);+ const warnings = identity.limitations.filter((warning) =>+ warning.includes("GHSA-vgwr-4w3p-xmjv"),+ );+ expect(warnings.length).toBe(affected && platform === "win32" ? 1 : 0);+ }+ },+ );+ it.each([+ ["3.0.0-beta.1", true],+ ["3.0.0", true],+ ["v3.0.0-dirty", true],+ ["3.0.1", true],+ ["3.0.1+patched", true],+ ["3.0.2-rc.1", true],+ ["3.0.2", false],+ ["3.0.2-dirty", false],+ ["3.0.3", false],+ ["3.1.0-beta.1", false],+ ["2.12.1", false],+ ["4.0.0", false],+ ] as const)(+ "bounds the 3.x regression advisory for %s",+ (version, affected) => {+ for (const platform of ["win32", "linux", "darwin"] as const) {+ const identity = parseApktoolVersionOutput(version, platform);+ if (identity.version === null) throw new Error("Expected version");+ const warnings = identity.limitations.filter((warning) =>+ warning.includes("CVE-2026-39973"),+ );+ expect(warnings.length).toBe(affected ? 1 : 0);+ if (affected) {+ expect(warnings[0]).toContain(+ "does not establish engine contents or downstream backports",+ );+ expect(warnings[0]?.includes("source-derived")).toBe(+ version.includes("3.0.0"),+ );+ }+ }+ },+ );+});+describe("apktoolInvocation", () => {const windows = { SystemRoot: "C:\\Windows" };diff --git a/src/apktool/ApktoolConfiguration.ts b/src/apktool/ApktoolConfiguration.tsindex ff5841eac..97010f9b0 100644--- a/src/apktool/ApktoolConfiguration.ts+++ b/src/apktool/ApktoolConfiguration.ts@@ -219,6 +219,7 @@ export const apktoolInvocation = (/** Read the version from Apktool's single-line `--version` response. */export const parseApktoolVersionOutput = (stdout: string,+ platform: NodeJS.Platform = process.platform,):| ApktoolClientIdentity| { readonly version: null; readonly reportedVersion: string | null } => {@@ -239,14 +240,38 @@ export const parseApktoolVersionOutput = ((downstreamRelease? parsed.compareMain(release): parsed.compare(release)) >= 0;+ const limitations: string[] = [];+ const discloseAdvisory = (+ fix: string,+ advisory: string,+ slug: string,+ ): string =>+ `Reported apktool version ${JSON.stringify(line)} predates the upstream ${fix} fix for ${advisory} (decoded resource paths could escape the output directory). Verify the selected decoder's patches before decoding untrusted APKs; launcher version alone does not establish engine contents or downstream backports. https://github.com/iBotPeaches/Apktool/security/advisories/${slug}`;+ if (!atLeast("2.9.2"))+ limitations.push(+ discloseAdvisory("2.9.2", "CVE-2024-21633", "GHSA-2hqv-2xv4-5h5w"),+ );+ if (platform === "win32" && !atLeast("2.9.3"))+ limitations.push(+ discloseAdvisory(+ "2.9.3",+ "GHSA-vgwr-4w3p-xmjv on Windows",+ "GHSA-vgwr-4w3p-xmjv",+ ),+ );+ // Upstream 65dd848 validates ResTypeSpec names in 3.0.2. The tagged 3.0.0+ // producer also lacks that check, although the advisory names only 3.0.1.+ if (parsed.major === 3 && parsed.minor === 0 && !atLeast("3.0.2"))+ limitations.push(+ discloseAdvisory("3.0.2", "CVE-2026-39973", "GHSA-m8mh-x359-vm8m") ++ (parsed.patch === 0+ ? " Inclusion of the 3.0.0 release line is source-derived; the advisory lists 3.0.1."+ : ""),+ );return {version: line,supportsDocumentedVersion: atLeast("2.7.0"),- limitations: atLeast("2.9.2")- ? []- : [- `Reported apktool version ${JSON.stringify(line)} predates the upstream 2.9.2 fix for CVE-2024-21633 (decoded resource paths could escape the output directory). Verify the selected decoder's patches before decoding untrusted APKs; launcher version alone does not establish engine contents or downstream backports. https://github.com/iBotPeaches/Apktool/security/advisories/GHSA-2hqv-2xv4-5h5w`,- ],+ limitations,};};@@ -315,6 +340,7 @@ export const inspectApktoolClient = async (snapshot.stdout.text,snapshot.stderr.text,selection,+ platform,),);} catch (cause) {@@ -377,8 +403,9 @@ const interpretApktoolVersion = (stdout: string,stderr: string,selection: ApktoolCommandSelection,+ platform: NodeJS.Platform,): ApktoolClientIdentity => {- const identity = parseApktoolVersionOutput(stdout);+ const identity = parseApktoolVersionOutput(stdout, platform);if (identity.version === null)throw new ApktoolConfigurationFailure("version_unresolved",diff --git a/src/apktool/ApktoolProvider.test.ts b/src/apktool/ApktoolProvider.test.tsindex bff476f10..5c02c3c8e 100644--- a/src/apktool/ApktoolProvider.test.ts+++ b/src/apktool/ApktoolProvider.test.ts@@ -687,10 +687,17 @@ it("retains completed Evidence and live cleanup until a denied workspace removal}});-it.each([false, true])(- "preserves completed Evidence and cancellation during workspace cleanup (denied=%s)",- async (deniedInitially) => {- const { command, root } = await writeApktoolStub(decodeStub());+it.each([+ [false, "2.7.0-dirty", "CVE-2024-21633"],+ [true, "2.7.0-dirty", "CVE-2024-21633"],+ [false, "3.0.1", "CVE-2026-39973"],+ [true, "3.0.1", "CVE-2026-39973"],+] as const)(+ "preserves completed Evidence and cancellation during workspace cleanup (denied=%s, version=%s)",+ async (deniedInitially, version, advisory) => {+ const { command, root } = await writeApktoolStub((root) =>+ decodeStub()(root).replace(VERSION_BLOCK, `printf '%s\\n' '${version}'`),+ );const apk = await apkFixture(root);const controller = new AbortController();const reason = { caller: "during final workspace removal" };@@ -720,7 +727,7 @@ it.each([false, true])(operation: "decode_android_resources",normalized_result: { target: { sha256: apk.sha256 } },limitations: expect.arrayContaining([- expect.stringContaining("CVE-2024-21633"),+ expect.stringContaining(advisory),]),});denied = false;@@ -1003,7 +1010,18 @@ it("discloses qualified and unfamiliar strings tables while preserving exact loc}});-it.each(["2.7.0-dirty", "2.9.1", "2.9.2-rc.1", "2.9.2", "2.9.2-dirty"])(+it.each([+ "2.7.0-dirty",+ "2.9.1",+ "2.9.2-rc.1",+ "2.9.2",+ "2.9.2-dirty",+ "3.0.0",+ "3.0.1",+ "3.0.2-rc.1",+ "3.0.2",+ "3.1.0",+])("retains reported-version limitations for both operations without refusing %s (#3438)",async (version) => {const { command, root } = await writeApktoolStub((root) =>@@ -1026,9 +1044,31 @@ it.each(["2.7.0-dirty", "2.9.1", "2.9.2-rc.1", "2.9.2", "2.9.2-dirty"])(limitation.includes("CVE-2024-21633"),);expect(warnings.length).toBe(- ["2.9.2", "2.9.2-dirty"].includes(version) ? 0 : 1,+ ["2.7.0-dirty", "2.9.1", "2.9.2-rc.1"].includes(version) ? 1 : 0,);if (warnings.length > 0) expect(warnings[0]).toContain("CVE-2024-21633");+ expect(+ inspect.value.limitations.filter((warning) =>+ warning.includes("CVE-2026-39973"),+ ).length,+ ).toBe(["3.0.0", "3.0.1", "3.0.2-rc.1"].includes(version) ? 1 : 0);+ expect(+ inspect.value.limitations.filter((warning) =>+ warning.includes("GHSA-vgwr-4w3p-xmjv"),+ ).length,+ ).toBe(+ process.platform === "win32" &&+ [+ "2.7.0-dirty",+ "2.9.1",+ "2.9.2-rc.1",+ "2.9.2",+ "2.9.2-dirty",+ ].includes(version)+ ? 1+ : 0,+ );+for (const warning of inspect.value.limitations)expect(decode.value.limitations).toContain(warning);expect(inspect.value.result).toMatchObject({diff --git a/src/apktool/ApktoolVersionProbe.test.ts b/src/apktool/ApktoolVersionProbe.test.tsindex 1e40e4cee..de61f2d5b 100644--- a/src/apktool/ApktoolVersionProbe.test.ts+++ b/src/apktool/ApktoolVersionProbe.test.ts@@ -160,3 +160,29 @@ it("keeps unresolved probe cleanup typed when the launcher overflows its output"await provider.close();expect(result.ok ? null : result.error.cleanupIncomplete).toBe(false);});++it.each(["linux", "win32"] as const)(+ "interprets advisory applicability using the selected %s host",+ async (platform) => {+ vi.mocked(runOwnedCommand).mockImplementationOnce(+ async (_spawn, limits) => {+ const output = {+ stdout: { text: "2.9.2\n" },+ stderr: { text: "" },+ } as Awaited<ReturnType<typeof runOwnedCommand>>;+ limits.observeCompleted?.(output);+ return output;+ },+ );+ const identity = await inspectApktoolClient(selection, commands, {+ environment: {},+ platform,+ });+ expect(identity.version).toBe("2.9.2");+ expect(+ identity.limitations.some((warning) =>+ warning.includes("GHSA-vgwr-4w3p-xmjv"),+ ),+ ).toBe(platform === "win32");+ },+);