Skip to content

Gateway: harden cron.runs jobId path handling - #24038

Merged
Takhoffman merged 2 commits into
mainfrom
fix/cron-runs-path-safety
Feb 23, 2026
Merged

Takhoffman merged 2 commits into
mainfrom
fix/cron-runs-path-safety

Conversation

@Takhoffman

@Takhoffman Takhoffman commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: cron.runs accepted arbitrary non-empty id/jobId values and used them in run-log path resolution.
  • Why it matters: path separator segments (../, /, \\) could escape the intended runs/ directory scope.
  • What changed: tightened cron.runs schema validation, added defensive runtime job-id/path checks, and added regression tests.
  • What did NOT change (scope boundary): cron scheduling/execution semantics, cron job IDs in add/update/run/remove, and run log entry format.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #

User-visible / Behavior Changes

  • cron.runs now rejects id/jobId values containing path separators.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) Yes
  • If any Yes, explain risk + mitigation:
    • Mitigation: cron.runs access is constrained to canonical per-job run-log files under <cron-dir>/runs.

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node.js + Vitest
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): default local test config

Steps

  1. Validate cron.runs params with traversal-like IDs.
  2. Resolve run-log path for traversal-like job IDs.
  3. Run targeted tests.

Expected

  • Traversal-like id/jobId inputs are rejected.
  • Resolved run-log paths remain inside <cron-dir>/runs.

Actual

  • Implemented and verified.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: validateCronRunsParams rejects path separators; resolveCronRunLogPath throws on unsafe IDs.
  • Edge cases checked: both / and \\ separators, and .. traversal segments.
  • What you did not verify: full end-to-end websocket gateway flow.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes (for valid IDs)
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 347da47b3.
  • Files/config to restore: src/gateway/protocol/schema/cron.ts, src/cron/run-log.ts, src/gateway/server-methods/cron.ts.
  • Known bad symptoms reviewers should watch for: cron.runs rejecting unexpected legacy IDs containing path separators.

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: over-restricting accepted cron.runs identifiers could reject unusual legacy IDs.
    • Mitigation: restriction only blocks path separators; standard UUID-like IDs remain valid.

Greptile Summary

Hardened cron.runs API to prevent path traversal attacks by validating jobId parameters at both schema and runtime levels.

  • Added CronRunLogJobIdSchema with regex pattern ^[^/\\]+$ to reject path separators in cron.runs API params
  • Introduced assertSafeCronRunLogJobId() runtime check blocking /, \\, and null bytes
  • Added defense-in-depth validation ensuring resolved paths stay within <cron-dir>/runs/
  • Wrapped resolveCronRunLogPath() in try-catch in gateway handler to return proper error responses
  • Comprehensive test coverage for both schema validation and runtime path resolution

The fix correctly targets only the cron.runs API (read-only path) while leaving other cron operations unchanged, since internal job IDs are safely generated via crypto.randomUUID() and never contain path separators.

Confidence Score: 5/5

  • This PR is safe to merge with no security concerns
  • The implementation provides defense-in-depth with schema validation, runtime checks, and path resolution verification. Test coverage is thorough, covering both Unix and Windows path separators. The scope is appropriately limited to the vulnerable cron.runs endpoint while internal operations remain unchanged.
  • No files require special attention

Last reviewed commit: 347da47

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Feb 23, 2026
@Takhoffman
Takhoffman force-pushed the fix/cron-runs-path-safety branch from 347da47 to 6993183 Compare February 23, 2026 01:34
@Takhoffman
Takhoffman merged commit 259d863 into main Feb 23, 2026
15 checks passed
@Takhoffman
Takhoffman deleted the fix/cron-runs-path-safety branch February 23, 2026 01:35
@Takhoffman

Copy link
Copy Markdown
Contributor Author

PR #24038 - Gateway: harden cron.runs jobId path handling (#24038)

Merged via squash.

  • Merge commit: 259d863
  • Verified: pnpm install --frozen-lockfile, pnpm build, pnpm check, pnpm test:macmini
  • Changes made:
    M CHANGELOG.md
    M src/cron/run-log.test.ts
    M src/cron/run-log.ts
    M src/gateway/protocol/cron-validators.test.ts
    M src/gateway/protocol/schema/cron.ts
    M src/gateway/server-methods/cron.ts
  • Why these changes were made:
    Fixes a confirmed cron.runs path traversal scope issue by constraining run-log IDs and path resolution to the cron runs directory; also includes required changelog update for release visibility.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Thanks @Takhoffman!

carlosrivera pushed a commit to myascendai/meshiclaw that referenced this pull request Feb 23, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
gabrielkoo pushed a commit to gabrielkoo/openclaw that referenced this pull request Feb 23, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
xianfeng92 pushed a commit to xianfeng92/openclaw that referenced this pull request Feb 24, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
(cherry picked from commit 259d863)
speculatingwook pushed a commit to Pronto-Lab/prontoclaw that referenced this pull request Feb 24, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
(cherry picked from commit 259d863)
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
desertstackdev pushed a commit to desertstackdev/openclaw that referenced this pull request Feb 28, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…Takhoffman

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

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

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant