Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(cron): bound scheduled agent tool authority

Steven Enamakele3ece069ccb6
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
index 80a31d9988..e5681b152f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
@@ -545,6 +545,29 @@ impl SecurityGate for OpenHumanSecurityGate {
)));
};
+ // A scheduled prompt is data, not an open-ended approval for later
+ // actions. Keep cron agent turns within a read-only tool capability.
+ // This check precedes the shell shortcut and all approval settings,
+ // including installations where the approval gate is disabled.
+ if matches!(
+ crate::agent::turn_origin::current(),
+ Some(
+ crate::agent::turn_origin::AgentTurnOrigin::TrustedAutomation {
+ source: crate::agent::turn_origin::TrustedAutomationSource::Cron,
+ ..
+ }
+ )
+ ) && (call.tool_name == SHELL_TOOL
+ || tool.permission_level_with_args(&call.arguments) > PermissionLevel::ReadOnly
+ || tool.external_effect_with_args(&call.arguments))
+ {
+ return Ok(GateDecision::deny(format!(
+ "{} Scheduled agent turns may use read-only tools only; '{}' needs a live user action.",
+ crate::security::POLICY_DENIED_MARKER,
+ call.tool_name
+ )));
+ }
+
// 3. `shell` is the one tool whose arguments carry a classifiable
// command, and `gate_decision` already encodes the autonomy tier —
// at a finer grain than the tool's coarse `Execute` permission
diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.md
index 7d7255360d..278976a48c 100644
--- a/crates/openhuman-core/src/cron/README.md
+++ b/crates/openhuman-core/src/cron/README.md
@@ -186,8 +186,12 @@ The session target shapes the prompt:
Trust follows the origin. A job with a channel origin runs under
`AgentTurnOrigin::ExternalChannel { message_id: "cron:<job>:<run>" }`, so its
external-effect tools stay gated the way its creator's were. Web-origin and
-origin-less jobs run as `TrustedAutomation { source: Cron }`, which the approval
-gate treats as user-authorized. Creating a job skips the approval gate only when
+origin-less jobs run as `TrustedAutomation { source: Cron }`. This grants the
+saved agent prompt read-only tool use and delivery to the job's configured
+destination. It does not grant shell, network, write, or cron mutation tools;
+those calls are denied on every run, including when approval prompts are
+globally disabled. A shell job runs its approved, stored command directly;
+this limit applies to agent tool calls. Creating a job skips the approval gate only when
`origin::is_self_scoped_agent_job` holds: the turn is a channel conversation,
the job is an agent job with no shell `command`, and its delivery resolves to
that same conversation (no `delivery`, `origin`, or a matching `announce`).
diff --git a/crates/openhuman-core/src/security/approval/README.md b/crates/openhuman-core/src/security/approval/README.md
index 7983e651eb..62a9abc935 100644
--- a/crates/openhuman-core/src/security/approval/README.md
+++ b/crates/openhuman-core/src/security/approval/README.md
@@ -6,7 +6,7 @@ Interactive approval workflow for supervised mode (issue #1339). `ApprovalGate`
- Intercept external-effect tool calls and gate them behind explicit user consent.
- Short-circuit to `Allow` when the tool is on the user's `autonomy.auto_approve` allowlist (read live via `security::live_policy`).
-- Allow through (never park) when there is no live chat context: background/triage/cron turns carry no `ApprovalChatContext` and are pre-authorized.
+- Cron agent turns may use read-only tools and the job's configured delivery. Their external-effect calls are denied, including schedule mutation. Other automation follows its origin-specific gate policy.
- Persist pending requests in SQLite so they survive a core restart; lazily expire stale rows; keep a durable decided/executed audit trail.
- Resolve a parked call on a user decision (`approve_once` / `approve_always_for_tool` / `deny`), TTL timeout, or channel drop, failing closed in every non-approve path.
- Redact arguments (`redact_args`) and build safe action summaries (`summarize_action`) before anything leaves the gate.
diff --git a/crates/openhuman-core/src/security/approval/gate_intercept.rs b/crates/openhuman-core/src/security/approval/gate_intercept.rs
index 5d07530977..988aa3e956 100644
--- a/crates/openhuman-core/src/security/approval/gate_intercept.rs
+++ b/crates/openhuman-core/src/security/approval/gate_intercept.rs
@@ -50,12 +50,32 @@ impl ApprovalGate {
// `AgentTurnOrigin` around `run_turn`. Unlabelled callers map to
// `Unknown`, which is denied — the gate refuses to execute an
// external_effect tool from an unlabelled call site.
+ let origin = turn_origin::current().unwrap_or(AgentTurnOrigin::Unknown);
+ // Approval of job creation grants the scheduler permission to run the
+ // saved prompt and deliver its answer, not permission for arbitrary
+ // future external effects. Enforce this before global auto-approval,
+ // per-tool allowlists, and per-agent approval bypasses.
+ if matches!(
+ &origin,
+ AgentTurnOrigin::TrustedAutomation {
+ source: TrustedAutomationSource::Cron,
+ ..
+ }
+ ) {
+ return (
+ GateOutcome::Deny {
+ reason: format!(
+ "{POLICY_DENIED_MARKER} Scheduled agent turns cannot use '{tool_name}' for an external effect."
+ ),
+ },
+ None,
+ );
+ }
// SaaS has no per-user approval surface: never park, allow only what
// the deployment's sandboxed tool groups open.
if let Some(outcome) = saas_outcome_with(crate::core::runtime::is_saas(), tool_name) {
return (outcome, None);
}
- let origin = turn_origin::current().unwrap_or(AgentTurnOrigin::Unknown);
if forced
&& !matches!(
&origin,
@@ -303,14 +323,16 @@ impl ApprovalGate {
}
AgentTurnOrigin::TrustedAutomation {
source: TrustedAutomationSource::Cron,
- job_id,
+ ..
} => {
- tracing::debug!(
- tool = tool_name,
- job_id = %job_id,
- "[approval::gate] trusted cron automation — allowing without prompt"
+ return (
+ GateOutcome::Deny {
+ reason: format!(
+ "{POLICY_DENIED_MARKER} Scheduled agent turns cannot use '{tool_name}' for an external effect."
+ ),
+ },
+ None,
);
- return (GateOutcome::Allow, None);
}
AgentTurnOrigin::TrustedAutomation {
source: TrustedAutomationSource::Background,
diff --git a/crates/openhuman-core/src/skills/runtime/run_machinery.rs b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
index 3635063628..3dd6817a8f 100644
--- a/crates/openhuman-core/src/skills/runtime/run_machinery.rs
+++ b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
@@ -150,7 +150,7 @@ pub async fn spawn_workflow_run_background(
// immediately. Same flow handle_skills_run used to inline — extracted
// so the `run_workflow` agent tool can re-use it for skill chaining.
let inherited_origin = crate::agent::turn_origin::current()
- .unwrap_or(crate::agent::turn_origin::AgentTurnOrigin::Cli);
+ .unwrap_or(crate::agent::turn_origin::AgentTurnOrigin::Unknown);
{
let run_id = run_id.clone();
let workflow_id = workflow_id.clone();