Skip to content

fix(security): replace shell-injection execSync and validate user-supplied RegExp to fix semgrep/ci#20

Draft
div0-space with Copilot wants to merge 4 commits into
chore/deprivatizefrom
copilot/fix-semgrep-ci-failure
Draft

fix(security): replace shell-injection execSync and validate user-supplied RegExp to fix semgrep/ci#20
div0-space with Copilot wants to merge 4 commits into
chore/deprivatizefrom
copilot/fix-semgrep-ci-failure

Conversation

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown

The semgrep/ci job was failing because Semgrep's p/ci ruleset detected two real security issues in the codebase.

CWE-78: Command Injection — scripts/check-semgrep.js

execSync with a template literal passes input through a shell, flagged by Semgrep's child-process-injection rule:

// before — shell-interpolated, CWE-78
const output = execSync(`"${semgrepPath}" --version`, { encoding: 'utf8' }).trim();

// after — no shell, args array
const output = execFileSync(semgrepPath, ['--version'], { encoding: 'utf8' }).trim();

Both execSync calls (including the semgrep --version fallback probe) are replaced with execFileSync.

CWE-730: ReDoS / Non-literal RegExp — src/index.ts

handleFilterResults passed unsanitized MCP arguments directly to new RegExp():

// before — unvalidated user input
const pathRegex = new RegExp(args.path_pattern);

// after — rejects invalid patterns with McpError
let pathRegex: RegExp;
try {
  pathRegex = new RegExp(args.path_pattern);
} catch {
  throw new McpError(ErrorCode.InvalidParams, 'path_pattern is not a valid regular expression');
}

Same fix applied to message_pattern.

div0-space and others added 2 commits July 19, 2026 12:31
…rep.js; validate user-supplied regex patterns in handleFilterResults
Copilot AI changed the title [WIP] Fix failing GitHub Actions job semgrep/ci fix(security): replace shell-injection execSync and validate user-supplied RegExp to fix semgrep/ci Jul 19, 2026
Copilot AI requested a review from div0-space July 19, 2026 10:34
@div0-space
div0-space changed the base branch from main to chore/deprivatize July 19, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants