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: More small security fixes #6589

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-avocados-search.md
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix: More small security fixes
2 changes: 1 addition & 1 deletion packages/electron-updater/src/MacUpdater.ts
Expand Up @@ -118,7 +118,7 @@ export class MacUpdater extends AppUpdater {
const authInfo = Buffer.from(`autoupdater:${pass}`, "ascii")

// insecure random is ok
const fileUrl = `/${Date.now().toString(16)}-${Math.floor(Math.random() * 9999).toString(16)}.zip`
const fileUrl = `/${randomBytes(64).toString("hex")}.zip`
this.server!.on("request", (request: IncomingMessage, response: ServerResponse) => {
const requestUrl = request.url!
log.info(`${requestUrl} requested`)
Expand Down
Expand Up @@ -22,12 +22,11 @@ export function verifySignature(publisherNames: Array<string>, unescapedTempUpda
// https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7
// * Double quotes `"` are treated literally within single-quoted strings;
// * Single quotes can be escaped by doubling them: 'don''t' -> don't;
// * Backticks can be escaped by doubling them: 'A backtick (``) character';
//
// Also note that at this point the file has already been written to the disk, thus we are
// guaranteed that the path will not contain any illegal characters like <>:"/\|?*
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, "''").replace(/`/g, "``")
const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, "''")

// https://github.com/electron-userland/electron-builder/issues/2421
// https://github.com/electron-userland/electron-builder/issues/2535
Expand Down