Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

Addresses shell escaping vulnerability identified in PR #429 review. The script path argument to popen() was wrapped in double quotes, which doesn't protect against special shell metacharacters like backticks, dollar signs, or embedded quotes.

Changes

  • Added shell_escape() helper function implementing POSIX single-quote escaping
  • Updated command construction in run_python_code() to use proper escaping
  • Added _codeql_build_dir and _codeql_detected_source_root to .gitignore

Implementation

Before:

std::string cmd = python_exe + " \"" + script_path.string() + "\" 2>&1";

After:

std::string cmd = python_exe + " " + shell_escape(script_path.string()) + " 2>&1";

The shell_escape() function wraps arguments in single quotes and escapes embedded single quotes using '\'' pattern, preventing command injection regardless of path contents.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

evaleev and others added 3 commits November 21, 2025 13:20
Implement proper POSIX shell escaping for script path using single quotes.
This prevents command injection when the path contains special shell
metacharacters like backticks, dollar signs, or spaces.

Co-authored-by: evaleev <[email protected]>
@evaleev evaleev force-pushed the feature/export-numpy branch from cbe70f5 to b11a07b Compare November 21, 2025 18:24
Copilot AI and others added 2 commits November 21, 2025 18:28
The CodeQL checker created build artifacts that should not be committed.
Added _codeql_build_dir and _codeql_detected_source_root to .gitignore.

Co-authored-by: evaleev <[email protected]>
Copilot AI changed the title [WIP] Update minimal NumPy support based on review feedback Fix shell injection vulnerability in test_export_python.cpp Nov 21, 2025
Copilot AI requested a review from evaleev November 21, 2025 18:30
@evaleev evaleev marked this pull request as ready for review November 21, 2025 21:59
@evaleev evaleev merged commit afa16eb into feature/export-numpy Nov 21, 2025
16 checks passed
@evaleev evaleev deleted the copilot/sub-pr-429 branch November 21, 2025 22:02
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