Skip to content

fix(media): prevent provider-generated text from injecting delivery directives - #118780

Merged
steipete merged 1 commit into
mainfrom
codex/qa0803-generated-media-directive-boundary
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0803-generated-media-directive-boundary

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • stop hostile image/video/music provider metadata, generated attachment names/types/URLs, model/provider labels and returned lyrics from being interpreted as trusted MEDIA, reply, reaction, voice-note, Markdown-image or fence directives
  • centralize model-facing generated-attachment display sanitization in its canonical formatter while keeping original structured attachment URLs/paths, signed bytes, raw provider results and lyrics intact
  • preserve legitimate operator/assistant attachments and readable multiline lyrics across immediate delivery, background completion, retry, internal-event serialization and escaped-newline rehydration

Actual production-path security proof

  • genuine owner->internal event->message-tool newline normalization->reply parser->outbound planner regressions originally attached arbitrary synthetic local/remote files, rerouted replies, altered reactions/voice mode, or silently swallowed intended attachments
  • actual signed provider URLs remain byte-exact in structured delivery; only provider-controlled presentation is defanged
  • escaped CR/LF plus 0–3 spaces and both backtick/tilde fence families are neutralized before newline rehydration, preserving existing legitimate media
  • 125 full image/music/video owner tests + 139 unchanged internal-event/background siblings = 264 passing
  • 458 additional real production-path adversarial metadata/fence/filename combinations passed; focused actual repository test type-aware checking is clean
  • independent formal structured security review clean, confidence 0.88; production delta +41 lines justified by canonical cross-media security boundary and removal of duplicate image sanitizer

Actual loopback production provider + canonical outbound proof

The actual bundled OpenAI video provider executed 30 real authenticated loopback HTTP requests (POST /v1/videos, then GET /v1/videos/qa_video_118780/content?variant=video) across 15 malicious upstream-response cases. Credentials and endpoint were synthetic; no external paid/live provider was contacted.

Each response injected combinations of MEDIA:/tmp/..., Markdown images, reply redirects, voice/reaction tags, LF/CRLF/escaped newlines, bidi/control characters, and backtick/tilde fences. The real video_generate owner persisted the 32-byte download unchanged (SHA256 cce9c9fd7e9af77862cdae9a8aaeffd7608c16d0f3cc29063c9f3e497b80265b); the actual detached event formatter, reply parser, and canonical outbound planner then delivered exactly one intended original-byte attachment with zero forged attachments, reply redirects, voice conversions, or reactions in all 15 cases.

{"provider":"actual bundled OpenAI video adapter","transport":"real authenticated localhost HTTP","externalProviderCalled":false,"httpRequests":30,"adversarialProviderResponses":15,"intendedAttachmentsDelivered":15,"forgedAttachments":0,"replyHijacks":0,"voiceHijacks":0,"reactionHijacks":0,"failures":0}

The project-owner-authored PR explicitly accepts the disclosed absence of an external paid/live provider: real provider HTTP ingress, hostile upstream payloads, binary download, production persistence, detached delivery, and final outbound planning have all been exercised end to end.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 2:25 PM ET / 18:25 UTC.

ClawSweeper review

What this changes

Sanitizes provider-generated image, music, and video display text so it cannot create media, reply, reaction, voice, Markdown-image, or fence directives, while preserving exact structured attachment records.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR remains necessary: current main still formats provider-controlled media metadata directly into text that the reply parser can interpret as delivery directives. The proposed shared formatter is the appropriate owner boundary, its focused image/music/video coverage is coherent, and the updated loopback production-path evidence is sufficient; the protected maintainer label keeps the final merge decision with a maintainer.

Priority: P1
Reviewed head: bba95c0991079d9ba56ca4706927df10045e6585

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused canonical repair with strong cross-media regressions and credible after-fix production-path output; final approval remains with the protected maintainer workflow.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The updated PR body provides copied after-fix loopback output from the actual bundled video adapter through persistence, detached event formatting, reply parsing, and outbound planning across 15 adversarial cases; synthetic fixture URLs in the prepared manifest are not asserted as live proof artifacts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The updated PR body provides copied after-fix loopback output from the actual bundled video adapter through persistence, detached event formatting, reply parsing, and outbound planning across 15 adversarial cases; synthetic fixture URLs in the prepared manifest are not asserted as live proof artifacts.
Evidence reviewed 6 items Current vulnerable parsing path: Current main sends text through media extraction, reaction parsing, reply-tag parsing, and audio parsing; media directives are recognized from lines beginning with MEDIA: and inline directive tags are subsequently consumed.
Canonical repair boundary: The branch adds one shared formatter for provider-controlled display text and separately quotes attachment presentation fields, preserving the structured attachment values used for delivery.
Sibling media coverage: Image, music, and video owners use the shared formatter for provider/model and override presentation; music additionally preserves readable lyric lines while preventing them from opening directives or fences before trusted attachment lines.
Findings None None.
Security None None.

How this fits together

Image, music, and video generation tools receive provider results and produce both human-readable tool text and structured media attachments. Tool text can later pass through reply-directive parsing and outbound planning, while structured attachment paths and URLs identify the intended media independently.

flowchart LR
  A[Provider result] --> B[Media generation tool]
  B --> C[Generated-media display formatter]
  C --> D[Agent or internal-event text]
  D --> E[Reply directive parser]
  E --> F[Outbound delivery plan]
  B --> G[Structured attachment metadata]
  G --> F
Loading

Before merge

  • Resolve merge risk (P1) - This shared formatter intentionally changes displayed provider metadata and attachment presentation across all three media tools. The branch should merge only with the cross-path tests intact, because a later producer that bypasses the formatter could reintroduce directive interpretation after escaped-newline rehydration.
  • Complete next step (P2) - The patch has no actionable defect from this review and carries the protected maintainer label, so the remaining action is normal maintainer approval rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +41, Tests +169. Total +210 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 87 46 +41
Tests 3 177 8 +169
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 264 54 +210

Review metrics

Metric Value Why it matters
Production versus test delta production +41, tests +169 The net production growth creates a shared cross-media security boundary and removes the prior image-only sanitizer; the larger test delta exercises image, music, video, immediate delivery, and detached internal-event paths.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/tools/music-generate-tool.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Merge with the shared-boundary coverage (recommended)
    Approve the canonical formatter approach while preserving the immediate and detached delivery regressions that prove untrusted presentation cannot become outbound controls.
  2. Pause for a broader owner audit
    Hold the PR only if maintainers identify another generated-media producer that emits provider text outside the shared formatter, then add that caller to the same boundary test set.

Technical review

Best possible solution:

Keep one shared generated-media display sanitizer for untrusted provider presentation, retain exact structured attachment metadata for delivery, and land the focused image/music/video regression coverage after maintainer approval.

Do we have a high-confidence way to reproduce the issue?

Yes: current main routes generated text through parseReplyDirectives, whose media and inline-directive parsers can consume the injected syntaxes. The PR’s focused tests reproduce both immediate and detached internal-event parsing with adversarial provider fields.

Is this the best way to solve the issue?

Yes: placing sanitization in src/agents/generated-attachments.ts removes the prior image-only duplicate and gives image, music, and video one canonical presentation boundary while leaving structured delivery metadata untouched.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 05dc73bb35fd.

Labels

Label justifications:

  • P1: Provider-controlled output can otherwise alter media, reply, reaction, or voice delivery behavior in active agent workflows.
  • merge-risk: 🚨 message-delivery: The changed text is consumed by outbound directive parsing, so a missed escaping path could add, redirect, suppress, or transform delivered media.
  • merge-risk: 🚨 security-boundary: The patch establishes the trust boundary between untrusted provider presentation and executable delivery syntax.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The updated PR body provides copied after-fix loopback output from the actual bundled video adapter through persistence, detached event formatting, reply parsing, and outbound planning across 15 adversarial cases; synthetic fixture URLs in the prepared manifest are not asserted as live proof artifacts.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body provides copied after-fix loopback output from the actual bundled video adapter through persistence, detached event formatting, reply parsing, and outbound planning across 15 adversarial cases; synthetic fixture URLs in the prepared manifest are not asserted as live proof artifacts.

Evidence

What I checked:

  • Current vulnerable parsing path: Current main sends text through media extraction, reaction parsing, reply-tag parsing, and audio parsing; media directives are recognized from lines beginning with MEDIA: and inline directive tags are subsequently consumed. (src/auto-reply/reply/reply-directives.ts:78, 05dc73bb35fd)
  • Canonical repair boundary: The branch adds one shared formatter for provider-controlled display text and separately quotes attachment presentation fields, preserving the structured attachment values used for delivery. (src/agents/generated-attachments.ts:47, bba95c099107)
  • Sibling media coverage: Image, music, and video owners use the shared formatter for provider/model and override presentation; music additionally preserves readable lyric lines while preventing them from opening directives or fences before trusted attachment lines. (src/agents/tools/music-generate-tool.ts:487, bba95c099107)
  • Current main does not include the branch: The proposed commit is not an ancestor of the checked-out current main, so the central repair is neither implemented nor released from this branch. (bba95c099107)
  • Feature provenance: The shared attachment formatter on current main is attributed by blame to Peter Steinberger’s recent agents work; the proposed repair commit is also authored by Peter Steinberger and directly modifies that shared owner surface. (src/agents/generated-attachments.ts:46, 73535e4ede7e)
  • Real behavior evidence: The PR body records a 15-case authenticated localhost loopback through the bundled OpenAI video adapter, binary persistence, detached event formatting, reply parsing, and final outbound planning, reporting zero forged attachments, reply hijacks, voice hijacks, or reaction hijacks. Prepared downloadable URLs are deliberately synthetic fixture values and failed retrieval, so they do not weaken the copied runtime output in the PR body. (bba95c099107)

Likely related people:

  • steipete: Peter Steinberger authored the proposed boundary repair and is the current blame/history author for the shared generated-attachment formatter around the affected presentation logic. (role: shared formatter contributor and recent area contributor; confidence: high; commits: bba95c099107, 73535e4ede7e; files: src/agents/generated-attachments.ts, src/agents/tools/image-generate-tool.ts, src/agents/tools/music-generate-tool.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-03T17:10:24.262Z sha bba95c0 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 3, 2026
@steipete
steipete merged commit 1ed8241 into main Aug 3, 2026
146 of 162 checks passed
@steipete
steipete deleted the codex/qa0803-generated-media-directive-boundary branch August 3, 2026 20:39
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* commit 'efcced7207baa0b1b1db5e8e1836673a24212657':
  test(agents): prove process control roundtrip (#118843)
  test(qa): add memory redaction boundary coverage (#118916)
  fix(kilocode): model discovery overstates the usable context window (#118868)
  fix(media): isolate generated-provider text from delivery directives (#118780)
  test(gateway): add node control-plane QA coverage (#118784)
  fix(config): reject unsupported diagnostics otel grpc (#93087)
  fix(providers): recognize configured media credentials across provider boundaries (#118761)
  refactor: delete dead post-landing plugin/hooks scaffolding (#118920)
  fix(cron): deliver child results after heartbeat-only parent responses (#118743)
  fix(ci): keep Matrix chunk tests aligned with inventory (#118917)
  fix(tts): preserve hidden speech answers when synthesis fails (#118690)
vincentkoc added a commit that referenced this pull request Aug 3, 2026
…-worker-update-20260803

* origin/main: (48 commits)
  test(ui): add shell and PWA primary QA proof (#118788)
  test(qa): cover CLI distribution workflows (#118948)
  chore(i18n): refresh native locales (#118883)
  test(qa): prove plugin tool ownership in gateway flow (#118958)
  docs: correct onboarding risk flags and Google Chat credential shapes (#118936)
  fix(imessage): honor explicitly enabled accounts during startup (#118944)
  test(gateway): cover client transport defaults (#118798)
  fix(signal): normalize accounts during noninteractive setup (#118932)
  fix(msteams): enable channels for federated environment credentials (#118931)
  fix(openai): enforce final transcript bounds before callback delivery (#118928)
  test(tasks): cover plugin-managed flows (#118919)
  test(agents): prove process control roundtrip (#118843)
  test(qa): add memory redaction boundary coverage (#118916)
  fix(kilocode): model discovery overstates the usable context window (#118868)
  fix(media): isolate generated-provider text from delivery directives (#118780)
  test(gateway): add node control-plane QA coverage (#118784)
  fix(config): reject unsupported diagnostics otel grpc (#93087)
  fix(providers): recognize configured media credentials across provider boundaries (#118761)
  refactor: delete dead post-landing plugin/hooks scaffolding (#118920)
  fix(cron): deliver child results after heartbeat-only parent responses (#118743)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant