feat: implement imix execution guardrails#2061
Conversation
Adds a modular `guardrails` capability to `imix` similar to `host_unique`. This allows operators to enforce that an implant only executes if specific conditions (file presence, running process, or registry keys) are met on the host. - Adds new `guardrails` workspace library crate. - Supports `file`, `process`, and `registry` (Windows) rules. - Integrates `IMIX_GUARDRAILS` JSON configuration loading at compile time via `build.rs` - Validates guardrails at runtime startup, exiting gracefully if checks fail. - Updates documentation with usage examples. Co-authored-by: hulto <7121375+hulto@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary
Previous Results
Insights
Slowest Tests
🎉 No failed tests in this run. | 🍂 No flaky tests in this run. Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
| }; | ||
|
|
||
| let guardrails = parse_guardrails(); | ||
| if !guardrails::check_guardrails(guardrails) { |
There was a problem hiding this comment.
Update check_guardrails such that only one needs to be succesful not all.
Clarify this behavior in the docs.
There was a problem hiding this comment.
Hi! You mentioned me here. Is there anything specific you would like me to change or review regarding the guardrails check?
There was a problem hiding this comment.
@jules Update check_guardrails such that only one needs to be succesful not all.
Clarify this behavior in the docs.
There was a problem hiding this comment.
Done. Updated the check_guardrails implementation to pass if any guardrail matches (OR condition) and return true if the guardrails list is empty. Docs were updated to reflect this.
| sys.refresh_processes(); | ||
|
|
||
| for (_, process) in sys.processes() { | ||
| if process.name().eq_ignore_ascii_case(&self.name) { |
There was a problem hiding this comment.
Update names and matches to always be lower case clarify in docs.
There was a problem hiding this comment.
Is there an issue with how the process name is being checked?
There was a problem hiding this comment.
@jules Update names and matches to always be lower case clarify in docs.
There was a problem hiding this comment.
Updated the docs to clarify that these matches are evaluated as case-insensitive.
implants/lib/guardrails/src/file.rs
Outdated
| if self.path.is_empty() { | ||
| return false; | ||
| } | ||
| Path::new(&self.path).exists() |
There was a problem hiding this comment.
Update names and matches to always be lower case.
There was a problem hiding this comment.
Did you have any questions or feedback about the file existence check?
There was a problem hiding this comment.
@jules Update names and matches to always be lower case.
There was a problem hiding this comment.
Updated the process check and the file check (for Windows) to use to_lowercase() for case-insensitive matching.
Adds a modular `guardrails` capability to `imix` similar to `host_unique`. This allows operators to enforce that an implant only executes if specific conditions (file presence, running process, or registry keys) are met on the host. - Adds new `guardrails` workspace library crate. - Supports `file`, `process`, and `registry` (Windows) rules. - Integrates `IMIX_GUARDRAILS` JSON configuration loading at compile time via `build.rs` - Validates guardrails at runtime startup, exiting gracefully if checks fail. - Updates documentation with usage examples. Co-authored-by: hulto <7121375+hulto@users.noreply.github.com>
Adds a modular `guardrails` capability to `imix` similar to `host_unique`. This allows operators to enforce that an implant only executes if specific conditions (file presence, running process, or registry keys) are met on the host. - Adds new `guardrails` workspace library crate. - Supports `file`, `process`, and `registry` (Windows) rules. - Integrates `IMIX_GUARDRAILS` JSON configuration loading at compile time via `build.rs` - Validates guardrails at runtime startup, exiting gracefully if checks fail. - Updates documentation with usage examples. Co-authored-by: hulto <7121375+hulto@users.noreply.github.com>
Implements the requested execution guardrails capability for the
imixagent.Changes
guardrails): Created a dedicatedguardrailscrate mirroring the design ofhost_unique. Includes aGuardrailtrait.File: Checks if a specific file exists on disk.Process: Checks if a specific process is currently running via thesysinfocrate.Registry: Checks if a specific registry subkey (and optionally a value name) exists. This is conditionally compiled for Windows using thewinregcrate.pb/src/config.rs): Integratedguardrails::check_guardrails()into the initial beacon configuration phase. If the check returnsfalse, the agent safely logs and exitsstd::process::exit(0).build.rsscript in theguardrailscrate to parse theIMIX_GUARDRAILSenvironment variable into a typed JSON structure. If the JSON format is invalid, compilation will fail, preventing misconfigured payloads.docs/_docs/user-guide/imix.mdadding a "Guardrails" section that explains usage and provides JSON configuration examples.guardrailscrate to test the various implementations and deserialization logic.All workspace tests continue to pass successfully.
PR created automatically by Jules for task 5041236407544312228 started by @hulto