Skip to content

fix(skillgen): prevent monolith watch path injection - #3852

Closed
hopstreax wants to merge 2 commits into
Graphify-Labs:v8from
hopstreax:fix/3844-watch-input-path-injection
Closed

hopstreax wants to merge 2 commits into
Graphify-Labs:v8from
hopstreax:fix/3844-watch-input-path-injection

Conversation

@hopstreax

@hopstreax hopstreax commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3844 by preventing untrusted INPUT_PATH values from being interpreted as shell syntax in Graphify's generated skills, including the Aider and Devin monolith flows.

Changes

  • Persist the resolved scan root to graphify-out/.graphify_root through a single-quoted heredoc.

  • Remove direct INPUT_PATH interpolation from the Aider/Devin --watch commands.

  • Make --watch consume the trusted .graphify_root marker instead.

  • Remove literal INPUT_PATH references from Step 1 comments to prevent newline-based substitution from escaping the quoted heredoc.

  • Add narrowly scoped sanctioned-diff rules for the intentional monolith changes.

  • Expand security tests to cover:

    • command substitution
    • backticks
    • ;
    • &&
    • pipes
    • newline injection
  • Add tests for valid paths containing spaces and nonexistent paths.

  • Fix Linux/macOS portability in the path-resolution tests.

  • Regenerate all affected skill artifacts and expected snapshots.

Validation

  • python -m tools.skillgen --check — PASS
  • python -m tools.skillgen --monolith-roundtrip — PASS
  • pytest tests/test_skillgen_input_path_injection.py -v — 30 passed
  • pytest tests/test_skillgen.py -v — 65 passed
  • git diff --check — PASS

Security

The scan path is now passed to Python through a quoted heredoc rather than being interpreted as part of a shell command. The Aider and Devin --watch flows read the trusted resolved root from graphify-out/.graphify_root, eliminating direct shell interpolation of INPUT_PATH.

No unrelated changes are included.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 3 advisory finding(s) below merit a look before merge.


Graphify review — findings

Fixes a command-injection vector in the --watch instructions of the Aider and Devin skill monoliths: Step 1 now persists the resolved scan root to graphify-out/.graphify_root via a quoted heredoc (so metacharacters in the path are never re-interpreted), and the --watch command reads that trusted file instead of substituting a raw INPUT_PATH. Extends the injection test suite to pull Step 1 and --watch blocks from all three skill artifacts, assert the --watch command uses the exact trusted-file form with no raw placeholder, and execute Step 1 against six hostile payloads to prove no injected command runs. Adds Windows/WSL handling in the test runner that rewrites C:\ paths to /mnt/c/ and shells out via a temp .sh file to dodge quote mangling.

Worth a look

  • Step 1 now rejects URL/non-directory INPUT_PATHs before graphify can handle them — graphify/skill-aider.md:100 · Escalate · high
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Unconditional drive-letter indexing crashes legitimate-path test on POSIX — tests/test_skillgen_input_path_injection.py:184 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Unquoted interpreter path breaks watch when Python path contains spaces — graphify/skill-aider.md:1239 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 389 functions depend on the 324 functions this change touches.

Health — this change adds coupling hotspots:

  • new: render() — 13 callers, 5 callees
  • new: audit_coverage() — 8 callers, 6 callees
  • new: main() — 3 callers, 11 callees
  • new: monolith_roundtrip() — 3 callers, 5 callees
  • new: test_audit_catches_a_dropped_non_allowlisted_heading() — 0 callers, 6 callees

Verification — 389 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 389 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

301 of 301 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/test_affected_cli.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_agents_platform.py — full-run-safety
  • tests/test_analyze.py — full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — full-run-safety
  • tests/test_astro_import_ids.py — full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_build.py — full-run-safety
  • tests/test_build_merge_dedup_scope.py — full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — full-run-safety
  • tests/test_build_merge_shrink_guard.py — full-run-safety
  • tests/test_builtin_global_type_refs.py — full-run-safety
  • tests/test_cache.py — full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_cargo_missing_manifest.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — full-run-safety
  • tests/test_case_sensitive_resolution.py — full-run-safety
  • tests/test_charmap_encoding.py — full-run-safety
  • tests/test_chunking.py — full-run-safety
  • tests/test_cjs_module_extension.py — full-run-safety
  • tests/test_claude_cli_backend.py — full-run-safety
  • tests/test_claude_md.py — full-run-safety
  • tests/test_cli_broken_pipe.py — full-run-safety
  • tests/test_cli_export.py — full-run-safety
  • tests/test_cli_help.py — full-run-safety
  • tests/test_cluster.py — full-run-safety
  • tests/test_cobol_extractor.py — full-run-safety
  • tests/test_codebuddy.py — full-run-safety
  • tests/test_community_hub_labels.py — full-run-safety
  • tests/test_community_labels_skill.py — full-run-safety
  • tests/test_confidence.py — full-run-safety
  • tests/test_corrupt_graph_json.py — full-run-safety
  • tests/test_cpp_nested_and_cli.py — full-run-safety
  • tests/test_cpp_objc_cross_file_calls.py — full-run-safety
  • tests/test_cpp_preprocess.py — full-run-safety
  • tests/test_cross_extension_reexport_self_cycle.py — full-run-safety
  • tests/test_cross_language_call_resolution.py — full-run-safety
  • tests/test_cross_repo_external_call_guards.py — full-run-safety
  • tests/test_cross_repo_member_calls.py — full-run-safety
  • … and 251 more

non-code file(s) changed (graphify/skill-aider.md, graphify/skill-devin.md, tools/skillgen/expected/graphify__skill-aider.md, tools/skillgen/expected/graphify__skill-devin.md, tools/skillgen/fragments/core/aider.md …) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (graphify/skill-aider.md, graphify/skill-devin.md, tools/skillgen/expected/graphify__skill-aider.md, tools/skillgen/expected/graphify__skill-devin.md, tools/skillgen/fragments/core/aider.md …) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

· 5 more finding(s) on lines outside this diff (see the check run).

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 5 advisory finding(s) below merit a look before merge.


Graphify review — findings

Hardens the graphify update/watch flow across all skill variants by reading the scan root from the trusted graphify-out/.graphify_root file instead of substituting INPUT_PATH into the command line, so a path containing shell metacharacters can't be re-interpreted. Adds the root-saving heredoc step to the aider and devin variants that were missing it, and updates the watcher invocation to $(cat graphify-out/.graphify_python) -m graphify.watch "$(cat graphify-out/.graphify_root)". Rewords the accompanying comments and generator fragments/expected fixtures to match.

Worth a look

  • Command substitution of .graphify_root reintroduces shell injection in watch command (devin) — graphify/skill-devin.md:1369 · Escalate · high
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Watch command executes interpreter arguments from workspace file — tools/skillgen/fragments/core/devin.md:1369 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Persisted Python interpreter is executed unquoted in watch command — graphify/skill-aider.md:1227 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Watcher executes interpreter path from writable project file — graphify/skill-aider.md:1229 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Watch command leaves saved Python path unquoted — tools/skillgen/gen.py:1177 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 1043 functions depend on the 978 functions this change touches.

Health — this change adds coupling hotspots:

  • new: render() — 13 callers, 5 callees
  • new: audit_coverage() — 8 callers, 6 callees
  • new: main() — 3 callers, 11 callees
  • new: monolith_roundtrip() — 3 callers, 5 callees
  • new: test_audit_catches_a_dropped_non_allowlisted_heading() — 0 callers, 6 callees

Verification — 1043 functions in the blast radius were not formally verified this run (proofs are advisory here).

Health delta baseline: last indexed commit 4139885 (diverged from this PR's base — delta is approximate).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 1043 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

301 of 301 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/test_affected_cli.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_agents_platform.py — full-run-safety
  • tests/test_analyze.py — full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — full-run-safety
  • tests/test_astro_import_ids.py — full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_build.py — full-run-safety
  • tests/test_build_merge_dedup_scope.py — full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — full-run-safety
  • tests/test_build_merge_shrink_guard.py — full-run-safety
  • tests/test_builtin_global_type_refs.py — full-run-safety
  • tests/test_cache.py — full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_cargo_missing_manifest.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — full-run-safety
  • tests/test_case_sensitive_resolution.py — full-run-safety
  • tests/test_charmap_encoding.py — full-run-safety
  • tests/test_chunking.py — full-run-safety
  • tests/test_cjs_module_extension.py — full-run-safety
  • tests/test_claude_cli_backend.py — full-run-safety
  • tests/test_claude_md.py — full-run-safety
  • tests/test_cli_broken_pipe.py — full-run-safety
  • tests/test_cli_export.py — full-run-safety
  • tests/test_cli_help.py — full-run-safety
  • tests/test_cluster.py — full-run-safety
  • tests/test_cobol_extractor.py — full-run-safety
  • tests/test_codebuddy.py — full-run-safety
  • tests/test_community_hub_labels.py — full-run-safety
  • tests/test_community_labels_skill.py — full-run-safety
  • tests/test_confidence.py — full-run-safety
  • tests/test_corrupt_graph_json.py — full-run-safety
  • tests/test_cpp_nested_and_cli.py — full-run-safety
  • tests/test_cpp_objc_cross_file_calls.py — full-run-safety
  • tests/test_cpp_preprocess.py — full-run-safety
  • tests/test_cross_extension_reexport_self_cycle.py — full-run-safety
  • tests/test_cross_language_call_resolution.py — full-run-safety
  • tests/test_cross_repo_external_call_guards.py — full-run-safety
  • tests/test_cross_repo_member_calls.py — full-run-safety
  • … and 251 more

non-code file(s) changed (graphify/skill-agents.md, graphify/skill-aider.md, graphify/skill-amp.md, graphify/skill-claw.md, graphify/skill-codex.md …) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (graphify/skill-agents.md, graphify/skill-aider.md, graphify/skill-amp.md, graphify/skill-claw.md, graphify/skill-codex.md …) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

· 5 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Sep 27, 2026
Security: close the Fortran cpp #include arbitrary-file-read
(GHSA-pcc4-rvhr-2pr8), the last Aider/Devin monolith --watch shell sink
(#3852), and terraform name/value secret redaction (#3870). Plus Windows
watch rebuild locking (#3883), C# tuple element-name refs (#3877), JSX
component-usage calls (#3855), and nested scan-root Python import
projection (#3867).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.70 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @hopstreax! Closes the last Aider/Devin monolith --watch shell sink (tracking issue #3844); monolith-roundtrip and the gen.py sanctioned-diff verified green.

Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.70

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