Skip to content

fix(auto-reply): allow voice-reply payloads through silent turns - #73406

Closed
zqchris wants to merge 2 commits into
openclaw:mainfrom
zqchris:fix/auto-reply-voice-silent
Closed

zqchris wants to merge 2 commits into
openclaw:mainfrom
zqchris:fix/auto-reply-voice-silent

Conversation

@zqchris

@zqchris zqchris commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

buildReplyPayloads currently drops all tagged reply payloads when silentExpected is true:

const silentFilteredPayloads = params.silentExpected ? [] : replyTaggedPayloads;

This is too aggressive when an agent uses NO_REPLY as its text reply but also produced a voice message (audioAsVoice: true from a TTS voice provider). The voice should still be delivered — silent is meant to suppress the text portion, not the agent's voice itself.

Real symptom: a Telegram voice delivery on a NO_REPLY turn loses its audio; the user only ever hears voice replies that come with non-NO_REPLY text. The same drop affects every channel that honors audioAsVoice.

Fix

Keep audioAsVoice: true payloads on silent turns. Plain media (regular images, documents, non-voice audio) still drops, matching the existing "silent = deliver nothing" semantic.

const silentFilteredPayloads = params.silentExpected
  ? replyTaggedPayloads.filter((p) => p.audioAsVoice === true)
  : replyTaggedPayloads;

Test plan

  • pnpm test src/auto-reply/reply/agent-runner-payloads.test.ts — 26/26 (was 25, +1 covering audioAsVoice survives silent turn while plain media still drops)
  • pnpm check:changed clean
  • Reviewer note: existing test at line ~374 ("drops all final payloads during silent turns, including media-only payloads") is not changed — its sample payload has no audioAsVoice: true, so it correctly still drops. The new test exercises the orthogonal case.

Chris Zhang added 2 commits April 28, 2026 15:58
When an agent uses NO_REPLY as its text reply but also produced a
voice message (audioAsVoice=true from TTS), the voice should still
be delivered — silent suppresses the text portion, not the voice
reply itself.

Triggered by Telegram voice delivery losing audio on NO_REPLY turns;
fix is generic and affects all channels that honor audioAsVoice.

Regular media (plain images, documents, non-voice audio) is still
dropped on silent turns to match the upstream semantic
"silent = deliver nothing".
@aisle-research-bot

aisle-research-bot Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 2 potential security issue(s) in this PR:

# Severity Title
1 🟠 High Silent-turn suppression bypass allows voice (audioAsVoice) payloads to be delivered
2 🟡 Medium Silent-turn media suppression bypass via agent-controlled audioAsVoice flag
1. 🟠 Silent-turn suppression bypass allows voice (audioAsVoice) payloads to be delivered
Property Value
Severity High
CWE CWE-359
Location src/auto-reply/reply/agent-runner-payloads.ts:168-177

Description

buildReplyPayloads previously enforced a strict "silentExpected => deliver nothing" behavior by dropping all final payloads. The change now forwards payloads with audioAsVoice === true even when silentExpected is set.

This is risky because silentExpected is used for non-user-facing runs (e.g., memory compaction/flush) where no outbound content should be delivered. Allowing any payload type through (even voice) can:

  • Leak internal/system content (memory flush prompts/results) to the end user if the run produces/attaches a TTS voice payload
  • Break the implicit contract that silent runs never produce outbound messages

Example security-relevant call site:

  • agent-runner-memory.ts invokes runEmbeddedPiAgent({ silentExpected: true, trigger: "memory", ... }) to perform memory flushing/compaction. Those runs should not emit user-visible messages; this change would allow voice payloads to bypass suppression if they are generated.

Vulnerable code:

const silentFilteredPayloads = params.silentExpected
  ? replyTaggedPayloads.filter((p) => p.audioAsVoice === true)
  : replyTaggedPayloads;

Recommendation

Preserve the strict meaning of silentExpected (deliver nothing), and introduce a separate, narrowly-scoped flag for the desired behavior (e.g., allowVoiceOnSilentNoReply) that is only set for user-facing turns where policy explicitly allows it.

For example:

export async function buildReplyPayloads(params: {
  ​// ...
  silentExpected?: boolean;
  allowVoiceOnSilentNoReply?: boolean;
}) {
  const silentFilteredPayloads = params.silentExpected
    ? (params.allowVoiceOnSilentNoReply
        ? replyTaggedPayloads.filter((p) => p.audioAsVoice === true)
        : [])
    : replyTaggedPayloads;
}

Additionally:

  • Ensure internal triggers like trigger: "memory", "cron", "heartbeat" never set allowVoiceOnSilentNoReply.
  • Add regression tests covering that silentExpected: true still drops all payloads for internal runs.
2. 🟡 Silent-turn media suppression bypass via agent-controlled audioAsVoice flag
Property Value
Severity Medium
CWE CWE-285
Location src/auto-reply/reply/agent-runner-payloads.ts:168-177

Description

buildReplyPayloads now allows payloads through silent turns when audioAsVoice === true. However, audioAsVoice can be set by agent-controlled output (either directly on the ReplyPayload object or via the [[audio_as_voice]] inline directive parsed from text), and it is not validated to ensure the attached mediaUrl is actually a voice/TTS audio asset.

As a result:

  • During silentExpected turns (where the semantic expectation is “deliver nothing”), an agent can still deliver arbitrary media by marking the payload as audioAsVoice: true and including a mediaUrl.
  • This bypass can be triggered even without structured payload control by emitting [[audio_as_voice]] in plain text, since parseReplyDirectives propagates it into payload.audioAsVoice.

Vulnerable code (silent filter trusts the flag):

const silentFilteredPayloads = params.silentExpected
  ? replyTaggedPayloads.filter((p) => p.audioAsVoice === true)
  : replyTaggedPayloads;

Why agent control is plausible:

  • normalizeReplyPayloadDirectives sets audioAsVoice from either payload.audioAsVoice or parsed directives:
    • audioAsVoice: Boolean(params.payload.audioAsVoice || parsed?.audioAsVoice)
  • parsed?.audioAsVoice originates from splitMediaFromOutput which sets it solely based on presence of [[audio_as_voice]], independent of media type.

Impact depends on what “silentExpected” is used for upstream (e.g., policy/permission enforcement, safety gating, user opt-out). If it is relied on for safety/privacy, this becomes a policy bypass.

Recommendation

Do not rely on an agent-controlled boolean to bypass silent suppression.

Recommended hardening (choose one):

  1. Derive/attest voice replies server-side: only set audioAsVoice on payloads produced by the trusted TTS pipeline (e.g., where trustedLocalMedia === true and/or a signed/attested origin is present), and ignore/clear audioAsVoice from agent-provided payloads/directives.

  2. Validate that media is actually a voice payload before allowing through silent. For example:

const isTrustedVoicePayload = (p: ReplyPayload) =>
  p.audioAsVoice === true &&
  p.trustedLocalMedia === true &&
  typeof p.mediaUrl === "string" &&
  ​/\.(opus|ogg|mp3|m4a|wav)$/i.test(p.mediaUrl);

const silentFilteredPayloads = params.silentExpected
  ? replyTaggedPayloads.filter(isTrustedVoicePayload)
  : replyTaggedPayloads;

Also consider disallowing [[audio_as_voice]] directive (or stripping it) in untrusted agent text, or gating it behind an allowlist of agent IDs/capabilities.


Analyzed PR: #73406 at commit 45fff4f

Last updated on: 2026-04-28T08:03:30Z

@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes an over-aggressive silent-turn filter that dropped all reply payloads when silentExpected is true — including audioAsVoice: true voice messages from TTS providers. The one-line change and accompanying test are correct: only payloads explicitly flagged as voice replies are allowed through, while all other media (images, documents, non-voice audio) continues to be suppressed on silent turns.

Confidence Score: 5/5

Safe to merge — targeted single-line logic fix with a new test covering the exact scenario.

The change is minimal and well-scoped: one filter predicate replaces a blanket empty-array assignment. The new test directly validates the fixed behaviour, and the pre-existing test for plain media (no audioAsVoice) still passes unchanged, confirming the existing 'silent = deliver nothing' semantic is preserved for all other payload types. No P0/P1 issues found.

No files require special attention.

Reviews (1): Last reviewed commit: "docs(changelog): note auto-reply voice t..." | Re-trigger Greptile

@steipete

Copy link
Copy Markdown
Contributor

Thanks @zqchris. This is now landed on main in 28bf71d. I kept the intended behavior but tightened the guard so silent turns preserve audioAsVoice only when the payload also has sendable media, and added regression coverage for both the voice-media path and the empty-marker case. Closing this PR as superseded by the landed commit.

@steipete steipete closed this Apr 28, 2026
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 2, 2026
…penclaw#73241, openclaw#73400

Second hardening pass after the first round triggered new findings on
Aisle's re-scan. PR openclaw#73406 (auto-reply voice silent) was meanwhile
landed by the maintainer in upstream commit 28bf71d — that one will
drop out at the next rebase via patch-id match, no source change here.

PR openclaw#73241 (BB http hardening) — 1 HIGH + 2 MEDIUM:

- monitor-processing.sanitizeForLog: redact common secret-bearing
  patterns (`?password=`, `?token=`, `?api_key=`, `?secret=`,
  `Authorization: Bearer / Basic …`) before the value reaches the log
  sink. BlueBubbles uses query-string auth by default, so attachment
  download failures and similar errors can carry the API password in
  the captured request URL (CWE-532).
- history.fetchBlueBubblesMessageByGuid: validate the derived bareGuid
  (length ≤128, charset `[A-Za-z0-9._:-]+`, non-empty) before issuing
  the request. A trailing `/` would otherwise produce an empty bareGuid
  and turn the call into an unintended `/api/v1/message/` collection
  query (CWE-20).
- monitor-processing reply-context verbose logs: log only `bodyLen=`
  metadata, not the quoted message text itself. Verbose logs are
  retained / shipped to aggregators and would otherwise leak private
  chat content (CWE-532).

PR openclaw#73235 (BB routing guards) — 1 MEDIUM + 2 LOW:

- monitor-reply-cache.resolveBlueBubblesMessageId: when
  `requireKnownShortId=true` and `chatContext` lacks any identifier,
  throw "requires a chat scope" instead of resolving the short id.
  Short ids are allocated from a single global counter across every
  account and chat, so an action call without chat scope could
  silently apply to the wrong conversation (CWE-285). Test updated to
  expect fail-closed (was previously fail-open with a comment that
  acknowledged the risk).
- monitor-reply-cache.buildCrossChatError: replace raw inputId in the
  thrown error message with `<short:N-digit>` or `<uuid:prefix…>`
  shape descriptors. Combined with the earlier chatGuid redaction,
  cross-chat errors now leak no concrete identifier (CWE-117 /
  CWE-200). The Low PII finding on monitor-processing verbose logs is
  resolved automatically by the sanitizeForLog redaction extension
  added for PR openclaw#73241 openclaw#1.

PR openclaw#73400 (silent-reply 🧵) — 1 MEDIUM:

- silent-reply-policy.classifySilentReplyConversationType: classify
  a session key as `internal` only when `parseThreadSessionSuffix`
  returns a real `🧵<id>` suffix, not on a free-form `🧵`
  substring match. Caller-supplied session keys can no longer embed
  the marker mid-string to force the conversation type to `internal`
  and bypass silent-reply rewrites (CWE-840).
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 4, 2026
…penclaw#73241, openclaw#73400

Second hardening pass after the first round triggered new findings on
Aisle's re-scan. PR openclaw#73406 (auto-reply voice silent) was meanwhile
landed by the maintainer in upstream commit 28bf71d — that one will
drop out at the next rebase via patch-id match, no source change here.

PR openclaw#73241 (BB http hardening) — 1 HIGH + 2 MEDIUM:

- monitor-processing.sanitizeForLog: redact common secret-bearing
  patterns (`?password=`, `?token=`, `?api_key=`, `?secret=`,
  `Authorization: Bearer / Basic …`) before the value reaches the log
  sink. BlueBubbles uses query-string auth by default, so attachment
  download failures and similar errors can carry the API password in
  the captured request URL (CWE-532).
- history.fetchBlueBubblesMessageByGuid: validate the derived bareGuid
  (length ≤128, charset `[A-Za-z0-9._:-]+`, non-empty) before issuing
  the request. A trailing `/` would otherwise produce an empty bareGuid
  and turn the call into an unintended `/api/v1/message/` collection
  query (CWE-20).
- monitor-processing reply-context verbose logs: log only `bodyLen=`
  metadata, not the quoted message text itself. Verbose logs are
  retained / shipped to aggregators and would otherwise leak private
  chat content (CWE-532).

PR openclaw#73235 (BB routing guards) — 1 MEDIUM + 2 LOW:

- monitor-reply-cache.resolveBlueBubblesMessageId: when
  `requireKnownShortId=true` and `chatContext` lacks any identifier,
  throw "requires a chat scope" instead of resolving the short id.
  Short ids are allocated from a single global counter across every
  account and chat, so an action call without chat scope could
  silently apply to the wrong conversation (CWE-285). Test updated to
  expect fail-closed (was previously fail-open with a comment that
  acknowledged the risk).
- monitor-reply-cache.buildCrossChatError: replace raw inputId in the
  thrown error message with `<short:N-digit>` or `<uuid:prefix…>`
  shape descriptors. Combined with the earlier chatGuid redaction,
  cross-chat errors now leak no concrete identifier (CWE-117 /
  CWE-200). The Low PII finding on monitor-processing verbose logs is
  resolved automatically by the sanitizeForLog redaction extension
  added for PR openclaw#73241 openclaw#1.

PR openclaw#73400 (silent-reply 🧵) — 1 MEDIUM:

- silent-reply-policy.classifySilentReplyConversationType: classify
  a session key as `internal` only when `parseThreadSessionSuffix`
  returns a real `🧵<id>` suffix, not on a free-form `🧵`
  substring match. Caller-supplied session keys can no longer embed
  the marker mid-string to force the conversation type to `internal`
  and bypass silent-reply rewrites (CWE-840).
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 5, 2026
…penclaw#73241, openclaw#73400

Second hardening pass after the first round triggered new findings on
Aisle's re-scan. PR openclaw#73406 (auto-reply voice silent) was meanwhile
landed by the maintainer in upstream commit 28bf71d — that one will
drop out at the next rebase via patch-id match, no source change here.

PR openclaw#73241 (BB http hardening) — 1 HIGH + 2 MEDIUM:

- monitor-processing.sanitizeForLog: redact common secret-bearing
  patterns (`?password=`, `?token=`, `?api_key=`, `?secret=`,
  `Authorization: Bearer / Basic …`) before the value reaches the log
  sink. BlueBubbles uses query-string auth by default, so attachment
  download failures and similar errors can carry the API password in
  the captured request URL (CWE-532).
- history.fetchBlueBubblesMessageByGuid: validate the derived bareGuid
  (length ≤128, charset `[A-Za-z0-9._:-]+`, non-empty) before issuing
  the request. A trailing `/` would otherwise produce an empty bareGuid
  and turn the call into an unintended `/api/v1/message/` collection
  query (CWE-20).
- monitor-processing reply-context verbose logs: log only `bodyLen=`
  metadata, not the quoted message text itself. Verbose logs are
  retained / shipped to aggregators and would otherwise leak private
  chat content (CWE-532).

PR openclaw#73235 (BB routing guards) — 1 MEDIUM + 2 LOW:

- monitor-reply-cache.resolveBlueBubblesMessageId: when
  `requireKnownShortId=true` and `chatContext` lacks any identifier,
  throw "requires a chat scope" instead of resolving the short id.
  Short ids are allocated from a single global counter across every
  account and chat, so an action call without chat scope could
  silently apply to the wrong conversation (CWE-285). Test updated to
  expect fail-closed (was previously fail-open with a comment that
  acknowledged the risk).
- monitor-reply-cache.buildCrossChatError: replace raw inputId in the
  thrown error message with `<short:N-digit>` or `<uuid:prefix…>`
  shape descriptors. Combined with the earlier chatGuid redaction,
  cross-chat errors now leak no concrete identifier (CWE-117 /
  CWE-200). The Low PII finding on monitor-processing verbose logs is
  resolved automatically by the sanitizeForLog redaction extension
  added for PR openclaw#73241 openclaw#1.

PR openclaw#73400 (silent-reply 🧵) — 1 MEDIUM:

- silent-reply-policy.classifySilentReplyConversationType: classify
  a session key as `internal` only when `parseThreadSessionSuffix`
  returns a real `🧵<id>` suffix, not on a free-form `🧵`
  substring match. Caller-supplied session keys can no longer embed
  the marker mid-string to force the conversation type to `internal`
  and bypass silent-reply rewrites (CWE-840).
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 5, 2026
…penclaw#73241, openclaw#73400

Second hardening pass after the first round triggered new findings on
Aisle's re-scan. PR openclaw#73406 (auto-reply voice silent) was meanwhile
landed by the maintainer in upstream commit 28bf71d — that one will
drop out at the next rebase via patch-id match, no source change here.

PR openclaw#73241 (BB http hardening) — 1 HIGH + 2 MEDIUM:

- monitor-processing.sanitizeForLog: redact common secret-bearing
  patterns (`?password=`, `?token=`, `?api_key=`, `?secret=`,
  `Authorization: Bearer / Basic …`) before the value reaches the log
  sink. BlueBubbles uses query-string auth by default, so attachment
  download failures and similar errors can carry the API password in
  the captured request URL (CWE-532).
- history.fetchBlueBubblesMessageByGuid: validate the derived bareGuid
  (length ≤128, charset `[A-Za-z0-9._:-]+`, non-empty) before issuing
  the request. A trailing `/` would otherwise produce an empty bareGuid
  and turn the call into an unintended `/api/v1/message/` collection
  query (CWE-20).
- monitor-processing reply-context verbose logs: log only `bodyLen=`
  metadata, not the quoted message text itself. Verbose logs are
  retained / shipped to aggregators and would otherwise leak private
  chat content (CWE-532).

PR openclaw#73235 (BB routing guards) — 1 MEDIUM + 2 LOW:

- monitor-reply-cache.resolveBlueBubblesMessageId: when
  `requireKnownShortId=true` and `chatContext` lacks any identifier,
  throw "requires a chat scope" instead of resolving the short id.
  Short ids are allocated from a single global counter across every
  account and chat, so an action call without chat scope could
  silently apply to the wrong conversation (CWE-285). Test updated to
  expect fail-closed (was previously fail-open with a comment that
  acknowledged the risk).
- monitor-reply-cache.buildCrossChatError: replace raw inputId in the
  thrown error message with `<short:N-digit>` or `<uuid:prefix…>`
  shape descriptors. Combined with the earlier chatGuid redaction,
  cross-chat errors now leak no concrete identifier (CWE-117 /
  CWE-200). The Low PII finding on monitor-processing verbose logs is
  resolved automatically by the sanitizeForLog redaction extension
  added for PR openclaw#73241 openclaw#1.

PR openclaw#73400 (silent-reply 🧵) — 1 MEDIUM:

- silent-reply-policy.classifySilentReplyConversationType: classify
  a session key as `internal` only when `parseThreadSessionSuffix`
  returns a real `🧵<id>` suffix, not on a free-form `🧵`
  substring match. Caller-supplied session keys can no longer embed
  the marker mid-string to force the conversation type to `internal`
  and bypass silent-reply rewrites (CWE-840).
zqchris pushed a commit to zqchris/openclaw that referenced this pull request May 15, 2026
…penclaw#73241, openclaw#73400

Second hardening pass after the first round triggered new findings on
Aisle's re-scan. PR openclaw#73406 (auto-reply voice silent) was meanwhile
landed by the maintainer in upstream commit 28bf71d — that one will
drop out at the next rebase via patch-id match, no source change here.

PR openclaw#73241 (BB http hardening) — 1 HIGH + 2 MEDIUM:

- monitor-processing.sanitizeForLog: redact common secret-bearing
  patterns (`?password=`, `?token=`, `?api_key=`, `?secret=`,
  `Authorization: Bearer / Basic …`) before the value reaches the log
  sink. BlueBubbles uses query-string auth by default, so attachment
  download failures and similar errors can carry the API password in
  the captured request URL (CWE-532).
- history.fetchBlueBubblesMessageByGuid: validate the derived bareGuid
  (length ≤128, charset `[A-Za-z0-9._:-]+`, non-empty) before issuing
  the request. A trailing `/` would otherwise produce an empty bareGuid
  and turn the call into an unintended `/api/v1/message/` collection
  query (CWE-20).
- monitor-processing reply-context verbose logs: log only `bodyLen=`
  metadata, not the quoted message text itself. Verbose logs are
  retained / shipped to aggregators and would otherwise leak private
  chat content (CWE-532).

PR openclaw#73235 (BB routing guards) — 1 MEDIUM + 2 LOW:

- monitor-reply-cache.resolveBlueBubblesMessageId: when
  `requireKnownShortId=true` and `chatContext` lacks any identifier,
  throw "requires a chat scope" instead of resolving the short id.
  Short ids are allocated from a single global counter across every
  account and chat, so an action call without chat scope could
  silently apply to the wrong conversation (CWE-285). Test updated to
  expect fail-closed (was previously fail-open with a comment that
  acknowledged the risk).
- monitor-reply-cache.buildCrossChatError: replace raw inputId in the
  thrown error message with `<short:N-digit>` or `<uuid:prefix…>`
  shape descriptors. Combined with the earlier chatGuid redaction,
  cross-chat errors now leak no concrete identifier (CWE-117 /
  CWE-200). The Low PII finding on monitor-processing verbose logs is
  resolved automatically by the sanitizeForLog redaction extension
  added for PR openclaw#73241 openclaw#1.

PR openclaw#73400 (silent-reply 🧵) — 1 MEDIUM:

- silent-reply-policy.classifySilentReplyConversationType: classify
  a session key as `internal` only when `parseThreadSessionSuffix`
  returns a real `🧵<id>` suffix, not on a free-form `🧵`
  substring match. Caller-supplied session keys can no longer embed
  the marker mid-string to force the conversation type to `internal`
  and bypass silent-reply rewrites (CWE-840).
@zqchris
zqchris deleted the fix/auto-reply-voice-silent branch May 17, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants