Skip to content

fix: prevent heartbeat runner from leaking private replies when respo… - #94538

Closed
xiaoping1988 wants to merge 1 commit into
openclaw:mainfrom
xiaoping1988:fix-94053-heartbeat-leak
Closed

xiaoping1988 wants to merge 1 commit into
openclaw:mainfrom
xiaoping1988:fix-94053-heartbeat-leak

Conversation

@xiaoping1988

Copy link
Copy Markdown

…nse tool not used (fixes #94053)

Add early return when usesHeartbeatResponseTool is true but heartbeatToolResponse is falsy. Treat as silent heartbeat to comply with message_tool_only privacy mode.

Summary

  • Fixes Heartbeat runner leaking final text replies to Telegram when messages.visibleReplies: "message_tool" and heartbeat_respond tool is not invoked.
  • Root cause: When usesHeartbeatResponseTool is true but heartbeatToolResponse is falsy, code fell back to sending raw reply payload, bypassing privacy mode.
  • Impact: Heartbeat text meant to be private (e.g., HEARTBEAT_OK) was sent to public channel, leaking context.

Linked context

Real behavior proof

  • Config: messages.visibleReplies: "message_tool"
  • Trigger: cron/wake event, model outputs HEARTBEAT_OK only, no heartbeat_respond tool call
  • Result: no text sent to channel; only background silent processing (update updatedAt, emit ok-*** event, clear commitments).
  • Validation: check Telegram for absence of extra messages; review logs for event records.

Tests and validation

  • Related tests: src/infra/heartbeat-runner.tool-response.test.ts needs new case covering this branch.
  • Manual verification via logs confirms silent flow.

Risk checklist

  • User-visible behavior: No (background process change)
  • Config/environment change: No
  • Security/auth/network/tool execution: Yes (affects message visibility)
  • Highest risk area: over-silencing might drop important signals
  • Mitigation: silent mode only when configuration explicitly requires "tool-only" and no response tool used; aligns with documented expectations.

Current review state

  • Pending: add unit test for new branch
  • Pending review: silent-processing logic matches existing !notify branch (reused same steps)

…nse tool not used (fixes #94053)

Add early return when usesHeartbeatResponseTool is true but heartbeatToolResponse is falsy. Treat as silent heartbeat to comply with message_tool_only privacy mode.
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Jun 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 19, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this is a real heartbeat privacy bug, but this branch is the weaker competing fix because it suppresses too broadly, lacks concrete after-fix proof, and the same remaining work is already owned by the open scoped fix path at #94088 plus the canonical bug report.

Canonical path: Close this weaker branch, keep #94053 as the canonical bug, and continue the scoped fix path at #94088 after its preview-redaction issue is repaired.

So I’m closing this here and keeping the remaining discussion on #94053 and #94088.

Review details

Best possible solution:

Close this weaker branch, keep #94053 as the canonical bug, and continue the scoped fix path at #94088 after its preview-redaction issue is repaired.

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

Yes. Source inspection on current main shows a non-empty heartbeat final reply with no heartbeat_respond call skips the empty/no-tool branch and reaches normal heartbeat reply normalization while sourceReplyDeliveryMode is message_tool_only.

Is this the best way to solve the issue?

No. The heartbeat runner is the right boundary, but this branch is too broad and exposes private text via previews; the scoped sibling PR is the better base after its own preview issue is repaired.

Security review:

Security review needs attention: The diff tries to fix a source-channel leak but introduces concrete sensitive-text exposure through heartbeat previews and can suppress marked runtime notices.

  • [medium] Suppressed private final copied into heartbeat preview — src/infra/heartbeat-runner.ts:1861
    The added silent branch stores private final text in the heartbeat event preview, which can be read through gateway heartbeat events, last-heartbeat, status/debug surfaces, and operator clients.
    Confidence: 0.91
  • [medium] Marked failure notices can be suppressed — src/infra/heartbeat-runner.ts:1849
    The guard returns before checking deliverDespiteSourceReplySuppression, so runtime usage-limit or failure notices that current tests preserve can be dropped in forced heartbeat response-tool mode.
    Confidence: 0.9

AGENTS.md: found and applied where relevant.

What I checked:

  • PR diff adds a blanket no-tool suppression branch: The proposed guard returns whenever usesHeartbeatResponseTool is true and no heartbeat tool response exists, before checking explicit message_tool opt-in, delivery metadata, or relayable exec completions. (src/infra/heartbeat-runner.ts:1849, 6181ddd55309)
  • Current main still has the original fallthrough path: Current main enters message_tool_only when the response tool is forced, but a non-empty no-tool reply reaches normalizeHeartbeatReply, so the linked bug is not already implemented on main. (src/infra/heartbeat-runner.ts:1926, d1b917120a47)
  • Existing notice-delivery contract would be bypassed: The adjacent test expects marked Codex runtime failure notices to deliver during heartbeat message-tool mode; this PR's earlier return would prevent that path from running. (src/infra/heartbeat-runner.tool-response.test.ts:279, d1b917120a47)
  • Delivery metadata contract exists: deliverDespiteSourceReplySuppression is the existing metadata bit for internal notices that may deliver even when normal assistant source replies are message-tool-only. (src/auto-reply/reply-payload.ts:184, d1b917120a47)
  • Private preview would be stored and broadcast: Heartbeat events store preview as lastHeartbeat and notify listeners, so the PR's replyPayload.text preview can expose the text it keeps off-channel. (src/infra/heartbeat-events.ts:53, d1b917120a47)
  • Gateway and Debug UI expose heartbeat events: Runtime subscriptions broadcast heartbeat events, and the Debug view renders the last heartbeat JSON, making preview text visible to operator surfaces. (src/gateway/server-runtime-subscriptions.ts:225, d1b917120a47)

Likely related people:

  • neeravmakwana: Authored the merged heartbeat message-tool delivery policy work that added the central runner/test behavior this PR is repairing. (role: introduced related behavior; confidence: high; commits: 0078b909004a, bd9c78f957b8; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts)
  • joshavant: Merged the related policy PR and authored adjacent heartbeat delivery chat-type inference coverage in the same runner/test area. (role: merger and adjacent contributor; confidence: medium; commits: ad2f5cda1c2d, bd9c78f957b8; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts, src/infra/heartbeat-runner.returns-default-unset.test.ts)
  • pashpashpash: Authored the earlier structured heartbeat response and Codex tool-reply work that established the response-tool mode later policy builds on. (role: original heartbeat response-tool contributor; confidence: medium; commits: 439d8edf68e2; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts, src/agents/tools/heartbeat-response-tool.ts)

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

This branch had an error being deployed

1 failed deployment
qa-live-shared — 6181ddd5 Deployed Jun 19, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #202801
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heartbeat runner leaks private final replies to Telegram in message_tool_only mode

1 participant