Skip to content

feat: inject real operation values into agent prompt templates and reporting#270

Merged
l50 merged 8 commits into
mainfrom
fix/workgroup-domain-attribution-leak
May 10, 2026
Merged

feat: inject real operation values into agent prompt templates and reporting#270
l50 merged 8 commits into
mainfrom
fix/workgroup-domain-attribution-leak

Conversation

@l50
Copy link
Copy Markdown
Contributor

@l50 l50 commented May 10, 2026

Key Changes:

  • Injects operation-specific values (domain, DC IP, DC FQDN, listener IP) into all agent and system prompt templates
  • Refactors prompt rendering to use real targets in tool-call examples, eliminating generic placeholders
  • Improves output filtering and domain attribution logic to prevent phantom or noisy findings
  • Expands tests and updates documentation/examples to use realistic demo IPs/domains

Added:

  • OperationContext struct for passing operation values (domain, DC IP, DC FQDN, listener IP) to all prompt templates
  • report_filter module in loot formatter to filter out machine accounts, local SAM built-ins, krbtgt, and already-cracked hashes from JSON loot output
  • Defensive heuristics and helpers to detect and exclude workgroup/self-named pseudo-domains in user/hash/domain achievement processing
  • Extensive test coverage for workgroup filtering, domain attribution, loot filtering, and MSSQL/SMB parsing edge cases

Changed:

  • All agent and system prompt templates now render tool-call examples with real operation values injected (domain, DC IP/FQDN, listener IP)
  • Prompt rendering functions and template APIs updated to accept and propagate OperationContext
  • System and agent prompts clarify that tool-call examples are rendered with actual values, and instruct LLMs not to invent domains/IPs
  • MSSQL and trust exploitation templates now provide worked examples using actual credentials and context from payload/state
  • Output extraction logic for users, hashes, and achievements defensively filters out workgroup/self-named pseudo-domains, preventing state pollution from non-AD hosts
  • Loot JSON output now excludes noise accounts and duplicate cracked hashes to reduce scoreboard pollution
  • All hardcoded IPs in tests, examples, and documentation updated to use the standard demo subnet (192.168.58.x)

Removed:

  • Placeholder tool-call examples with fake IPs/domains in all agent/system prompt templates; replaced with context-driven real values
  • Manual instruction in prompts to "replace placeholders" - now all examples are rendered with live operation data
  • Redundant reporting instructions and placeholder handling in system instructions and templates, as real values are always present

l50 added 2 commits May 9, 2026 15:01
…ensively filter pseudo-domains

**Added:**

- Inject target domain, DC IP, DC FQDN, and listener IP into agent/system prompt templates via `StateSnapshot` and prompt rendering, ensuring tool-call examples use actual operation values
- Heuristic function to detect and filter Windows workgroup/self-named pseudo-domains in loot and output extraction, preventing phantom AD domains from polluting achievements and credential attribution
- Defensive filtering in loot achievement computation to skip workgroup and default computer-name pseudo-domains
- Contextual filtering of `(domain:...)` in SMB/user extraction to avoid setting current domain to a workgroup/self-named pseudo-domain
- Tests for new pseudo-domain detection and filtering behaviors across loot, orchestrator extraction, and SMB parsing
- Selection of representative credential for worked example in MSSQL lateral/exploit prompt generation

**Changed:**

- All agent/system prompt templates now render tool-call examples and workflow steps using injected operation context values (`target_domain`, `target_dc_ip`, `target_dc_fqdn`, `listener_ip`) instead of static placeholders
- `LlmTaskRunner` and prompt-building logic updated to pass listener IP and target context through to templates
- `SharedState` snapshot extended to compute and expose primary target domain, DC IP, DC FQDN, and listener IP for prompt rendering
- SMB NetExec banner parsing and FQDN extraction now skip workgroup/self-named pseudo-domains, matching orchestrator extraction logic
- Output extraction for users now prevents workgroup banners from overwriting `current_domain`
- MSSQL prompt rendering passes representative credential into templates for worked example sections
- All tests and agent/system prompt rendering calls updated to provide the required context values

**Removed:**

- Static/placeholder values for domain, DC IP, DC FQDN, and listener IP from prompt templates and examples, eliminating risk of LLMs copying non-contextual values into real tool calls
…ning

**Added:**

- Forward linked-server names from vulnerability details into the task payload in `auto_mssql_exploitation`, enabling prompt templates to use real values for `linked_server`
- Add `linked_server` field to `MssqlDeepWork` struct to carry context for linked server exploitation

**Changed:**

- Update MSSQL lateral prompt rendering to inject `linked_server` and `listener_ip` as context variables for more accurate task prompts
- Refactor trust exploitation prompt logic to use `has_source_sid`, `has_target_sid`, and `can_forge` flags; ensure forge and secretsdump steps only appear when all prerequisites are present, and provide clear instructions for missing SID resolution
- Remove placeholder variables from trust prompt context and templates, relying on real values passed by orchestrator
- Clarify and streamline privesc agent workflow: document that all MSSQL exploitation (including linked servers) is dispatched as focused tasks with required context already set, and direct agents not to guess or call steps out of order
- Improve coercion agent instructions to emphasize always using interface values from the task prompt and never guessing interface names
- Revise constrained delegation exploitation task prompt: clarify that only `s4u_attack` is run directly, and that follow-up credential access tasks (secretsdump, psexec) are auto-chained by the orchestrator; remove manual step instructions and reinforce correct reporting/termination
- Update MSSQL lateral task prompt to clarify that discovered linked servers trigger auto-dispatched follow-up tasks, and only pre-populated `linked_server` is used for pivoting in the current task
- Improve trust exploitation task prompt to conditionally render SID and forge steps based on available data, and to clarify that secretsdump is auto-chained by the orchestrator

**Removed:**

- Eliminate manual and placeholder-driven steps in trust and MSSQL task prompts, ensuring all steps rely on orchestrator-populated context and auto-chained follow-ups
- Remove obsolete or redundant step-by-step instructions for manual ticket and hash handling in constrained delegation and trust escalation paths, consolidating to orchestrator-driven workflows
@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

❌ Patch coverage is 88.09524% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.99%. Comparing base (c96aa1b) to head (b81a620).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ares-cli/src/ops/loot/format/display.rs 72.22% 20 Missing ⚠️
.../src/orchestrator/automation/mssql_exploitation.rs 0.00% 11 Missing ⚠️
ares-cli/src/ops/loot/format/json.rs 0.00% 10 Missing ⚠️
ares-cli/src/orchestrator/llm_runner.rs 55.55% 8 Missing ⚠️
ares-llm/src/prompt/exploit/mssql.rs 88.70% 7 Missing ⚠️
ares-cli/src/orchestrator/state/shared.rs 87.87% 4 Missing ⚠️
ares-cli/src/ops/loot/format/report_filter.rs 99.20% 1 Missing ⚠️
ares-cli/src/orchestrator/mod.rs 0.00% 1 Missing ⚠️
...es-cli/src/orchestrator/output_extraction/users.rs 98.07% 1 Missing ⚠️
ares-llm/src/prompt/exploit/trust.rs 91.66% 1 Missing ⚠️
... and 1 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
+ Coverage   75.92%   75.99%   +0.07%     
==========================================
  Files         385      386       +1     
  Lines       83591    84059     +468     
==========================================
+ Hits        63465    63881     +416     
- Misses      20126    20178      +52     
Files with missing lines Coverage Δ
ares-cli/src/ops/loot/format/mod.rs 68.33% <ø> (ø)
...s-cli/src/orchestrator/output_extraction/hashes.rs 98.30% <100.00%> (+0.26%) ⬆️
ares-cli/src/orchestrator/task_queue.rs 85.24% <100.00%> (ø)
ares-cli/src/orchestrator/tool_dispatcher/tests.rs 100.00% <100.00%> (ø)
ares-cli/src/worker/task_loop/result_handler.rs 82.29% <100.00%> (ø)
ares-cli/src/worker/tool_executor.rs 74.30% <100.00%> (ø)
ares-core/src/config/mod.rs 89.67% <100.00%> (-0.15%) ⬇️
ares-llm/src/prompt/blue.rs 100.00% <ø> (ø)
ares-llm/src/prompt/mod.rs 100.00% <ø> (ø)
ares-llm/src/prompt/templates.rs 100.00% <100.00%> (ø)
... and 11 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

l50 added 3 commits May 9, 2026 19:40
**Added:**

- Introduced `OperationContext` struct to encapsulate operation-specific fields (domain, DC IP/FQDN, listener IP) for prompt templates in `templates.rs`
- Added `OperationContext::EMPTY` constant and an `insert_into` method for context injection
- Added a test constant `TEST_OP` for use in prompt template tests

**Changed:**

- Refactored all agent and system prompt rendering functions (`render_agent_instructions`, `render_system_instructions`, etc.) to accept a single `OperationContext` argument instead of multiple individual operation-related parameters
- Updated all internal calls and tests to use the new `OperationContext` signature, replacing positional string arguments with the struct
- Simplified code in orchestrator, prompt, and test modules to use the unified context for readability and maintainability

**Removed:**

- Eliminated separate `target_domain`, `target_dc_ip`, `target_dc_fqdn`, and `listener_ip` function parameters in favor of the new `OperationContext` struct throughout the prompt/template codebase and tests
…reporting

**Added:**

- introduced `report_filter` module with logic to exclude machine accounts, krbtgt, local SAM built-ins, common service accounts, and already-cracked hashes from reported credentials and hashes
- comprehensive unit tests for credential and hash filtering logic

**Changed:**

- updated loot JSON output to apply filtering so only reportable credentials and hashes are included, reducing noise for external scoreboards
- added `report_filter` module import in format mod.rs to enable filtering in JSON output
**Added:**

- Introduced pre-scan logic in `output_extraction/hashes.rs` to infer the dumped domain/realm from evidence in NTDS dump output, avoiding phantom krbtgt attribution when the target differs from the actual dump realm
- Added tests in `output_extraction/hashes.rs` to verify domain inference behavior for krbtgt attribution, including correct fallback to the default domain and selection of the most common prefix

**Changed:**

- Updated test fixtures and example data across codebase to use realistic demo domains (e.g., `child.contoso.local`, `fabrikam.local`) and IPs (e.g., `192.168.58.10`) instead of placeholder or inconsistent values such as `10.0.0.1` and `north.sevenkingdoms.local`
- Modified test SMB banners, workgroup FQDNs, and related domain logic in `smb.rs`, `users.rs`, and `display.rs` to consistently use `WIN-ABCDEFGHIJK.WGRP.LOCAL` and similar
- Aligned test arguments and discovery payloads in orchestrator and worker tests to use the new canonical IP/domain examples
- Updated documentation in `docs/red.md` and `docs/strategy.md` to reflect the same IP and domain convention in code examples and scenario explanations

**Removed:**

- Eliminated references to fantasy or placeholder domains and IPs in test and documentation scenarios to prevent confusion and promote consistency with standard demo environments
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added the area/docs Changes made to project documentation label May 10, 2026
@l50 l50 changed the title feat: inject real operation context into agent prompt templates and improve workgroup handling feat: inject real operation values into agent prompt templates and reporting May 10, 2026
l50 added 3 commits May 9, 2026 20:11
**Changed:**

- Show domain admin and golden ticket achievement counts per domain in human-readable loot output, improving clarity for multi-domain environments - ares-cli/src/ops/loot/format/display.rs
- Minor formatting adjustment to test for reportable credentials, improving readability - ares-cli/src/ops/loot/format/report_filter.rs
- Minor code style update for hashmap initialization to a single line - ares-cli/src/orchestrator/output_extraction/hashes.rs
**Changed:**

- Merged tests for `AresConfig::from_env` handling of `ARES_CONFIG` env var into a single test to prevent race conditions caused by parallel test execution and shared environment variables
@l50 l50 merged commit adee1a1 into main May 10, 2026
11 checks passed
@l50 l50 deleted the fix/workgroup-domain-attribution-leak branch May 10, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Changes made to project documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant