Prevent MCP command injection via allowlist validation (CWE-78)

fix: prevent MCP command injection via allowlist validation (CWE-78) (#12290)
Prevent MCP command injection via allowlist validation (CWE-78)efbc4a-fix-prevent-mcp-command-injection-via-allowlist-cve-2026-105697-cve-2026-105740fixprevent mcp command injection via allowlist

Committed by Jkavia

commit message
fix: prevent MCP command injection via allowlist validation (CWE-78) (#12290)

* fix: prevent MCP command injection via allowlist validation (CWE-78)
 
* fix: add security logging and refactor MCP validation constants
 
* fix: harden MCP schema validation with env var blocklist, Docker arg checks, and npx auto-install prevention
- Block dangerous environment variables (LD_PRELOAD, NODE_OPTIONS, PYTHONSTARTUP,
  PATH, BASH_ENV, IFS, BASH_FUNC_*, HOME, TMPDIR, etc.) that enable code injection
  through approved MCP commands wrapped in bash -c
- Block npx -y/--yes flags to prevent silent package auto-installation
- Block Docker isolation-breaking args (--privileged, --net=host, --cap-add, etc.)
- Block subshell parentheses as shell metacharacters
- Migrate stdlib logging to langflow.logging (structured logger)
- Migrate deprecated Pydantic v1 Config class to v2 ConfigDict
- Convert mutable security constants (set/list) to immutable frozensets
- Extract _extract_base_command helper to reduce duplication
- Replace verbose extra={} log dicts with concise format-string logging
- Add 40+ targeted tests covering all new validation surfaces
Addresses authenticated command injection (CWE-78) via environment variable
manipulation, npx package auto-install bypass, and Docker container escape.
 
* [autofix.ci] apply automated fixes
 
* [autofix.ci] apply automated fixes (attempt 2/3)
 
* [autofix.ci] apply automated fixes (attempt 3/3)
 
* chore: update uv.lock after merging release-1.9.0
 
* [autofix.ci] apply automated fixes
 
* [autofix.ci] apply automated fixes (attempt 2/3)
 
* [autofix.ci] apply automated fixes (attempt 3/3)
 
* fix: handle command strings with arguments in MCP validation for frontend compatibility
 
* fix: reset auto-generated files to match release-1.9.0
 
* [autofix.ci] apply automated fixes
 
* feat: add shell wrapper support for MCP command validation with security controls
 
* [autofix.ci] apply automated fixes
 
---------
 
Co-authored-by: Janardan S Kavia <[email protected]>
Co-authored-by: Hamza Rashid <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

Editor assessment

This commit patches CVE-2026-105697 and CVE-2026-105740. A strong security message. The subject names the vulnerability class and the fix mechanism (allowlist validation) and cites CWE-78, so the risk is clear before the body starts. The body then enumerates the actual bypasses - LD_PRELOAD/NODE_OPTIONS-style environment variables, npx auto-install, Docker isolation-breaking flags, subshell metacharacters - and notes the 40+ tests. The only reasons it stops at 4 are noise: a very long squash log with autofix and lockfile commits, and no scope. The substance is publishable as-is.

Browse categories

More fix examples · Back to search