Cron lifecycle guard: reject dangerous commands at job creation #778

Closed
opened 2026-10-27 13:37:42 +00:00 by sam · 0 comments
Owner

Slice 4 of the cron/scheduling epic (archie-core-1786637496320-249-be6d9a20). The epic's third acceptance criterion verbatim: 'Dangerous commands are rejected at creation time.'

Guards both runners from the previous slice: ChatCourier (whose body could include shell-shaped payloads) and WorkflowTask (whose shell-step is a documented footgun). Rejection happens at job creation, not at tick time, so a refused job is visible in the store with a refusal reason and never reaches the ticker engine.

Acceptance criteria

  • Rejects job specs whose target body includes any of: archied restart, systemctl, launchctl, pkill, mkfs, dd, shutdown, reboot.
  • Rejection reason is recorded on the refused job and surfaced through the gateway / dashboard; the job is not written to the store.
  • One named rejection function both the CLI and gateway paths call, so adding a new dangerous token does not require touching every UI surface.
  • False positives are deliberate — the list over-broadens then narrows by operator feedback. Cost of accepting a dangerous command vastly exceeds the cost of a refused one.

Close reason

Landed in 0a3ecf26. scheduling.RefuseDangerousJob (internal/domain/scheduling/guard.go) refuses a job whose Payload.Text names any of archied restart, systemctl, launchctl, pkill, mkfs, dd, shutdown, reboot, matched whole-word and case-insensitively. validateSchedules, the one validator every creation path reaches (dashboard/control-plane replace of the schedules document, config seed and ValidateStored), calls it first, so a refusal is a 400 carrying the reason - 'control-plane validation: scheduling: payload names a dangerous command: job "nightly" payload names "dd"' - which SchedulesPage.vue shows in its role=alert paragraph. Nothing is written to the store: Decode fails before PutResource. Criterion 3 is met by the single validator rather than by two call sites: the CLI creation path the epic's slices 3 and 6 assumed was never built (no CLI command references schedules; ReplaceSchedules has exactly one caller, the runner's MarkRun), so there is no second surface to call it from. The over-broad 'dd' is matched as a word, so 'added' and 'middleware' are accepted while 'sudo dd if=...' is refused. Test: internal/domain/scheduling/guard_test.go, table-driven, three accepted payloads and eight refusals. task check green on the committed tree. Follow-up filed: archie-core-3k3c (the validator parity fixture has no Go side).


Imported from beads archie-core-1786637496320-249-be6d9a20.4 · GitHub #677 · type feature · priority P2 · created 2026-08-27 · closed 2026-10-08

Slice 4 of the cron/scheduling epic (archie-core-1786637496320-249-be6d9a20). The epic's third acceptance criterion verbatim: 'Dangerous commands are rejected at creation time.' Guards both runners from the previous slice: ChatCourier (whose body could include shell-shaped payloads) and WorkflowTask (whose shell-step is a documented footgun). Rejection happens at job creation, not at tick time, so a refused job is visible in the store with a refusal reason and never reaches the ticker engine. ### Acceptance criteria - Rejects job specs whose target body includes any of: `archied` restart, `systemctl`, `launchctl`, `pkill`, `mkfs`, `dd`, `shutdown`, `reboot`. - Rejection reason is recorded on the refused job and surfaced through the gateway / dashboard; the job is not written to the store. - One named rejection function both the CLI and gateway paths call, so adding a new dangerous token does not require touching every UI surface. - False positives are deliberate — the list over-broadens then narrows by operator feedback. Cost of accepting a dangerous command vastly exceeds the cost of a refused one. ### Close reason Landed in 0a3ecf26. scheduling.RefuseDangerousJob (internal/domain/scheduling/guard.go) refuses a job whose Payload.Text names any of archied restart, systemctl, launchctl, pkill, mkfs, dd, shutdown, reboot, matched whole-word and case-insensitively. validateSchedules, the one validator every creation path reaches (dashboard/control-plane replace of the schedules document, config seed and ValidateStored), calls it first, so a refusal is a 400 carrying the reason - 'control-plane validation: scheduling: payload names a dangerous command: job "nightly" payload names "dd"' - which SchedulesPage.vue shows in its role=alert paragraph. Nothing is written to the store: Decode fails before PutResource. Criterion 3 is met by the single validator rather than by two call sites: the CLI creation path the epic's slices 3 and 6 assumed was never built (no CLI command references schedules; ReplaceSchedules has exactly one caller, the runner's MarkRun), so there is no second surface to call it from. The over-broad 'dd' is matched as a word, so 'added' and 'middleware' are accepted while 'sudo dd if=...' is refused. Test: internal/domain/scheduling/guard_test.go, table-driven, three accepted payloads and eight refusals. task check green on the committed tree. Follow-up filed: archie-core-3k3c (the validator parity fixture has no Go side). --- _Imported from beads `archie-core-1786637496320-249-be6d9a20.4` · GitHub #677 · type feature · priority P2 · created 2026-08-27 · closed 2026-10-08_
sam added the mediumfeature labels 2026-10-27 13:37:42 +00:00
sam self-assigned this 2026-10-27 13:37:42 +00:00
sam closed this issue 2026-10-27 13:37:42 +00:00
sam added a new dependency 2026-10-27 13:42:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#778