fix(updater): escape manifest-derived paths in the Windows update script - #580
Merged
kdroidFilter merged 1 commit intoAug 19, 2026
Merged
Conversation
The Windows self-update PowerShell interpolates the downloaded artifact path into single-quoted strings (Remove-Item, Start-Process). That path is built from the `url` field of the remote update manifest, so a hostile or compromised manifest could embed a single quote to break out of the quoting and inject PowerShell that runs at install time. The macOS and Linux script builders already quote via quoteForShell(); the Windows builder did not. Every manifest-derived value is now passed through psSingleQuote(), which doubles single quotes — the PowerShell escape for a literal quote inside a single-quoted string — closing the injection while leaving ordinary Windows paths unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Security fix — F-6 (audit 2026-08-19)
Severity: Medium · Module:
updater-runtimeProblem
The
urlfield from the remote update manifest is used verbatim as the local artifact file name and then interpolated into single-quoted PowerShell strings with no escaping:A hostile or compromised manifest can put a
'in the name to break out of the quoting and inject PowerShell that runs at install time. The macOS and Linux script builders already escape viaquoteForShell(); the Windows builder had no equivalent.Fix
A
psSingleQuote()helper doubles every'— the PowerShell escape for a literal quote inside a single-quoted string — and every manifest-derived value (artifact path, script path, installer path, relaunch launcher) is passed through it. Ordinary Windows paths are unchanged; a'can no longer terminate the string and start a new command.Test
WindowsUpdateScriptTestgains a case feeding a name containingev'il; Start-Process calc.exe #and asserting the quote is doubled in the generated script and the raw break-out sequence never appears.Note (out of scope here): path traversal via a
../-containing manifest name is a separate concern in the staging-path construction (NucleusUpdater/FileSelector) and is best fixed there with a filename charset allow-list; this PR closes the injection (RCE) vector only.Verified locally:
:updater-runtime:ktlintCheck :updater-runtime:detekt :updater-runtime:testall pass.🤖 Generated with Claude Code