Skip to content

fix(#7949): stop leaking injected status/instance values into logs - #7950

Closed
fullsend-ai-coder[bot] wants to merge 2 commits into
mainfrom
agent/7949-sanitize-agent-script-logs
Closed

fullsend-ai-coder[bot] wants to merge 2 commits into
mainfrom
agent/7949-sanitize-agent-script-logs

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Fixes three template-side findings from #7949 (surfaced via review on fullsend-ai/agents#1167) in the scripts fullsend agent new generates:

  • internal/agentnew/templates/post.sh.tmpl — the invalid-status rejection no longer prints any part of the (model-controlled) value. The previous flatten-and-cap approach blocked line-splitting injection but not GitHub Actions' legacy ##[...] logging-command syntax, which the Actions log viewer recognizes anywhere in a line, not only at its start.
  • internal/agentnew/templates/scripts/validate-output-schema.sh — the schema-validation failure message no longer prints Python's ValidationError.message (which embeds the offending instance verbatim, e.g. for a failed enum check). It now reports only trusted schema metadata: the field path, the failed keyword, and (for enum/const) the schema's own allowed-value list.
  • post.sh.tmpl locale handling — LC_ALL is now forced to C.UTF-8 unconditionally instead of only when unset, so an inherited LC_ALL=C from the runner can no longer make the 200-code-point summary cap (and comment truncation) count bytes instead of Unicode code points.

Testing

  • Added regression tests exercising forged ##[warning]/##[add-mask] status values against both the post-script and the generated validator, confirming the raw value never reaches stdout/stderr (and confirmed these tests fail against the pre-fix templates).
  • Added regression tests for multibyte summary/comment handling under an inherited LC_ALL=C (also confirmed failing before the fix).
  • Regenerated testdata/golden/{triage,validation-loop}.txt to match the updated post-script comments.
  • go test ./internal/agentnew/... (including -race), go vet ./..., go build ./..., gofmt -l, staticcheck, and shellcheck -x -e SC1091,SC2001,SC2016 on the changed shell script all pass.
  • pre-commit run could not reach GitHub to fetch hook repos from this sandbox (network policy); the hooks it would have run (whitespace/EOF/line-ending/merge-conflict checks, shellcheck) were run directly instead, and gitleaks-equivalent coverage was done via scan-secrets.

Notes


Closes #7949

Post-script verification

  • Branch is not main/master (agent/7949-sanitize-agent-script-logs)
  • Secret scan passed (gitleaks — d3540e2bf9b2637a4fed538bb86555bf95e7d999..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

Three template-side findings reported against fullsend-ai/agents#1167,
all in `fullsend agent new` output:

1. post.sh.tmpl's invalid-status diagnostic flattened CR/LF and capped
   the value at 40 characters before logging it, which defeats
   line-splitting injection but not GitHub Actions' legacy
   "##[...]" logging-command syntax: the Actions log viewer
   recognizes that form anywhere in a line, not only at its start. A
   model-written status such as "##[warning]forged" would still reach
   the runner log. The fix stops printing any part of the value: the
   rejection message is now fixed text with no model output in it.

2. The generated validate-output-schema.sh printed Python's
   jsonschema ValidationError.message directly, which embeds the
   offending instance verbatim for errors like a failed enum check.
   That instance is the same untrusted agent output as (1), reaching
   the log through the validation-loop path instead. The script now
   reports only trusted schema metadata (the field path, the failed
   keyword, and for enum/const the schema's own allowed-value list)
   and never the instance.

3. post.sh.tmpl's locale default only applied when LC_ALL was unset,
   so a runner that already exports LC_ALL=C passed straight through
   untouched, and the length check then counted bytes instead of
   Unicode code points against the schema's 200-code-point cap. A
   101-character multibyte summary could be wrongly rejected, and
   truncation could slice a comment mid-character. LC_ALL is now
   forced unconditionally.

Added regression tests for all three: forged legacy-command statuses
for both the post-script and the validator, and multibyte
summary/comment handling under an inherited LC_ALL=C. Regenerated the
golden fixtures for the changed post-script comments.

The two injection findings were reported from review but not yet
reproduced on a live runner, per the issue. Once merged,
examples/link-check/ in fullsend-ai/agents needs regenerating from
this template; that is tracked as follow-up in the issue and is out
of scope here.

Closes #7949
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team October 1, 2026 22:59
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Oct 1, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:01 PM UTC · Completed 11:15 PM UTC

Commit: 7636fdf · View workflow run →

Runtime: pi · Model: openai/gpt-6.1-sol → gpt-6.1-sol · Effort: high · Cost: $2.68

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Oct 1, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate risk due to security-labeled issue context and recent churn in agent templates, balanced by focused scope, bot authorship, and absence of protected path or CI workflow changes.

Previous run

Risk Assessment: moderate (2/5)

Details

Moderate risk due to security-labeled issue context and recent churn in agent templates, balanced by focused scope, bot authorship, and absence of protected path or CI workflow changes.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Looks good to me

Previous run

Review

Findings

Medium

  • [injection-vuln] internal/agentnew/templates/scripts/validate-output-schema.sh:68 — ValidationError.path can contain instance-controlled keys, not just schema-declared property names. For a configured schema with additionalProperties: {"type": "integer"}, the invalid instance {"\n::warning::forged\n": "bad"} puts the malicious key into e.path. Joining and printing that path emits the payload into the diagnostic without escaping or a command fence, leaving a workflow-command injection path. The new tests exercise status values under the generated schema, not dynamic property names.
    Remediation: Omit instance paths, replace dynamic components with trusted placeholders, or fence diagnostics with an unpredictable stop-commands token. Add a regression test using additionalProperties or patternProperties with a malicious instance key.

  • [stale-doc] docs/guides/user/building-custom-agents.md:453 — The copyable post-script example still prints a flattened and truncated model-supplied status, whereas the updated template emits a fixed diagnostic. Flattening and truncation preserve legacy-command payloads such as ##[warning]forged, so the guide continues to recommend the logging pattern this PR removes.
    Remediation: Replace the status interpolation with a fixed error message and update the accompanying comment to match internal/agentnew/templates/post.sh.tmpl.


Labels: This bug fix hardens generated agent harness scripts against log injection.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added security Security threat model and related concerns type/bug Confirmed defect in existing behavior component/harness Agent harness, config, and skills loading labels Oct 1, 2026
@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 11:17 PM UTC · Completed 11:26 PM UTC

Commit: 7636fdf · View workflow run →

Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.47

ValidationError.path can include keys taken straight from the instance
when a schema uses additionalProperties/patternProperties, not just
declared property names. validate-output-schema.sh now only prints path
components that are literal property names found in the schema
document; anything else is masked, closing the same workflow-command
log-injection class the post-script already guards against. Also
updates the building-custom-agents.md example post-script, which still
showed the old flatten-and-truncate pattern for an unknown status, to
match post.sh.tmpl's fixed-message approach.

Addresses #7950
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Fixed both findings from the review: validate-output-schema.sh now masks any ValidationError path component that isn't a literal property name declared in the schema document (closing a log-injection path via additionalProperties/patternProperties-matched instance keys), with a new regression test; and the building-custom-agents.md example post-script was updated to match post.sh.tmpl's fixed-message handling of an unknown status instead of the superseded flatten-and-truncate pattern.

Fixed (2):

  1. ValidationError.path can contain instance-controlled keys, not just schema-declared property names, so printing it unescaped leaves a workflow-command injection path (internal/agentnew/templates/scripts/validate-output-schema.sh): Collect every literal property name declared anywhere in the schema document and only print path components that match one of those names; array indices stay as plain integers; any other path component (e.g. a key that only matched via additionalProperties/patternProperties) is replaced with a fixed '' placeholder. Added a regression test using additionalProperties with a malicious instance key matching the finding's example.
  2. The copyable post-script example in building-custom-agents.md still flattens and truncates the model-supplied status instead of matching the fixed-diagnostic approach the template now uses (docs/guides/user/building-custom-agents.md): Replaced the flatten/truncate/interpolate status handling in the example's unknown-status case with a fixed error message and comment matching internal/agentnew/templates/post.sh.tmpl's approach of never printing any part of the status.

Tests: passed

CI inspections (12):

  1. CI / test (passing, success)
  2. CI / test-sandbox-darwin (passing, success)
  3. CI / commit-lint (passing, success)
  4. CI / web (passing, success)
  5. E2E Tests / behaviour (passing, success)
  6. E2E Tests / e2e (passing, success)
  7. E2E Tests / gate (passing, success)
  8. Functional Tests / functional-tests (passing, success)
  9. Functional Tests / gate (passing, success)
  10. Vouch Check / vouch-gate (passing, success)
  11. codecov/patch (passing, success)
  12. DCO (passing, success)
Decision points
  • Chose to mask only path components not literally declared as schema property names, rather than omitting the whole path or wrapping it in a stop-commands fence (alternatives: Omit the instance path entirely, Fence the diagnostic output with an unpredictable stop-commands token, Mask all string path components unconditionally; rationale: Masking only came from unmatched keys preserves the existing, already-tested useful diagnostics (e.g. the 'status' field name in failure output) for the common case of schemas with fixed properties, while still closing the injection path for schemas using additionalProperties/patternProperties. Masking all string components would have broken an existing passing test that asserts the declared property name appears in the failure output.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🤖 Review · ❌ Terminated · Started 11:28 PM UTC · Ended 11:39 PM UTC

Commit: 5d771cf · View workflow run →

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Site preview

Preview: https://a328b9ad-site.fullsend-ai.workers.dev

Commit: 5d771cf53d39d923e82d60a28c1d86524b31754f

@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review October 1, 2026 23:38

Superseded by updated review

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Oct 1, 2026
@fullsend-ai-review

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:28 PM UTC · Completed 11:39 PM UTC

Commit: 5d771cf · View workflow run →

Runtime: pi · Model: openai/gpt-6.1-sol → gpt-6.1-sol · Effort: high · Cost: $1.67

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity in the last month. It will be closed in 2 weeks if no further activity occurs. Remove the stale label to reset the inactivity timer.

@github-actions github-actions Bot added the stale label Nov 1, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been closed due to inactivity. Feel free to reopen it if the changes are still needed.

@github-actions github-actions Bot closed this Nov 22, 2026
@github-actions
github-actions Bot deleted the agent/7949-sanitize-agent-script-logs branch November 22, 2026 01:35

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — 5d771cf5 Deployed Oct 1, 2026 by github-actions[bot]
dev — 5d771cf5 Deployed Oct 1, 2026 by fullsend-ai-coder[bot] via behaviour #14940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/harness Agent harness, config, and skills loading ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate security Security threat model and related concerns stale type/bug Confirmed defect in existing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent new: generated post-script and validator echo untrusted values that can carry legacy ##[ workflow commands; locale default keeps LC_ALL=C

1 participant