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: prevent yarn directory traversal on plugin installation #6829

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all 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: 4 additions & 1 deletion packages/insomnia/src/main/install-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cp, mkdir, readdir, stat } from 'node:fs/promises';
import { cp, mkdir, readdir, stat, writeFile } from 'node:fs/promises';

import childProcess from 'child_process';
import * as electron from 'electron';
Expand Down Expand Up @@ -160,6 +160,8 @@ async function _installPluginToTmpDir(lookupName: string) {
return new Promise<{ tmpDir: string }>(async (resolve, reject) => {
const tmpDir = path.join(electron.app.getPath('temp'), `${lookupName}-${Date.now()}`);
await mkdir(tmpDir, { recursive: true });
// Write a dummy package.json so that yarn doesn't traverse up the directory tree
await writeFile(path.join(tmpDir, 'package.json'), JSON.stringify({ license: 'ISC', workspaces: [] }), 'utf-8');

console.log(`[plugins] Installing plugin to ${tmpDir}`);
childProcess.execFile(
Expand All @@ -176,6 +178,7 @@ async function _installPluginToTmpDir(lookupName: string) {
'--no-lockfile',
'--production',
'--no-progress',
'--ignore-workspace-root-check',
],
{
timeout: 5 * 60 * 1000,
Expand Down