Skip to content

fix(skill): write save-result/add free text to disk instead of a shell arg (#3640) - #4507

Open
dKKpandey wants to merge 1 commit into
Graphify-Labs:v8from
dKKpandey:fix/aider-devin-skill-injection
Open

dKKpandey wants to merge 1 commit into
Graphify-Labs:v8from
dKKpandey:fix/aider-devin-skill-injection

Conversation

@dKKpandey

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #3640: the aider and devin monolith skills have no disk-write tool and built graphify save-result/graphify add by substituting free text (the user's verbatim question, an LLM-generated answer, a URL/author/contributor) directly into a double-quoted shell argument or a Python string literal inside -c "...". Bash still performs $(...) and backtick command substitution inside double quotes, and an embedded '/\ breaks out of the Python literal — so that free text (which can originate from an untrusted fetched page) could execute as shell or Python instead of being treated as data. This is the same injection class as #3642/#3844, just in the two monoliths that have no separate file-write tool.

How

Both skills now write the free text to a temp file first via a single-quoted heredoc (<<'GRAPHIFY_EOF', which bash does not expand at all — no $(), backticks, or quote interpretation), then dispatch through file-based flags instead of inline substitution:

  • save-result --question-file ... --answer-file ... --nodes-file ... (3 call sites per skill: query, path, explain)
  • add --from-file payload.json (1 call site per skill), where the one line written is parsed as JSON, not executed — so even an unescaped " is at worst a JSON parse error, never code execution.

graphify/cli.py gains the missing file-based flags, mirroring the --answer-file flag already shipped for #1502:

  • save-result: --question-file, --nodes-file (accepts one or more paths, one node label per line), --correction-file
  • add: --from-file <path> reading {"url": ..., "author": ..., "contributor": ..., "dir": ...} (author/contributor/dir optional)

Missing/unreadable/non-UTF-8 files and malformed --from-file payloads end in a clean CLI error, not a traceback.

tools/skillgen/gen.py gains _is_skill_injection_fix_line, a sanctioned-diff predicate (following the existing pattern, e.g. _is_watch_injection_fix_line for #3844) so the monolith round-trip guard accepts this change instead of flagging it as unreviewed drift.

Testing

  • New tests/test_cli_save_result_add.py (10 tests): file-based flags for both commands, including adversarial payloads containing $(rm -rf /), backticks, and SQL/shell metacharacters that now land inertly in the saved content instead of executing; missing-file and malformed-JSON error paths; and a no-regression check that the original inline --question/--answer and positional-add forms still work.
  • python -m tools.skillgen --check / --monolith-roundtrip / --schema-singleton: all pass (134 artifacts match).
  • tests/test_skillgen.py (67 tests), tests/test_ingest.py, tests/test_cli_help.py, tests/test_cli_broken_pipe.py: all pass.

This PR is scoped to cli.py and the aider/devin fragments only — it doesn't touch any extractor code.

🤖 Generated with Claude Code

…l arg (Graphify-Labs#3640)

The aider and devin monolith skills have no disk-write tool and built
`graphify save-result`/`graphify add` by substituting free text (the
user's verbatim question, an LLM-generated answer, a URL/author/
contributor) directly into a double-quoted shell argument or a Python
string literal inside `-c "..."`. Bash still performs `$(...)` and
backtick command substitution inside double quotes, and an embedded
`'`/`\` breaks out of the Python literal, so that free text could run
as shell or Python instead of being treated as data.

Both skills now write the free text to a temp file first via a
single-quoted heredoc (`<<'GRAPHIFY_EOF'`, which bash does not expand
at all), then dispatch through `save-result --question-file/
--answer-file/--nodes-file` and `add --from-file <json>`. Neither has
an injection surface: the file's own path is the only shell argument,
and the `add` JSON payload is parsed, not executed.

`graphify/cli.py` gains the file-based flags (mirroring the disk-
capable platforms' `--answer-file`, already shipped for Graphify-Labs#1502):
`--question-file`/`--nodes-file`/`--correction-file` for `save-result`,
and `--from-file` for `add`. tools/skillgen/gen.py gains a sanctioned-
diff predicate so the monolith round-trip guard accepts this change.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@dKKpandey
dKKpandey requested a review from safishamsi as a code owner October 16, 2026 23:34
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @dKKpandey. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 16, 2026

@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.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).

Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).

Not verified on this run: dispatch\_command (vacuous: never exercised).


Graphify review — findings

Adds file-based inputs to the CLI so skills no longer interpolate free text into shell commands: save-result accepts --question-file, --answer-file, --nodes-file and --correction-file, and add accepts --from-file with a JSON payload. Unreadable, non-UTF-8 or non-object inputs and empty question/answer values now end in a clean CLI error instead of a traceback. The aider and devin skills (and their generated expected outputs) now write the question, answer and node labels to temp files through a quoted heredoc before calling the CLI, but that heredoc uses a fixed delimiter and shared temp paths, so user text containing the delimiter line can still break out into the shell and concurrent runs can overwrite each other's files.

Worth a look

  • Fixed heredoc delimiter lets user text break out into shell — graphify/skill-aider.md:1094 · Escalate · high
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Fixed heredoc delimiter lets user text break out into shell — graphify/skill-devin.md:1230 · Escalate · high
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Fixed heredoc delimiter allows shell injection from saved content — tools/skillgen/expected/graphify__skill-aider.md:1093 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review

Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 776 functions depend on the 416 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: dispatch_command() — 5 callers, 135 callees
  • worse: main() — 112 callers, 3 callees

Verification — 776 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: 731 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

433 of 433 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/pi.test.ts — full-run-safety
  • tests/test_affected_cli.py — impact, full-run-safety
  • tests/test_affected_defines.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_affected_overrides.py — full-run-safety
  • tests/test_agents_platform.py — impact, full-run-safety
  • tests/test_alias_folding.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_backend_opt_in.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_benchmark_real_query.py — full-run-safety
  • tests/test_blade_extractor.py — full-run-safety
  • tests/test_build.py — full-run-safety
  • tests/test_build_located_semantic_identity.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_c_include_resolution.py — full-run-safety
  • tests/test_cache.py — full-run-safety
  • tests/test_cache_stale_import_target.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 — impact, full-run-safety
  • tests/test_cli_help.py — full-run-safety
  • tests/test_cli_save_result_add.py — impact, changed-test, full-run-safety
  • tests/test_cloud_cta.py — impact, full-run-safety
  • tests/test_cluster.py — full-run-safety
  • tests/test_cluster_ambiguous_scale.py — full-run-safety
  • … and 383 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.

Docs that may be stale (advisory)

Formal verification

Could not verify: Could not verify dispatch\_command.

The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aider/devin skills still build save-result/add commands from unescaped free text (RCE via $(...) in double quotes)

1 participant