Skip to content

Route sensitive group commands to the owner privately - #73872

Merged
pashpashpash merged 3 commits into
mainfrom
codex/private-command-cross-channel-routing
Apr 29, 2026
Merged

pashpashpash merged 3 commits into
mainfrom
codex/private-command-cross-channel-routing

Conversation

@pashpashpash

@pashpashpash pashpashpash commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

This follows up on the diagnostics and trajectory export approval work. The previous behavior kept sensitive group commands private only when the originating surface could resolve a private owner route. That meant a Discord group invocation could fail even when the owner already had Telegram configured as their primary private interface.

This change makes the private route resolver match the expected owner ergonomics: try the same surface first, then fall back to the first available owner route from commands.ownerAllowFrom. The command handlers then use exactly that selected route for both the exec approval defaults and the final private reply, so group chats only get the short acknowledgement while the sensitive details land in the owner DM.

The resolver now also treats owner identity as a hard boundary, not just a ranking hint. Native approval clients may know about exec approvers who are not command owners, so those targets are filtered out before routing diagnostics or trajectory details.

The tests cover the ordering rule directly, the non-owner exec approver regression, and /diagnostics plus /export-trajectory using only the selected private target for approval/result delivery.

@aisle-research-bot

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

Copy link
Copy Markdown

🔒 Aisle Security Analysis

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

# Severity Title
1 🔵 Low Cross-channel owner identifier collision can misroute private owner-only command replies
1. 🔵 Cross-channel owner identifier collision can misroute private owner-only command replies
Property Value
Severity Low
CWE CWE-201
Location src/auto-reply/reply/commands-private-route.ts:144-157

Description

resolvePrivateCommandRouteTargets() now collects DM delivery targets from all loaded channel plugins and then filters/sorts them by whether the target matches an entry in commands.ownerAllowFrom.

In buildPrivateCommandRouteOwnerKeys(), each target is considered an owner match if any of these keys match an ownerAllowFrom entry:

  • the raw to value (e.g. "849985193")
  • user:${to}
  • ${channel}:${to} (and tg:${to} for Telegram)

Because commands.ownerAllowFrom explicitly supports unprefixed “channel-native IDs” (see config help text), an unqualified owner entry like "849985193" will match any channel target whose to equals that string, not just the intended channel.

This can cause private routing of sensitive owner-only outputs (e.g. /diagnostics, /export-trajectory, exec-approval prompts/results) to be delivered to the wrong channel/recipient in mixed-channel setups when identifier strings collide across providers.

Vulnerable code:

if (to) {
  keys.add(to);
  keys.add(`user:${to}`);
}

Recommendation

Tighten owner matching so it cannot cross channels unless the config entry is explicitly channel-qualified.

Recommended change:

  • Remove raw to and user:${to} keys from buildPrivateCommandRouteOwnerKeys().
  • Only match on ${channel}:${to} (and explicit aliases like tg:${to}), and update docs/tests to require channel prefixes for owner routing.

Example safer implementation:

function buildPrivateCommandRouteOwnerKeys(target: PrivateCommandRouteTarget): Set<string> {
  const channel = normalizeLowercaseStringOrEmpty(target.channel);
  const to = normalizeLowercaseStringOrEmpty(target.to);
  const keys = new Set<string>();
  if (channel && to) {
    keys.add(`${channel}:${to}`);
    if (channel === "telegram") keys.add(`tg:${to}`);
  }
  return keys;
}

If unprefixed owner IDs must remain supported for backward compatibility, scope them to a specific channel during matching (e.g., only treat an unprefixed owner entry as matching when target.channel === originChannel, or normalize ownerAllowFrom entries to add explicit channel prefixes at config-load time).


Analyzed PR: #73872 at commit 89c98e6

Last updated on: 2026-04-29T00:09:50Z

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord size: M maintainer Maintainer-authored PR labels Apr 28, 2026
@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors resolvePrivateCommandRouteTargets to iterate all loaded channel plugins (origin-first) instead of only the originating channel, then sorts gathered targets by same-surface preference followed by position in commands.ownerAllowFrom. Both /diagnostics and /export-trajectory handlers are updated to narrow to targets[0] before using the result for exec-approval defaults and private reply delivery, so group chats only receive the short acknowledgement.

Confidence Score: 5/5

This PR is safe to merge; the routing logic is well-tested and no correctness or security issues were identified.

All changed paths are covered by new and updated tests that exercise both the same-surface preference and the cross-surface fallback. The sorting is deterministic when ownerAllowFrom is configured (the documented requirement). Deduplication and seen-set channel enumeration are correct. No P0 or P1 findings.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(commands): route sensitive group app..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

Keep this PR open. It is member-authored and has the protected maintainer label, so this cleanup workflow should not auto-close it. Current main still lacks the PR’s cross-surface private owner-route fallback and selected-single-target delivery for sensitive group /diagnostics and /export-trajectory flows, and the PR diff still deserves maintainer/security review around owner route matching.

Best possible solution:

Keep this PR open for maintainer review. The likely path is to refine and land the focused resolver/handler changes after addressing the cross-channel owner identity matching question, so sensitive group /diagnostics and /export-trajectory choose exactly one private owner route, prefer same-surface owner DMs, fall back through commands.ownerAllowFrom, and keep non-owner exec approvers out of private diagnostics or trajectory delivery.

What I checked:

  • Protected maintainer signal: Provided GitHub context lists author association MEMBER and labels include maintainer; repository policy says maintainer-authored or protected-label items need explicit maintainer judgment, not automated close.
  • Current main only resolves the originating channel: resolvePrivateCommandRouteTargets loads getLoadedChannelPlugin(params.commandParams.command.channel) and resolves that one channel's native approver DM targets; it does not enumerate loaded channel plugins for fallback owner routes. (src/auto-reply/reply/commands-private-route.ts:23, fd2625a16252)
  • Diagnostics still sends to all resolved targets and keeps origin provider defaults: In group diagnostics, current main passes the full targets array to private delivery and sets exec approval messageProvider from the originating command channel, not from a selected private owner route. (src/auto-reply/reply/commands-diagnostics.ts:129, fd2625a16252)
  • Trajectory export still sends to all resolved targets and keeps origin provider defaults: In group trajectory export, current main delivers to the full targets array and sets exec approval messageProvider to params.command.channel; it does not narrow approval/result delivery to one selected private target. (src/auto-reply/reply/commands-export-trajectory.ts:87, fd2625a16252)
  • Docs do not yet describe the PR's cross-surface fallback: Current docs say group /diagnostics and /export-trajectory go to the owner privately, and Discord docs describe native approval DMs/channel fanout, but they do not document the PR's Discord-to-Telegram owner route fallback behavior. Public docs: docs/tools/slash-commands.md. (docs/tools/slash-commands.md:153, fd2625a16252)
  • PR diff is focused but security-sensitive: The PR diff touches changelog/docs, private route resolver code, diagnostics/trajectory command handlers, and tests; it does not change workflows, dependency sources, lockfiles, release scripts, package metadata, or generated/vendor/minified code. The resolver change is still security-sensitive because it broadens private routing across loaded channel plugins for sensitive command output. (89c98e691339)

Likely related people:

  • pashpashpash [email protected]: Current-main git history and blame tie this person to the private command route helper, group diagnostics/trajectory private-routing behavior, and recent Telegram owner-derived exec approval changes. This is current-main feature history, not merely PR authorship. (role: introduced behavior and recent maintainer; confidence: high; commits: 6ce1058296cc, 43fa40a35dc3; files: src/auto-reply/reply/commands-private-route.ts, src/auto-reply/reply/commands-diagnostics.ts, src/auto-reply/reply/commands-export-trajectory.ts)

Remaining risk / open question:

  • Closing this PR automatically would bypass the repository rule for member-authored and maintainer-labeled items.
  • Current main does not implement the PR's cross-surface fallback or selected-single-private-target delivery, so closing as implemented would drop an active fix candidate.
  • The PR broadens sensitive private routing across channel plugins; the diff still appears to allow bare owner IDs to match across channels, so maintainers should resolve or explicitly accept that security tradeoff before merge.
  • No tests were run because this review was constrained to read-only inspection.

Codex review notes: model gpt-5.5, reasoning high; reviewed against fd2625a16252.

@pashpashpash

Copy link
Copy Markdown
Contributor Author

Aisle was right here. I pushed 76afadf3dd to make owner routing a hard filter instead of a preference: resolvePrivateCommandRouteTargets now drops any native approval DM target that does not match commands.ownerAllowFrom before sorting. I also added a regression test where a same-surface non-owner exec approver is returned by the channel resolver and Telegram is the only configured owner route; the resolver selects only the Telegram owner route.

@pashpashpash

Copy link
Copy Markdown
Contributor Author

ClawSweeper’s routing-order open question is covered by the focused resolver tests: the new test registry registers multiple native approval-capable channel plugins, verifies same-surface owner DMs win even when another owner route is listed first, verifies fallback follows commands.ownerAllowFrom when the source surface has no private owner route, and now verifies same-surface non-owner exec approvers are filtered out entirely. Disabled/native-ineligible clients still go through the existing describeDeliveryCapabilities(...).enabled and supportsApproverDmSurface checks before any target is collected.

@openclaw-barnacle openclaw-barnacle Bot added the channel: telegram Channel integration: telegram label Apr 29, 2026
@pashpashpash

Copy link
Copy Markdown
Contributor Author

Added the explicit ergonomics regression coverage in 89c98e6913: Telegram now has a test showing commands.ownerAllowFrom alone makes the Telegram operator an approval client without channels.telegram.execApprovals.approvers, and the private-route test covers a Discord group diagnostics request falling back to that Telegram owner route. This pins the original “owner/operator should not configure a second approval client” path while keeping the Aisle owner-only boundary.

@pashpashpash
pashpashpash merged commit 4aa8da3 into main Apr 29, 2026
82 of 83 checks passed
@pashpashpash
pashpashpash deleted the codex/private-command-cross-channel-routing branch April 29, 2026 00:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(commands): route sensitive group approvals privately

* fix(commands): require owner private routes

* test(commands): cover owner-derived Telegram diagnostics routing
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(commands): route sensitive group approvals privately

* fix(commands): require owner private routes

* test(commands): cover owner-derived Telegram diagnostics routing
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix(commands): route sensitive group approvals privately

* fix(commands): require owner private routes

* test(commands): cover owner-derived Telegram diagnostics routing
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix(commands): route sensitive group approvals privately

* fix(commands): require owner private routes

* test(commands): cover owner-derived Telegram diagnostics routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: telegram Channel integration: telegram docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant