Repository navigation
fix(apktool): run Windows batch launchers through cmd.exe - #1777
Merged
Merged
Conversation
On Windows, Node refuses to spawn .bat and .cmd files without a shell (CVE-2024-27980), so REA_APKTOOL_COMMAND pointing at Chocolatey's apktool.bat or a java -jar wrapper failed its version probe with EINVAL, reported as "did not report a usable version". Move Ghidra's conservative cmd.exe invocation (no AutoRun, no delayed expansion, every token quoted, interpreter metacharacters rejected) into src/process/WindowsBatchCommand.ts. Ghidra keeps its error type, wording and length limit. apktool now uses it for both the version probe and the decode run when the launcher is a batch file on Windows. A launcher that cmd.exe would reinterpret reports launcher_unsupported (not_configured) with remediation instead of version_unresolved. Fixes #1774 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
morluto
added a commit
that referenced
this pull request
Oct 13, 2026
* fix(apktool): resolve Windows PATH launchers before invocation Resolve the default launcher through the selected PATH/PATHEXT before choosing native process creation or the existing conservative cmd.exe wrapper. Reuse the resulting selection and one canonical environment for the version probe and decode. Follow-up to the release #1693 review of #1777. Source inspected and formatted; tests, builds, check reruns and real Windows Apktool execution were skipped at maintainer request. * fix(apktool): bound lookup and retain only selected environment Source inspection and targeted formatting only. Tests, builds, lint, typechecks and provider workloads were not run at the user's explicit request. * fix(apktool): use supported timeout diagnostics Retain lookup phase through AnalysisErrorOptions diagnostics while preserving the operation and timeout identity. Source inspection and targeted formatting only; tests, checks, builds and provider workloads were skipped at the user request. --------- Co-authored-by: morluto <[email protected]>
22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1774.
Problem
On Windows,
REA_APKTOOL_COMMANDpointed at a.bat/.cmdlauncher could never start. These include Chocolatey'sapktool.batand thejava -jarwrapper scripts that REA's remediation text recommends. Since the CVE-2024-27980 fix, Node refuses to run batch files without a shell and throwsEINVAL. The probe then reportedversion_unresolved("did not report a usable version"), which points at the launcher instead of the spawn. The decode run used REA's native Windows spawner with CRT argument quoting, whichcmd.exedoes not parse safely.Change
src/process/WindowsBatchCommand.ts: Ghidra's existing conservative batch call, moved out ofGhidraLauncher. It builds aComSpec-validatedcmd.exe /d /e:on /v:off /s /c "…"call: no AutoRun, no delayed expansion, every token quoted. Tokens containing" % ^ ! & | < >or newlines are rejected rather than escaped.GhidraLaunchError, its P0 wording and its 30,000-character limit. The existing Ghidra batch tests (exactcmd.exeargv, metacharacter rejection, ComSpec selection) pass unchanged.apktoolInvocationwraps the launcher only when the platform iswin32and the path ends in.bat/.cmd. The--versionprobe and theapktool ddecode both use it, withwindowsVerbatimArguments. Native.exelaunchers and POSIX run exactly as before.cmd.exewould reinterpret now reportslauncher_unsupported, which maps to thenot_configuredrejection code, with remediation. If REA's own decode paths contain those characters, decode returnscapability_unavailablenaming the cause.docs/apktool-resource-analysis.mddescribes the Windows behavior.Validation
src/apktool/ApktoolConfiguration.test.ts:cmd.exeinvocation for a Chocolatey-styleapktool.BAT, including a path with spaces..exeand a POSIXapktool.cmdname.launcher_unsupported/not_configuredbefore any spawn.npm run test:focusedon the apktool module/provider tests, the apktool CLI boundary tests, and the Ghidra launcher module/boundary tests passes (54 passed, 1 Windows-only skip). The provider tests decode with a real launcher stub on macOS.npm run check:fastandnpm run docs:checkpass.Not verified: a real Windows host with apktool 3.0.3 and Chocolatey's
apktool.bat. I only have macOS here, so the Windows path is covered by argv-construction tests, not by an executedcmd.exe. The issue mentions other providers that useexecFileOutput(for example adb). Those still run their launchers directly and are not changed here. A bareapktoolresolved fromPATHis also unchanged: WindowsexecFiledoes not applyPATHEXT, so a PATH-onlyapktool.batstill needsREA_APKTOOL_COMMAND.🤖 Generated with Claude Code