Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6b03e4e
chore(vendor): bump tiny submodules to latest commits
senamakel Nov 3, 2026
c314f6a
chore(vendor): restore submodule pins to main
senamakel Nov 3, 2026
869413c
feat(config): add security mode config section
senamakel Nov 3, 2026
f9f4090
chore(config): re-export security mode types
senamakel Nov 3, 2026
594b161
feat(security): add switch module
senamakel Nov 3, 2026
c81a102
refactor(security): route boot prompt-screen logging through switch c…
senamakel Nov 3, 2026
9a9f06d
fix(security): skip prompt and tool scans when security is disabled
senamakel Nov 3, 2026
eb87010
feat(security): bypass module gate when security is disabled
senamakel Nov 3, 2026
a43a0a0
feat(security): bypass path policy when security is disabled
senamakel Nov 3, 2026
2e07a71
fix(security): honour the global security switch in policy checks
senamakel Nov 3, 2026
9dad25a
fix(security-gate): honor disabled security switch in authorization
senamakel Nov 3, 2026
3b83f08
fix(security): skip module checks when security is disabled
senamakel Nov 3, 2026
99dadc8
fix(security): allow non-forced tool calls when security is disabled
senamakel Nov 3, 2026
f725a89
fix(security): skip argument serialization when security is disabled
senamakel Nov 3, 2026
011a9b9
fix(composio): skip redaction when security is disabled
senamakel Nov 3, 2026
3f5807e
feat(security): bypass redaction when security is disabled
senamakel Nov 3, 2026
ce1bfb7
feat(sandbox): run commands without a spawn plan when security is dis…
senamakel Nov 3, 2026
8c8fe68
refactor(sandbox): destructure resolved sandbox in exec dispatch
senamakel Nov 3, 2026
3220664
fix(mcp): bypass path denials when security is disabled
senamakel Nov 3, 2026
a04b78e
fix(mcp): skip tool scanning when security is disabled
senamakel Nov 3, 2026
5eaf451
fix(security): allow artifact paths when security is disabled
senamakel Nov 3, 2026
355172e
test(prompt_injection): cover security-off and module-disabled paths
senamakel Nov 3, 2026
8030e1d
test(prompt_injection): qualify enforce_prompt_input via super
senamakel Nov 3, 2026
2eb9e63
test(policy): cover security-disabled policy gates
senamakel Nov 3, 2026
9d72de2
test(security-gate): cover tool authorization when security is disabled
senamakel Nov 3, 2026
0ef389a
fix(security): permit control-plane egress under local-only when secu…
senamakel Nov 3, 2026
83695a7
test(security): cover audit recording when the security module is absent
senamakel Nov 3, 2026
1d13659
test(security): cover pass-through when security is disabled
senamakel Nov 3, 2026
d2ef3ff
test(util): cover loopback host classification
senamakel Nov 3, 2026
ebf14ae
feat(security): add disabled approval engine for security-off gates
senamakel Nov 3, 2026
5c5b598
test(approval): cover disabled engine approval and forced-call paths
senamakel Nov 3, 2026
fe0e039
test(sandbox): cover unchecked backend resolution
senamakel Nov 3, 2026
e3b9e0c
feat(embed): add security mode knob to runtime builder
senamakel Nov 3, 2026
db53215
docs(embed): clarify prompt screen enforcement semantics
senamakel Nov 3, 2026
f81e27c
docs(embed): document security mode test coverage
senamakel Nov 3, 2026
ac04947
chore(ci): register security switch statics in process-statics
senamakel Nov 3, 2026
8ca6d25
docs(security): document the security switch and disabled-mode behaviour
senamakel Nov 3, 2026
f76a3f1
chore(security): apply rustfmt formatting across security modules
senamakel Nov 3, 2026
705fcf2
docs(embed): refresh builder setter line references in api index
senamakel Nov 3, 2026
9f3ef73
test(security): gate fail-closed tests behind security-module feature
senamakel Nov 3, 2026
14e3f26
test(tinyagents): cover loopback endpoint classification without secu…
senamakel Nov 3, 2026
77f9341
test(tinyagents): reformat self-hosted provider assertion
senamakel Nov 3, 2026
50cd3de
test(security): gate fail-closed tests on the security module feature
senamakel Nov 3, 2026
af152c1
test(security-gate): gate message import behind security-module feature
senamakel Nov 3, 2026
b34c925
fix(mcp): remove needless borrow in security client call
senamakel Nov 4, 2026
7c524f4
refactor(embed): reuse computed security_enforced flag in info
senamakel Nov 4, 2026
af71301
fix(embed): report security enforcement status in runtime info
senamakel Nov 4, 2026
244e945
feat(sandbox): skip TinySecurity floor when security is disabled
senamakel Nov 4, 2026
5616538
refactor(security): remove the disabled approval engine
senamakel Nov 4, 2026
ff27fb8
docs(security): clarify approval gate behaviour when security is disa…
senamakel Nov 4, 2026
5e0ed58
fix(sandbox): keep the configured backend when security is disabled
senamakel Nov 4, 2026
8da022d
feat(security): report and apply the builder's own security mode
senamakel Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ With the policy **disabled** (the default):
`~/.aws`) and system roots stay unreachable. So do `..` traversal and null
bytes in a path. Keep that floor.

The floor is TinySecurity's. With **security disabled**
(`security/switch.rs`: a build without `security-module`, or `[security] mode
= "off"`) no TinySecurity check runs: paths resolve on the host with no floor
(the `..` and null-byte preflight stays), and tool calls are not classified.
`[privacy] mode = "local_only"` and approvals a channel or flow demands still
apply.

With `[autonomy] enabled = true`:

- `action_dir` is the agent's permitted read and write root — and is granted as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ async fn an_action_dir_inside_workspace_dir_is_never_materialized() {
.await;
}

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn explicit_workspace_policy_blocks_unguarded_offload_before_writing() {
let dir = tempfile::tempdir().expect("tempdir");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ impl ArtifactPathPolicy for WorkspaceGuard {
/// Artifact materialization reserves the complete private workspace, beyond the
/// general acting-tool policy's named internal subdirectories. Ask the native
/// engine to resolve aliases and prospective parents before any blob is stored.
/// With security disabled (`crate::security::switch`) nothing is reserved and
/// every path is allowed.
pub(super) async fn materialization_allowed(policy: &SecurityPolicy, path: &Path) -> bool {
if crate::security::switch::disabled().is_some() {
return true;
}
#[cfg(feature = "security-module")]
{
use tinysecurity_bus::{PathCheckKind, PathReservation};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::*;

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[test]
fn redactor_withholds_body_when_tinysecurity_is_unavailable() {
let out = SanitizingRedactor.redact("ordinary prose with no secrets");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ impl OpenHumanSecurityGate {
// Disabled autonomy turns off action classification, approval and
// budget policy. The channel boundary, known-tool requirement,
// scheduled-turn restriction and, for shell, TinySecurity's protected
// path floor above remain in force.
if !policy.enabled {
// path floor above remain in force. Disabled security
// (`crate::security::switch`) skips the same stages: there is no
// module to classify the action or keep the budget.
if policy.unchecked() {
return Ok(self.settled(channel_approved));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use super::*;
#[cfg(feature = "security-module")]
use tinyinference_llm::message::Message;

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn injection_payloads_are_blocked_from_every_origin() {
let gate = gate(AutonomyLevel::Full);
Expand Down Expand Up @@ -149,6 +153,9 @@ async fn channel_approval_does_not_bypass_the_readonly_tier() {
/// The tier still governs a tool the channel allows outright, which is the
/// control for the test above: the denial there must come from the tier,
/// not from the channel verdict.
// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn the_readonly_tier_refuses_an_acting_tool_the_channel_allowed() {
let decision = OpenHumanSecurityGate::new(policy(AutonomyLevel::ReadOnly), registry())
Expand Down Expand Up @@ -179,6 +186,9 @@ async fn allow_and_deny_channel_verdicts_are_unchanged() {
}

/// Input is held when the shared TinySecurity scanner is unavailable.
// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn screen_input_fails_closed_when_tinysecurity_is_unavailable() {
let gate = gate(AutonomyLevel::Full);
Expand All @@ -202,6 +212,9 @@ async fn screen_input_fails_closed_when_tinysecurity_is_unavailable() {
assert_eq!(untrusted, ScreenOutcome::Pass);
}

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn screening_holds_the_new_user_row_when_tinysecurity_is_unavailable() {
let gate = gate(AutonomyLevel::Full);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ async fn cron_headless_settlement_does_not_allow_effectful_spawn_aliases() {
);
}

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[tokio::test]
async fn read_only_autonomy_denies_an_acting_tool() {
let decision = gate(AutonomyLevel::ReadOnly)
Expand Down Expand Up @@ -331,3 +334,60 @@ async fn shell_authorization_ignores_stale_facts_and_uses_request_command() {

#[path = "security_gate_screen_and_policy_tests.rs"]
mod screen_and_policy;

// -- security disabled (`crate::security::switch`) -----------------

/// What an enabled-autonomy gate decides for an acting tool and a shell command.
async fn acting_decisions() -> (GateDecision, GateDecision) {
let policy = Arc::new(SecurityPolicy {
enabled: true,
autonomy: AutonomyLevel::Supervised,
..SecurityPolicy::default()
});
let gate = OpenHumanSecurityGate::new(policy, registry());
let write = gate
.authorize_tool(&req("write_file", json!({ "path": "notes.md" })))
.await
.unwrap();
let shell = gate
.authorize_tool(&req(SHELL_TOOL, json!({ "command": "rm -rf build" })))
.await
.unwrap();
(write, shell)
}

#[cfg(not(feature = "security-module"))]
#[tokio::test]
async fn a_build_without_the_module_authorizes_tools_without_classifying_them() {
let (write, shell) = acting_decisions().await;
assert_eq!(write, GateDecision::Allow);
assert_eq!(shell, GateDecision::Allow);
}

#[cfg(feature = "security-module")]
#[tokio::test]
async fn security_configured_off_authorizes_tools_without_classifying_them() {
let _off = crate::security::switch::off_for_this_thread();
let (write, shell) = acting_decisions().await;
assert_eq!(write, GateDecision::Allow);
assert_eq!(shell, GateDecision::Allow);
}

#[cfg(feature = "security-module")]
#[tokio::test]
async fn an_enforcing_gate_denies_a_tool_the_module_cannot_classify() {
use crate::core::runtime::{CoreContext, DomainSet};
let temp = tempfile::tempdir().unwrap();
let mut config = crate::credentials::test_support::plaintext_fixture_config(temp.path());
config.modules.enabled = false;
let context = CoreContext::for_test_with_config(DomainSet::full(), config);
let (write, _) = CoreContext::scope(context, acting_decisions()).await;
assert!(!write.is_allowed());
assert!(
write
.denial_reason()
.expect("a Deny carries a reason")
.contains(tinytools::status::POLICY_BLOCKED_MARKER),
"{write:?}"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ use tinyagents_harness::middleware::{
/// The token is removed before scrubbing and put back afterwards, so it is
/// never seen by (or counted against) the scrubber.
fn scrub_with_notice_for_tool(_tool_name: &str, content: &str) -> Option<(String, usize)> {
// Security disabled: no redactor, so the result reaches the model as is.
if crate::security::switch::disabled().is_some() {
return None;
}
#[cfg(feature = "security-module")]
let mode = if _tool_name == "browser"
&& serde_json::from_str::<serde_json::Value>(content)
Expand Down Expand Up @@ -63,6 +67,6 @@ pub(crate) fn credential_scrub_middleware() -> CredentialScrubMiddleware {
CredentialScrubMiddleware::with_scrubber(scrubber)
}

#[cfg(all(test, feature = "security-module"))]
#[cfg(test)]
#[path = "credential_scrub_tests.rs"]
mod tests;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use super::*;

#[cfg(feature = "security-module")]
#[tokio::test(flavor = "multi_thread")]
#[ignore = "downloads and loads the pinned native TinySecurity release"]
async fn native_credentials_only_and_browser_result_adapter() {
Expand Down Expand Up @@ -61,9 +62,30 @@ async fn native_credentials_only_and_browser_result_adapter() {
}
}

#[cfg(feature = "security-module")]
fn fixture_parts(case: &serde_json::Value, parts: &str, fallback: &str) -> String {
case[parts]
.as_array()
.map(|values| values.iter().map(|value| value.as_str().unwrap()).collect())
.unwrap_or_else(|| case[fallback].as_str().unwrap().to_owned())
}

/// With security disabled a tool result reaches the model as is.
fn assert_results_pass_through() {
assert!(scrub_with_notice_for_tool("read_file", "password=hunter2secret").is_none());
let pending = r#"{"status":"NeedsConfirmation","pending":{"token":"00000000-0000-4000-8000-000000000123"}}"#;
assert!(scrub_with_notice_for_tool("browser", pending).is_none());
}

#[cfg(not(feature = "security-module"))]
#[test]
fn a_build_without_the_module_leaves_tool_results_unscrubbed() {
assert_results_pass_through();
}

#[cfg(feature = "security-module")]
#[test]
fn security_configured_off_leaves_tool_results_unscrubbed() {
let _off = crate::security::switch::off_for_this_thread();
assert_results_pass_through();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::*;

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[test]
fn policy_denial_keeps_its_class_when_error_details_are_withheld() {
let policy = HostFailurePolicy::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ fn hosted_openai_is_not_treated_as_self_hosted() {
));
}

// Fails closed only while security is enforced: a build without the
// security module has security disabled (`crate::security::switch`).
#[cfg(feature = "security-module")]
#[test]
fn local_runtimes_are_self_hosted_and_endpoint_classification_fails_closed() {
assert!(provider_is_self_hosted("ollama:llama3", None));
Expand Down Expand Up @@ -167,3 +170,37 @@ fn a_dead_call_is_retried_at_the_same_cap_without_reasoning_and_new_calls_keep_i
);
}
}

/// With security disabled the endpoint is classified on the host: a loopback
/// endpoint is self-hosted, a LAN one is not.
fn assert_endpoints_classified_by_loopback() {
assert!(provider_is_self_hosted(
"llamacpp:m",
Some("http://127.0.0.1:8080/v1")
));
assert!(provider_is_self_hosted(
"vllm:m",
Some("http://0.0.0.0:8000/v1")
));
assert!(!provider_is_self_hosted(
"vllm:m",
Some("http://192.168.1.20:8000/v1")
));
assert!(provider_is_self_hosted(
"openai",
Some("http://localhost:8080/v1")
));
}

#[cfg(not(feature = "security-module"))]
#[test]
fn a_build_without_the_module_classifies_local_endpoints_by_loopback() {
assert_endpoints_classified_by_loopback();
}

#[cfg(feature = "security-module")]
#[test]
fn security_configured_off_classifies_local_endpoints_by_loopback() {
let _off = crate::security::switch::off_for_this_thread();
assert_endpoints_classified_by_loopback();
}
1 change: 1 addition & 0 deletions crates/openhuman-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub use schema::{
pub use schema::RequiredOutputContract;
pub use schema::SummarizerSettings;
pub use schema::{InboundDebounceConfig, InboundDebounceOverride};
pub use schema::{SecurityMode, SecurityModeConfig};
pub use schemas::{
all_controller_schemas as all_config_controller_schemas,
all_registered_controllers as all_config_registered_controllers,
Expand Down
3 changes: 2 additions & 1 deletion crates/openhuman-core/src/config/schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ is mounted as a submodule of [`load/dirs.rs`](./load/dirs.rs) via `#[path]`.
| `[modules]` | [`modules.rs`](./modules.rs) | `ModulesConfig`, `ModuleOverride`: controls only whether compiled-in modules load. The loadable *set* is fixed by `crate::modules::registry` |
| `[observability]` | [`observability.rs`](./observability.rs) | `ObservabilityConfig`, `AgentTracingConfig` |
| `[privacy]` | [`privacy.rs`](./privacy.rs) | `PrivacyConfig`, `PrivacyMode` |
| `[prompt_screen]` | [`prompt_screen.rs`](./prompt_screen.rs) | `PromptScreenConfig`, `PromptScreenMode` (TinySecurity prompt screen; `off` is an explicit opt-out, default enforces and fails closed) |
| `[prompt_screen]` | [`prompt_screen.rs`](./prompt_screen.rs) | `PromptScreenConfig`, `PromptScreenMode` (TinySecurity prompt screen; `off` is an explicit opt-out, default enforces and fails closed; `[security] mode = "off"` also turns it off) |
| `[security]` | [`security_mode.rs`](./security_mode.rs) | `SecurityModeConfig`, `SecurityMode` (whether TinySecurity-delegated checks run; `off` allows them and passes redaction through, default enforces and fails closed). Not the daemon's `SecurityConfig` in `security.rs` |
| `[proxy]` | [`proxy.rs`](./proxy.rs) | `ProxyConfig`, `ProxyScope`, plus `runtime_proxy_config()` / `set_runtime_proxy_config()` process-wide accessors |
| `[[model_routes]]`, `[[embedding_routes]]` | [`routes.rs`](./routes.rs) | `ModelRouteConfig`, `EmbeddingRouteConfig` |
| `[runtime]` (+ `[runtime.docker]`), `[shell]`, `[reliability]`, `[scheduler]` | [`runtime.rs`](./runtime.rs) | `RuntimeConfig`, `DockerRuntimeConfig`, `ShellConfig`, `ReliabilityConfig`, `SchedulerConfig` |
Expand Down
2 changes: 2 additions & 0 deletions crates/openhuman-core/src/config/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ mod runtime;
mod runtime_local_jail;
mod runtime_openshell;
mod scheduler_gate;
mod security_mode;
mod task_sources;
mod tokenjuice;
mod tools;
Expand Down Expand Up @@ -157,6 +158,7 @@ pub use scheduler_gate::{PauseReason, Policy, SchedulerGateConfig, SchedulerGate
pub use security::{
AuditConfig, ResourceLimitsConfig, SandboxBackend, SandboxConfig, SecurityConfig,
};
pub use security_mode::{SecurityMode, SecurityModeConfig};
pub use task_sources::TaskSourcesConfig;
pub use tinychannels_bus::config::{
ChannelsConfig, DingTalkConfig, DiscordConfig, EmailConfig, IMessageConfig, IrcConfig,
Expand Down
63 changes: 63 additions & 0 deletions crates/openhuman-core/src/config/schema/security_mode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//! Security mode configuration: whether the checks OpenHuman delegates to
//! TinySecurity run at all (`[security]`).
//!
//! With the default [`SecurityMode::Enforce`] every delegated check (the
//! prompt screen, action classification and approvals, path checks, the action
//! budget, egress privacy checks, redaction and the audit trail) asks the
//! module and fails closed whenever it cannot answer: not loaded, erroring or
//! slow. A host that runs its own controls, or that ships without the module,
//! turns them off with [`SecurityMode::Off`]; the checks then allow and
//! redaction passes content through unchanged. A build without the
//! `security-module` feature behaves as `off` whatever this says, because there
//! is no module to ask (`crate::security::switch`).
//!
//! This is not the daemon's [`SecurityConfig`](super::SecurityConfig), which
//! configures sandboxing, resource limits and the audit sink.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Whether the TinySecurity-delegated checks run.
///
/// Serializes as snake_case (`enforce` / `off`). A config missing the
/// `[security]` block, or its `mode` key, deserializes to
/// [`SecurityMode::Enforce`]. Any other value is a parse error.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SecurityMode {
/// Ask TinySecurity, refusing whatever it cannot confirm.
#[default]
Enforce,
/// Do not ask: every delegated check allows, and redaction passes content
/// through. Implies `[prompt_screen] mode = "off"`.
Off,
}

/// The `[security]` config block.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct SecurityModeConfig {
/// Whether the checks run. Missing key → [`SecurityMode::Enforce`].
pub mode: SecurityMode,
}

impl SecurityModeConfig {
/// The checks turned off: [`SecurityMode::Off`].
#[must_use]
pub fn off() -> Self {
Self {
mode: SecurityMode::Off,
}
}

/// Whether the checks run. False only when the config says
/// [`SecurityMode::Off`].
#[must_use]
pub fn enforces(&self) -> bool {
self.mode == SecurityMode::Enforce
}
}

#[cfg(test)]
#[path = "security_mode_tests.rs"]
mod tests;
Loading
Loading