Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: verify LiteralPath of update file during windows signature verification #8295

Merged
merged 7 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nervous-carrots-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix: verify LiteralPath of update file during windows signature verification
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { parseDn } from "builder-util-runtime"
import { execFile, execFileSync } from "child_process"
import * as os from "os"
import { Logger } from "./main"
import * as path from "path"

// $certificateInfo = (Get-AuthenticodeSignature 'xxx\yyy.exe'
// | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains("CN=siemens.com")})
Expand Down Expand Up @@ -48,6 +49,18 @@ export function verifySignature(publisherNames: Array<string>, unescapedTempUpda
}
const data = parseOut(stdout)
if (data.Status === 0) {
try {
const normlaizedUpdateFilePath = path.normalize(data.Path)
const normalizedTempUpdateFile = path.normalize(unescapedTempUpdateFile)
logger.info(`LiteralPath: ${normlaizedUpdateFilePath}. Update Path: ${normalizedTempUpdateFile}`)
if (normlaizedUpdateFilePath !== normalizedTempUpdateFile) {
handleError(logger, new Error(`LiteralPath of ${normlaizedUpdateFilePath} is different than ${normalizedTempUpdateFile}`), stderr, reject)
resolve(null)
return
}
} catch (error: any) {
logger.warn(`Unable to verify LiteralPath of update asset due to missing data.Path. Skipping this step of validation. Message: ${error.message ?? error.stack}`)
}
const subject = parseDn(data.SignerCertificate.Subject)
let match = false
for (const name of publisherNames) {
Expand Down Expand Up @@ -96,7 +109,6 @@ function parseOut(out: string): any {
// duplicates data.SignerCertificate (contains RawData)
delete signerCertificate.SubjectName
}
delete data.Path
return data
}

Expand Down
Loading