Skip to content

[Bug]: Telegram outbound rejects trusted generated HTML after staging strips trusted-root marker (PR #87982 missed e2e case) #90557

Closed

Description

@wangwllu

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After PR #87982 enabled trusted generated text/html for host-read outbound, Telegram delivery still drops the attachment because the staged copy under ~/.openclaw/media/outbound/<uuid>.html is no longer inside /tmp/openclaw/, so the second loadWebMedia call fails the isTrustedGeneratedHostReadHtmlPath root-check.

Steps to reproduce

  1. Run OpenClaw 2026.6.1 with a Telegram bot account configured.
  2. From an agent reply, emit an absolute MEDIA:/tmp/openclaw/<file>.html directive (file is a real generated HTML report, owned by the same uid as the gateway, mode 0644, nlink=1, valid UTF-8, doctype <!doctype html>).
  3. Observe gateway log: OutboundDeliveryError: hostReadCapability permits only validated plain-text documents and trusted generated HTML reports for local reads. No file is delivered.

I instrumented dist/web-media-B4RFpB_P.js (isTrustedGeneratedHostReadHtmlPath + the gate602 site) with console.error probes and confirmed the exact flow:

[HTMLDBG] isTrustedPath {
  filePath: "/tmp/openclaw/unread-fetch-report.html",
  resolvedFilePath: "/private/tmp/openclaw/unread-fetch-report.html",
  resolvedTmpRoot:  "/private/tmp/openclaw",
  inside: true
}
[HTMLDBG] gate602 { hostReadCapability: true, hostReadDeclaredMime: "text/html", trustedGeneratedHtmlPath: true }
[HTMLDBG] isTrustedHtml OK

# same outbound flow, second loadWebMedia call:
[HTMLDBG] isTrustedPath {
  filePath: "/Users/<user>/.openclaw/media/outbound/unread-fetch-report---<uuid>.html",
  resolvedFilePath: "/Users/<user>/.openclaw/media/outbound/unread-fetch-report---<uuid>.html",
  resolvedTmpRoot:  "/private/tmp/openclaw",
  inside: false
}
[HTMLDBG] gate602 { hostReadCapability: true, hostReadDeclaredMime: "text/html", trustedGeneratedHtmlPath: false }
→ throw OutboundDeliveryError: hostReadCapability permits only validated plain-text documents and trusted generated HTML reports

Expected behavior

Per PR #87982, a .html file whose realpath is inside /tmp/openclaw/ should be deliverable as a Telegram document. PDF works in the exact same surface (verified at 12:23 with a 1.34 MB PDF: operation=sendDocument deliveryKind=document). HTML should work analogously. The PR description even says "valid generated .html reports under the OpenClaw temp root load as text/html documents for host-read delivery" — which is true on the first call but the staging step then re-invokes loadWebMedia on the staged copy, which is not under the temp root.

Actual behavior

Telegram outbound is rejected with OutboundDeliveryError: hostReadCapability permits only validated plain-text documents and trusted generated HTML reports for local reads. No "Media failed" placeholder reaches the chat — the message is silently dropped. PDF/PNG attachments through the same code path succeed because they don't go through the text/html trusted-root branch at all.

Reproduced 4 times today across different filenames, permission modes (0600 / 0644), and gateway restarts; every attempt logs the same error at the same web-media.ts site.

OpenClaw version

2026.6.1 (commit 2e08f0f)

Operating system

macOS 26.4 (Darwin 25.4.0, arm64)

Install method

npm global

Model

claude-cli/Claude-Opus-4.7

Provider / routing chain

Direct Telegram Bot API (polling), bot @yoyo_li_bot

Additional provider/model setup details

Channel: telegram plugin built-in. No proxy on outbound (only inbound polling proxy).

Logs, screenshots, and evidence

Source: ~/Library/Logs/openclaw/gateway.log and /tmp/openclaw/openclaw-2026-06-05.log.

2026-06-05T13:06:35 [HTMLDBG] isTrustedPath inside=true   (original /tmp/openclaw/...html)
2026-06-05T13:06:35 [HTMLDBG] gate602 trustedGeneratedHtmlPath=true
2026-06-05T13:06:36 [HTMLDBG] isTrustedHtml OK
2026-06-05T13:06:37 [HTMLDBG] isTrustedPath inside=false  (staged ~/.openclaw/media/outbound/...html)
2026-06-05T13:06:37 [HTMLDBG] gate602 trustedGeneratedHtmlPath=false
2026-06-05T13:06:37 ERROR channels/telegram: OutboundDeliveryError: hostReadCapability permits only validated plain-text documents and trusted generated HTML reports for local reads

The contrast in the same trace is decisive: the first isTrustedPath evaluation passes; the second one (after staging) fails because resolvedFilePath no longer lives under resolvedTmpRoot=/private/tmp/openclaw.

Suspected fix region: either (a) resolveOutboundAttachmentFromUrl (or whichever staging step copies /tmp/openclaw/*.html to ~/.openclaw/media/outbound/) should preserve the trusted-root marker through the post-stage loadWebMedia, or (b) isTrustedGeneratedHostReadHtmlPath should also accept the ~/.openclaw/media/outbound/ staging root as trusted (with the same nlink/symlink guards).

PR #87982 explicitly notes: "What was not tested: live Telegram Bot API delivery". This issue is the missed e2e case.

Impact and severity

Affected channel: Telegram. Severity: blocks workflow (HTML attachments unsendable). Frequency: always. Workaround: render HTML to PDF via headless Chrome — PDF goes through HOST_READ_ALLOWED_DOCUMENT_MIMES and survives staging.

Additional information

Activity

  1. clawsweeper commented on Jun 5, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 7:40 AM ET / 11:40 UTC.

    Summary
    Keep open: current main and v2026.6.9 still trust generated host-read HTML only when the file being loaded is under the OpenClaw temp root, while the reported Telegram flow stages the file under media/outbound and reloads it there. The open closing PR at #90579 owns the repair path, so this issue should remain canonical until that PR or an equivalent fix lands.

    Reproducibility: yes. at source level. Current main stages local reply media into media/outbound and Telegram later reloads that staged .html through a host-read gate that only trusts temp-root realpaths; I did not run a live Telegram repro in this read-only review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90557
    Summary: This issue is the canonical user report; the open linked PR is the current fix candidate and the earlier merged PR is partial regression context.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    No new ClawSweeper fix PR should be queued because an open closing PR already owns this security-sensitive repair path.

    Security
    Needs attention: The issue is security-sensitive because the repair must allow staged generated HTML without trusting arbitrary staged or host-local HTML.

    Review details

    Best possible solution:

    Land #90579 or an equivalent provenance-preserving repair, then close this issue after the fix is merged and validated.

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

    Yes, at source level. Current main stages local reply media into media/outbound and Telegram later reloads that staged .html through a host-read gate that only trusts temp-root realpaths; I did not run a live Telegram repro in this read-only review.

    Is this the best way to solve the issue?

    Yes for keeping the issue open, but not for closing it yet. The best path is to review and land the linked PR or a focused replacement that preserves the trusted-HTML security boundary through staging.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The remaining fix changes a trusted local HTML host-read boundary, so it must preserve arbitrary host-local HTML rejection while carrying generated-HTML provenance through staging.
    • No live Telegram e2e was run in this read-only review; final merge confidence should come from the linked PR's security review plus Telegram-visible proof when feasible.

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

    Label changes

    Label justifications:

    • P1: The issue reports a released Telegram outbound regression that blocks generated HTML attachment delivery in a security-sensitive host-read path.
    • impact:security: The affected behavior is the trusted local HTML host-read gate that controls which HTML files may be read and delivered.
    • impact:message-loss: The reported failure drops the Telegram outbound attachment instead of delivering the generated report.
    Evidence reviewed

    Security concerns:

    • [medium] Preserve trusted HTML provenance through staging — src/media/web-media.ts:292
      A repair should not trust every .html file under the outbound media store; it needs to carry or revalidate the original generated-file trust decision so arbitrary staged host-local HTML remains blocked.
      Confidence: 0.9

    What I checked:

    • Current main trust gate: Current main requires the .html file's realpath to be inside resolvePreferredOpenClawTmpDir after regular-file, non-symlink, nlink=1 checks; it does not trust media/outbound staged paths. (src/media/web-media.ts:292, d1cbe29f3d52)
    • Current main rejection point: loadWebMedia computes trustedGeneratedHtmlPath from the current path and throws path-not-allowed for host-read text/html when that check is false. (src/media/web-media.ts:1023, d1cbe29f3d52)
    • Outbound staging drops provenance: resolveOutboundAttachmentFromUrl loads the original file and saves a copy into the outbound media store, returning only the staged path and content type with no trusted-HTML marker on main. (src/media/outbound-attachment.ts:16, d1cbe29f3d52)
    • Reply media path uses staged copy: The reply media normalizer calls resolveOutboundAttachmentFromUrl for likely local media and stores saved.path for later channel delivery, matching the reported first-load then staged-reload flow. (src/auto-reply/reply/reply-media-paths.ts:129, d1cbe29f3d52)
    • Telegram reloads media before send: Telegram outbound calls loadWebMedia on mediaUrl before constructing the Telegram InputFile, so a staged .html path hits the host-read HTML gate again. (extensions/telegram/src/send.ts:961, d1cbe29f3d52)
    • Current test coverage gap: Main tests cover trusted temp-root HTML and outside-root/symlink/hardlink rejection, while outbound attachment tests only cover filename preservation and buffer staging, not trusted HTML provenance through staging. (src/media/web-media.test.ts:667, d1cbe29f3d52)

    Likely related people:

    • steipete: Authored/merged the trusted generated HTML behavior in PR 87982 and authored earlier media staging/access commits that this issue crosses. (role: feature owner and recent media contributor; confidence: high; commits: 68d0c0f2f5c4, b43d73b633b4, 43ef8a5a8657; files: src/media/web-media.ts, src/media/outbound-attachment.ts, src/auto-reply/reply/reply-media-paths.ts)
    • wangwllu: Provided detailed live trace evidence and authored the open closing PR that targets this exact trust-through-staging failure. (role: reporter and active fix proposer; confidence: high; commits: 4d294fecc991; files: src/media/web-media.ts, src/media/outbound-attachment.ts, src/media/store.ts)
    • scoootscooob: Moved the Telegram channel implementation into extensions, including the send path that reloads staged media before delivery. (role: adjacent Telegram implementation contributor; confidence: medium; commits: e5bca0832fbd; files: extensions/telegram/src/send.ts, extensions/telegram/src/bot/delivery.replies.ts)
    How this review workflow works
    • 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.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.
    on Jun 5, 2026
  3. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 15, 2026
  4. locked as resolved and limited conversation to collaborators on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions