Commit Graph

141 Commits

Author SHA1 Message Date
xj
236706a4ac style(security): apply rustfmt in policy tests 2026-02-28 17:00:18 -08:00
argenis de la rosa
7058b15cc4 fix(security): harden git config readonly checks 2026-02-28 18:23:37 -05:00
argenis de la rosa
4ce4ec5f34 feat(security): allow read-only git config operations
Previously, `is_args_safe()` blocked ALL `git config`, `git alias`,
and `git -c` subcommands unconditionally. This forced administrators
to pre-create `.gitconfig` files outside ZeroClaw.

Now allow read-only git config operations:
- `git config --get <key>` - read single value
- `git config --list` / `git config -l` - list all config
- `git config --get-all <key>` - get all values for key
- `git config --get-regexp <pattern>` - list matching keys
- `git config --get-urlmatch <pattern>` - URL matching

Write operations remain blocked:
- `git config user.name "value"` (plain write)
- `git config --unset <key>`
- `git config --add <key> <value>`
- `git config --global <key> <value>` (scoped write)
- `git config -e` / `--edit` (opens editor)
- `git alias.*` and `git -c` remain fully blocked

Security impact: Read operations have no side effects and cannot
be used for code execution. The dangerous keys (core.editor,
credential.helper, alias.*) remain protected since we only allow
explicitly read-only operations.

Fixes #1398

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:23:37 -05:00
argenis de la rosa
b0a3fbd338 test(security): assert /mnt in default forbidden path checks 2026-02-28 18:09:35 -05:00
Antigravity Agent
28b9d81464 security: add /mnt to default forbidden_paths 2026-02-28 18:09:35 -05:00
argenis de la rosa
f7de9cda3a Merge remote-tracking branch 'origin/main' into pr2093-mainmerge 2026-02-28 17:33:17 -05:00
argenis de la rosa
3f70cbbf9b feat(gateway): add paired devices API and dashboard tab 2026-02-28 13:34:33 -05:00
Chummy
be8f7efe82 test: stabilize flaky threshold assertions 2026-02-28 23:01:53 +08:00
Chummy
5ee6024914 Fix channel turn persistence and low-sensitivity leak detection 2026-02-28 23:01:53 +08:00
argenis de la rosa
a029c720a6 feat(security): add safety heartbeat reinjection with cadence fixes 2026-02-28 08:52:16 -05:00
Chummy
d9cdaa0757 fix: resolve post-rebase compile and test stability issues 2026-02-28 21:30:37 +08:00
Chummy
51ad52d0e8 security: harden sensitive I/O and outbound leak controls 2026-02-28 21:30:37 +08:00
VirtualHotBar
0a42329ca5 fix: session leftovers after db47f56
- Demote session normal flow logs to debug\n- Skip session operations when CHANNEL_SESSION_CONFIG is uninitialized\n- Add spawn_blocking panic context for SQLite session manager\n- Fix fmt/clippy regressions (Box::pin large futures, cfg features, misc lints)
2026-02-28 15:23:42 +08:00
argenis de la rosa
bfe3e4295d feat(security): add opt-in perplexity adversarial suffix filter 2026-02-26 22:55:23 -05:00
argenis de la rosa
970ef57f21 feat(security): add aho-corasick and entropy leak heuristics 2026-02-26 22:10:31 -05:00
argenis de la rosa
ffaf927690 fix(web): improve web access guidance and search failure diagnostics 2026-02-26 21:42:13 -05:00
argenis de la rosa
a9bd880a4f fix(security): use expect_err in role cycle test 2026-02-26 21:11:41 -05:00
argenis de la rosa
7aee6d9dc7 feat(security): add role-policy and otp challenge foundations 2026-02-26 21:11:41 -05:00
argenis de la rosa
b27b44829a chore: promote dev snapshot to main (resolve #1978/#1970) 2026-02-26 21:09:33 -05:00
Argenis
7bea2b89d4 fix(channels): resolve #1959 build break and #1960 mention-only noise
- restore Lark constructor wiring and platform-specific builders used by channel-lark builds\n- re-export syscall anomaly detector types from security module\n- suppress unauthorized Telegram prompts for unmentioned group messages when mention_only=true (still allow /bind)\n\nRefs: #1959\nRefs: #1960
2026-02-27 01:50:34 +00:00
argenis de la rosa
7b20697d93 fix(security): harden env passthrough validation coverage 2026-02-26 20:34:46 +08:00
argenis de la rosa
eeaa010f1a fix(security): allow configured shell env expansions 2026-02-26 20:34:46 +08:00
Chum Yin
9b0e70b2f2
supersede: file-replay changes from #1895 (#1926)
Automated conflict recovery via changed-file replay on latest main.
2026-02-26 04:15:47 -05:00
Jeff Lee
66ee2eb17e test(security): stabilize prompt guard and scheduler assertions 2026-02-26 02:01:43 +08:00
Chummy
cfe1e578bf feat(security): add and harden syscall anomaly detection 2026-02-25 20:43:38 +08:00
Chummy
346f58a6a1 hardening: strengthen tool policy enforcement and sandbox defaults 2026-02-25 18:33:28 +08:00
Chummy
d5cd65bc4f hardening: tighten gateway auth and secret lifecycle handling 2026-02-25 18:33:28 +08:00
FlashFamily
931cf40636 fix: resolve all clippy warnings across codebase
Fix all clippy errors reported by `cargo clippy --all-targets -- -D warnings`
on Rust 1.93, covering both the original codebase and upstream dev changes.

Changes by category:
- format!() appended to String → write!/writeln! (telegram, discord)
- Redundant field names, unnecessary boolean not (agent/loop_)
- Long numeric literals (wati, nextcloud, telegram, gemini)
- Wildcard match on single variant (security/leak_detector)
- Derivable Default impls (config/schema)
- &Option<T> → Option<&T> or allow (config/schema, config/mod, gateway/api)
- Identical match arms merged (gateway/ws, observability, providers, main, onboard)
- Cast truncation allowed with rationale (discord, lark)
- Unnecessary borrows/returns removed (multiple files)
- Unused imports removed (channels/mod, peripherals/mod, tests)
- MSRV-gated APIs allowed locally (memory/hygiene, tools/shell, tools/screenshot)
- Unnecessary .get().is_none() → !contains_key() (gemini)
- Explicit iteration → reference loop (gateway/api)
- Test-only: useless vec!, field_reassign_with_default, doc indentation

Validated: cargo fmt, cargo clippy --all-targets -- -D warnings, cargo test
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 49e90cf3e4)
2026-02-25 17:50:56 +08:00
reidliu41
8f263cd336 feat(agent): add CLI parameters for runtime config overrides 2026-02-24 18:12:33 +08:00
Chummy
15b54670ff fix: improve tool-call parsing and shell expansion checks 2026-02-24 13:45:13 +08:00
Chummy
5e581eabfe fix(security): preserve workspace allowlist before forbidden-root checks 2026-02-24 12:58:59 +08:00
Allen Huang
752877051c fix: security, config, and provider hardening
- security: honor explicit command paths in allowed_commands list
- security: respect workspace_only=false in resolved path checks
- config: enforce 0600 permissions on every config save (unix)
- config: reject temp-directory paths in active workspace marker
- provider: preserve reasoning_content in tool-call conversation history
- provider: add allow_user_image_parts parameter for minimax compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-24 12:58:59 +08:00
Chummy
d4f5f2ce95 fix(security): tighten prompt-guard detection thresholds and phrases 2026-02-24 12:38:48 +08:00
Mike Johnson-Maxted
2f29ec75ef fix(onboard): use provider-aware env var hint in quick setup next steps
Replace hardcoded OPENROUTER_API_KEY hint with provider-aware logic:
- keyless local providers (ollama, llamacpp, etc.) show chat/gateway/status hints
- device-flow providers (copilot, gemini, openai-codex) show OAuth/first-run hint
- all other providers show the correct provider-specific env var via provider_env_var()

Also adds canonical alias "github-copilot" -> "copilot" in canonical_provider_name(),
and a new provider_supports_device_flow() helper with accompanying test.

Additionally fixes pre-existing compile blockers that prevented CI from running:
- fix(security): correct raw string literals in leak_detector.rs that terminated
  early due to unescaped " inside r"..." (use r#"..."# instead)
- fix(gateway): add missing wati: None in two test AppState initializations
- fix(gateway): use serde::Deserialize path on WatiVerifyQuery struct
- fix(security): add #[allow(unused_imports)] on new pub use re-exports in mod.rs
- fix(security): remove unused serde::{Deserialize, Serialize} import
- chore: apply cargo fmt to files that had pending formatting diffs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 11:46:49 +08:00
Adam Singer
388e168158 [bug] Regex build failure 2026-02-24 11:34:12 +08:00
argenis de la rosa
5c63ec380a Merge branch 'main' into dev — consolidate all upstream releases 2026-02-23 14:03:17 -05:00
Erica Stith
63f485e56a
feat(security): Add prompt injection defense and leak detection (#1433)
Contributed from RustyClaw (MIT licensed).

## PromptGuard (src/security/prompt_guard.rs)

Detects and blocks/warns about prompt injection attacks:
- System prompt override attempts ("ignore previous instructions")
- Role confusion attacks ("you are now...", "act as...")
- Tool call JSON injection
- Secret extraction attempts
- Command injection patterns in tool arguments
- Jailbreak attempts (DAN mode, developer mode, etc.)

Features:
- Configurable sensitivity (0.0-1.0)
- Configurable action (Warn/Block/Sanitize)
- Pattern-based detection with regex
- Normalized scoring across categories

## LeakDetector (src/security/leak_detector.rs)

Prevents credential exfiltration in outbound content:
- API key patterns (Stripe, OpenAI, Anthropic, Google, GitHub)
- AWS credentials (Access Key ID, Secret Access Key)
- Generic secrets (passwords, tokens in config)
- Private keys (RSA, EC, OpenSSH PEM blocks)
- JWT tokens
- Database connection URLs (PostgreSQL, MySQL, MongoDB, Redis)

Features:
- Automatic redaction of detected secrets
- Configurable sensitivity
- Returns both detection info and redacted content

## Integration

Both modules are exported from `security` module:
```rust
use zeroclaw::security::{PromptGuard, GuardResult, LeakDetector, LeakResult};
```

## Attribution

RustyClaw: https://github.com/rexlunae/RustyClaw
License: MIT
2026-02-23 07:48:18 -05:00
Chummy
b7a5ef9d9d test(pairing): satisfy strict clippy delta on lockout sweep assertions 2026-02-23 19:49:10 +08:00
fettpl
99c4ae7200 fix(security): harden per-client lockout eviction and sweep
Addresses the unbounded-map gap left by #951: entries below the lockout
threshold (count < MAX_PAIR_ATTEMPTS, lockout = None) were never evicted,
allowing distributed brute-force (>1024 unique IPs, <5 attempts each) to
permanently fill the tracking map and disable accounting for new attackers.

Hardening delta on top of #951:

- Replace raw tuple with typed FailedAttemptState (count, lockout_until,
  last_attempt) for clarity and to enable retention-based sweep.
- Bump MAX_TRACKED_CLIENTS from 1024 to 10_000.
- Add 15-min retention sweep (prune_failed_attempts) on 5-min interval.
- Switch lockout from relative (locked_at + elapsed) to absolute
  (lockout_until) for simpler and monotonic comparison.
- Add LRU eviction fallback when map is at capacity after pruning.
- Add normalize_client_key() to sanitize whitespace/empty client IDs.
- Add 3 focused tests: per-client reset isolation, bounded map capacity,
  and sweep pruning of stale entries.

Supersedes:
- #670 by @fettpl (original hardening branch, rebased as delta)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:39:20 +08:00
Chummy
35e9ef2496 fix(security): honor explicit command paths in allowed_commands 2026-02-22 17:50:24 +08:00
Chummy
a36b1466ff feat(security): add otp and estop phase-1 foundation 2026-02-21 23:19:36 +08:00
Chummy
e5bc9514a4 security: close shell path-policy bypasses 2026-02-21 22:35:52 +08:00
Chummy
ccc3d6759f security: block plain shell variable expansion and forbidden path args 2026-02-21 20:42:48 +08:00
Chummy
628654ebe5 fix: improve allowed_roots guidance for filesystem access 2026-02-21 17:33:11 +08:00
chumyin
782bb0b483 fix: resolve multi-issue provider/channel/tool regressions 2026-02-21 15:12:27 +08:00
Aleksandr Prilipko
c54286fec0 feat(security): add allowed_roots for file access beyond workspace
Add `autonomy.allowed_roots` config option that lets the agent
read/write files under additional directory roots outside the
workspace (e.g. shared skills directories, project repos).
Resolved (canonical) paths under any allowed root pass
`is_resolved_path_allowed` alongside the workspace itself.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 14:57:16 +08:00
Aleksandr Prilipko
2393b9a551 fix: resolve clippy warnings and rustfmt across codebase
Address clippy lints (redundant continue, as-cast, match arms, elided
lifetimes, format vs write!) and reformat long cfg attributes and assert
macros to pass `cargo fmt --check` and `cargo clippy -D warnings`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 12:39:34 +08:00
dependabot[bot]
b23c2e7ae6
chore(deps): bump rand from 0.9.2 to 0.10.0 (#1075)
* chore(deps): bump rand from 0.9.2 to 0.10.0

Bumps [rand](https://github.com/rust-random/rand) from 0.9.2 to 0.10.0.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/rand_core-0.9.2...0.10.0)

---
updated-dependencies:
- dependency-name: rand
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(security): keep token generation compatible with rand 0.10

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Will Sarg <12886992+willsarg@users.noreply.github.com>
2026-02-20 05:29:23 -05:00
Alex Gorevski
2a106d051a
Merge pull request #1013 from zeroclaw-labs/fix/docs-inline-code-comments
docs(code): add decision-point comments to agent loop, security policy, and reliable provider
2026-02-19 16:01:19 -08:00
Alex Gorevski
200ce0d6fd
Merge pull request #1010 from zeroclaw-labs/fix/docs-trait-doc-comments
docs(code): expand doc comments on security, observability, runtime, and peripheral traits
2026-02-19 15:59:56 -08:00