Skip to content

Normalize agent hook system event trust handling#64372

Merged
drobison00 merged 2 commits into
openclaw:mainfrom
eleqtrizit:fix/hooks-agent-untrusted
Apr 10, 2026
Merged

Normalize agent hook system event trust handling#64372
drobison00 merged 2 commits into
openclaw:mainfrom
eleqtrizit:fix/hooks-agent-untrusted

Conversation

@eleqtrizit

Copy link
Copy Markdown
Contributor

Summary

  • normalizes agent hook system-event handling with the same untrusted treatment already used by related hook and node paths
  • sanitizes hook display names before they are reused in cron metadata and session events

Changes

  • update src/gateway/server/hooks.ts to sanitize agent hook names before composing system event text
  • mark agent hook non-delivery and error system events with trusted: false
  • add focused regression coverage for the agent-hook success and error enqueue paths

Validation

  • ran corepack pnpm install
  • ran corepack pnpm test src/gateway/server/hooks.agent-trust.test.ts
  • ran corepack pnpm test src/gateway/server.hooks.test.ts
  • ran claude -p "/review" and addressed the review outcome before opening this PR

Notes

  • incorporates the same narrow remediation pattern already used for related untrusted system-event paths
  • includes co-author credit for prior relevant work reviewed from the GHSA private fork

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Apr 10, 2026
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR closes two security gaps in dispatchAgentHook: (1) value.name was used verbatim in CronJob metadata and system-event text, allowing a hook caller to inject System: prefixes or bracketed tags; (2) non-delivery and error enqueueSystemEvent calls were missing trusted: false, unlike the already-fixed dispatchWakeHook path. The fix applies sanitizeInboundSystemTags to the name before it is reused and adds the missing trust flag, with focused regression tests for both paths.

Confidence Score: 5/5

Safe to merge — narrowly scoped security fix consistent with existing patterns, well-tested, no regressions expected.

Both changes (sanitization and trust-flag) are correct, minimal, and aligned with the already-fixed dispatchWakeHook path. sanitizeInboundSystemTags handles the relevant injection patterns; trusted?: boolean is a valid SystemEventOptions field; value.name is always a non-null string by the time it reaches dispatchAgentHook. Tests cover the two new behaviors and use vi.waitFor appropriately for the async IIFE. No unresolved P0/P1 findings.

No files require special attention.

Reviews (2): Last reviewed commit: "fix(hooks): sanitize agent hook system e..." | Re-trigger Greptile

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@codex review

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@greptile review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@drobison00
drobison00 force-pushed the fix/hooks-agent-untrusted branch from 8e68e91 to 22e3a07 Compare April 10, 2026 18:45
@drobison00
drobison00 force-pushed the fix/hooks-agent-untrusted branch from 22e3a07 to 00ef0be Compare April 10, 2026 18:54
@drobison00
drobison00 merged commit e3a845b into openclaw:main Apr 10, 2026
8 checks passed
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(hooks): sanitize agent hook system events

Co-authored-by: zsx <[email protected]>

* chore(changelog): add agent hook trust normalization entry

---------

Co-authored-by: zsx <[email protected]>
Co-authored-by: Devin Robison <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(hooks): sanitize agent hook system events

Co-authored-by: zsx <[email protected]>

* chore(changelog): add agent hook trust normalization entry

---------

Co-authored-by: zsx <[email protected]>
Co-authored-by: Devin Robison <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
* fix(hooks): sanitize agent hook system events

Co-authored-by: zsx <[email protected]>

* chore(changelog): add agent hook trust normalization entry

---------

Co-authored-by: zsx <[email protected]>
Co-authored-by: Devin Robison <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(hooks): sanitize agent hook system events

Co-authored-by: zsx <[email protected]>

* chore(changelog): add agent hook trust normalization entry

---------

Co-authored-by: zsx <[email protected]>
Co-authored-by: Devin Robison <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(hooks): sanitize agent hook system events

Co-authored-by: zsx <[email protected]>

* chore(changelog): add agent hook trust normalization entry

---------

Co-authored-by: zsx <[email protected]>
Co-authored-by: Devin Robison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants