Skip to content

Commit ff48200

Browse files
authored
fix: harden IPC file permissions and upgrade minimatch for brace-expansion compat (#117)
1 parent 5f1522c commit ff48200

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@
815815
"hosted-git-info": "8.1.0",
816816
"isexe": "3.1.1",
817817
"lru-cache": "11.2.2",
818-
"minimatch": "9.0.5",
818+
"minimatch": "9.0.6",
819819
"minipass": "7.1.3",
820820
"minipass-fetch": "4.0.1",
821821
"minipass-sized": "1.0.3",

pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ipc.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ async function ensureIpcDirectory(filePath: string): Promise<void> {
269269
const fs = getFs()
270270
const path = getPath()
271271
const dir = path.dirname(filePath)
272-
// Create directory recursively if it doesn't exist.
273-
await fs.promises.mkdir(dir, { recursive: true })
272+
// Use restrictive permissions (owner-only) to prevent other users
273+
// from reading or writing IPC stub files.
274+
await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 })
274275
}
275276

276277
/**
@@ -326,11 +327,12 @@ export async function writeIpcStub(
326327

327328
// Write with pretty printing for debugging.
328329
const fs = getFs()
329-
await fs.promises.writeFile(
330-
stubPath,
331-
JSON.stringify(validated, null, 2),
332-
'utf8',
333-
)
330+
// Use restrictive permissions (owner-only read/write) to prevent
331+
// other users on the system from reading sensitive IPC data.
332+
await fs.promises.writeFile(stubPath, JSON.stringify(validated, null, 2), {
333+
encoding: 'utf8',
334+
mode: 0o600,
335+
})
334336
return stubPath
335337
}
336338

@@ -442,7 +444,9 @@ export async function cleanupIpcStubs(appName: string): Promise<void> {
442444
// File is stale if EITHER check indicates staleness
443445
isStale = isStale || contentAge > maxAgeMs
444446
} catch {
445-
// If we can't read/parse the file, rely on mtime check
447+
// If we can't read/parse the file, treat it as stale
448+
// to prevent accumulation of corrupted stub files.
449+
isStale = true
446450
}
447451

448452
if (isStale) {

0 commit comments

Comments
 (0)