Skip to content
Closed
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
8 changes: 8 additions & 0 deletions examples/reaction-lifecycle-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { exec } from "node:child_process";

export function showRevision(request, response) {
exec(`git show ${request.query.revision}`, (error, output) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Avoid interpolating the request value into a shell command

request.query.revision is user-controlled and is interpolated into the shell command passed to exec, so a value such as HEAD; <command> executes arbitrary commands on the server. Validate it as a permitted revision format and invoke git without a shell (for example, execFile with argument array).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Avoid interpolating the revision into a shell command

exec invokes a shell, so an attacker-controlled request.query.revision can append shell syntax (for example, ; curl ...) and execute arbitrary commands in the process context. Validate the revision against an expected Git object format and invoke Git with argument-based execution (such as execFile('git', ['show', revision], ...)) rather than shell interpolation.

if (error) return response.status(500).send(error.message);
response.type("text/plain").send(output);
});
}