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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix for RCE on "gitlogplus" - huntr.dev #59

Merged
merged 2 commits into from Sep 14, 2020
Merged
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
8 changes: 5 additions & 3 deletions src/index.ts
@@ -1,4 +1,4 @@
import { exec, execSync, ExecSyncOptions, ExecException } from "child_process";
import { execFile, execFileSync, ExecSyncOptions, ExecException } from "child_process";
import { existsSync } from "fs";
import createDebugger from "debug";

Expand Down Expand Up @@ -323,9 +323,11 @@ function gitlog<Field extends CommitField = DefaultField>(
};
const execOptions = { cwd: userOptions.repo, ...userOptions.execOptions };
const command = createCommand(options);

command = command.split(' ');

if (!cb) {
const stdout = execSync(command, execOptions).toString();
const stdout = execFileSync(command[0], command.slice(1), execOptions).toString();
const commits = stdout.split("@begin@");

if (commits[0] === "") {
Expand All @@ -336,7 +338,7 @@ function gitlog<Field extends CommitField = DefaultField>(
return parseCommits(commits, options.fields, options.nameStatus);
}

exec(command, execOptions, (err, stdout, stderr) => {
execFile(command[0], command.slice(1), execOptions, (err, stdout, stderr) => {
debug("stdout", stdout);
const commits = stdout.split("@begin@");

Expand Down