Observations
The file packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts
implements the signature validation routine for Electron applications on Windows. It executes the following command in a new shell (process.env.ComSpec
on Windows, usually C:\Windows\System32\cmd.exe
):
https://github.com/electron-userland/electron-builder/blob/140e2f0eb0df79c2a46e35024e96d0563355fc89/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts#L35-L41
Because of the surrounding shell, a first pass by cmd.exe
expands any environment variable found in command-line above.
Exploitation
This creates a situation where verifySignature()
can be tricked into validating the certificate of a different file than the one that was just downloaded. If the step is successful, the malicious update will be executed even if its signature is invalid.
Impact
This attack assumes a compromised update manifest (server compromise, Man-in-the-Middle attack if fetched over HTTP, Cross-Site Scripting to point the application to a malicious updater server, etc.).
Patch
This vulnerability was patched in #8295, by comparing the path in the output of Get-AuthenticodeSignature
with the intended one. The patch is available starting from 6.3.0-alpha.6.
References
Observations
The file
packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts
implements the signature validation routine for Electron applications on Windows. It executes the following command in a new shell (process.env.ComSpec
on Windows, usuallyC:\Windows\System32\cmd.exe
):https://github.com/electron-userland/electron-builder/blob/140e2f0eb0df79c2a46e35024e96d0563355fc89/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts#L35-L41
Because of the surrounding shell, a first pass by
cmd.exe
expands any environment variable found in command-line above.Exploitation
This creates a situation where
verifySignature()
can be tricked into validating the certificate of a different file than the one that was just downloaded. If the step is successful, the malicious update will be executed even if its signature is invalid.Impact
This attack assumes a compromised update manifest (server compromise, Man-in-the-Middle attack if fetched over HTTP, Cross-Site Scripting to point the application to a malicious updater server, etc.).
Patch
This vulnerability was patched in #8295, by comparing the path in the output of
Get-AuthenticodeSignature
with the intended one. The patch is available starting from 6.3.0-alpha.6.References