Skip to content

fix(cron): validate custom session ids#59835

Closed
eleqtrizit wants to merge 4 commits into
openclaw:mainfrom
eleqtrizit:fix/cron-session-target-validation
Closed

fix(cron): validate custom session ids#59835
eleqtrizit wants to merge 4 commits into
openclaw:mainfrom
eleqtrizit:fix/cron-session-target-validation

Conversation

@eleqtrizit

Copy link
Copy Markdown
Contributor

Summary

  • Reject invalid session:<id> cron targets that contain path separator characters or NULs
  • Reuse the same validation when resolving the isolated cron run sessionKey

Changes

  • Added a shared cron custom-session validator in src/cron/normalize.ts
  • Applied that validator during cron job normalization so invalid custom session targets fall back to default isolated behavior
  • Applied the same validator in the gateway cron runner so previously stored invalid jobs fall back to cron:<job-id>
  • Added regression coverage for create-time normalization and run-time fallback behavior

Validation

  • Ran corepack pnpm test -- src/cron/normalize.test.ts src/gateway/server.cron.test.ts
  • Verified invalid session:../../... values no longer survive normalization
  • Verified stored invalid session: targets do not override the cron-scoped fallback session key
  • Attempted local agentic review with claude -p "/review"; it requested interactive GitHub approval and returned no code findings in this environment

Notes

  • Scope is limited to custom cron session IDs; valid session:<id> inputs still behave as before
  • This also hardens previously persisted invalid jobs by failing closed at execution time

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Apr 2, 2026
@greptile-apps

greptile-apps Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens cron custom session ID handling by introducing normalizeCronCustomSessionId in src/cron/normalize.ts, which rejects path-separator characters and enforces SAFE_SESSION_ID_RE. The validator is applied at job-create time (invalid targets fall back to "isolated") and at run time (invalid stored targets fall back to cron:<job-id>). The run-time path also adds a fast-track for full agent-format session keys via parseAgentSessionKey before falling through to the custom-ID validator. Tests cover forward-slash, backslash, and NUL-byte rejection at both layers, and the integration test confirms the fallback session key used for malicious stored jobs.

Confidence Score: 5/5

Safe to merge — the fix is narrowly scoped, fails closed on invalid input, and all prior review concerns are addressed.

Both previous thread concerns (adding SAFE_SESSION_ID_RE enforcement and backslash/NUL test cases) are resolved in this diff. No new P0/P1 issues introduced. The two-path run-time logic (parseAgentSessionKey fast-track → normalizeCronCustomSessionId fallback → cron: default) is correct and covered by tests at both the unit and integration level.

No files require special attention.

Reviews (3): Last reviewed commit: "fix(cron): preserve colon-delimited sess..." | Re-trigger Greptile

Comment thread src/cron/normalize.ts
Comment thread src/cron/normalize.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41557fe2a5

ℹ️ 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".

Comment thread src/gateway/server-cron.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41557fe2a5

ℹ️ 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".

Comment thread src/cron/normalize.ts
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Apr 3, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c01bdd74fd

ℹ️ 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".

Comment thread src/cron/normalize.ts Outdated
@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e988192ec6

ℹ️ 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".

Comment thread src/cron/normalize.ts
@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 24, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

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

Keep open because the protected maintainer label prevents automatic cleanup, but the branch is substantively superseded by the merged opaque-session-target fix and is no longer a viable merge path.

Root-cause cluster
Relationship: superseded
Canonical: #86578
Summary: The merged opaque-session-target PR is the canonical resolution for the cron session-key validation problem, while this PR implements the older opposite stricter-validation shape.

Members:

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

Canonical path: Close this PR as superseded by #86578.

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

Review details

Best possible solution:

Close this PR as superseded by #86578.

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

Yes, source-level. The PR routes custom session:<id> values through separator and SAFE_SESSION_ID_RE validation, while current main tests accept slash/backslash-bearing opaque session keys and only reject NUL.

Is this the best way to solve the issue?

No. The best fix already landed in #86578: keep cron session targets as opaque runtime keys and enforce path safety at cron job-id/run-log boundaries.

Security review:

Security review cleared: No supply-chain changes were found; the functional risk is session-state compatibility, while current main keeps path safety at the cron run-log job-id boundary.

AGENTS.md: found and applied where relevant.

What I checked:

  • linked superseding PR: fix(cron): accept opaque session target keys #86578 (fix(cron): accept opaque session target keys) is merged at 2026-05-26T00:39:05Z.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • ferminquant: Authored the merged replacement that defines the current cron session-target contract as opaque non-empty/non-NUL routing keys. (role: recent area contributor; confidence: high; commits: c9364f03dcbb; files: src/cron/session-target.ts, src/cron/normalize.test.ts, src/cron/service.jobs.test.ts)
  • steipete: Introduced the earlier strict unsafe custom-session target guard that this PR follows and maintained adjacent cron/gateway behavior. (role: guard introducer and adjacent contributor; confidence: high; commits: 39bcf695dce4; files: src/cron/session-target.ts, src/cron/normalize.ts, src/cron/service/jobs.ts)
  • kkhomej33-netizen: Introduced custom cron session IDs and current-session auto-binding, which is the feature boundary affected by this PR. (role: feature introducer; confidence: high; commits: e7d9648fba27; files: src/cron/normalize.ts, src/cron/service/jobs.ts, docs/automation/cron-jobs.md)
  • mvanhorn: Recently hardened persisted cron job validation in the same sessionTarget load and support-spec path. (role: recent adjacent contributor; confidence: medium; commits: b33eb93aac8a; files: src/cron/service/jobs.ts, src/cron/service/store.ts)

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

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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant