Metadata-Version: 2.4
Name: gsh-framework
Version: 1.9.0
Summary: Governed Security Hunting (GSH) Framework - autonomous agentic AI threat hunting: hunt playbooks, a real MCP proxy (Hunt-005), and SIEM/LangChain adapters.
Author-email: Sunil Gentyala <sunil.gentyala@ieee.org>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
        
Project-URL: Homepage, https://sunilgentyala.github.io/gsh-framework/
Project-URL: Repository, https://github.com/sunilgentyala/gsh-framework
Project-URL: Issues, https://github.com/sunilgentyala/gsh-framework/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE.md
Requires-Dist: pyyaml>=6.0.1
Provides-Extra: splunk
Requires-Dist: requests>=2.31.0; extra == "splunk"
Provides-Extra: elastic
Requires-Dist: requests>=2.31.0; extra == "elastic"
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3.0; extra == "langchain"
Provides-Extra: windows
Requires-Dist: pywin32>=306; sys_platform == "win32" and extra == "windows"
Provides-Extra: llm
Requires-Dist: openai>=1.30.0; extra == "llm"
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff==0.16.10; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Dynamic: license-file

<p align="center">
  <a href="https://sunilgentyala.github.io/gsh-framework/"><img src="docs/banner-v1.9.0.svg" alt="Governed Security Hunting (GSH) Framework: open-source threat hunting for agentic AI" width="100%"></a>
</p>

# Governed Security Hunting (GSH) Framework

[![CI](https://github.com/sunilgentyala/gsh-framework/actions/workflows/ci.yml/badge.svg)](https://github.com/sunilgentyala/gsh-framework/actions/workflows/ci.yml)
[![License](https://img.shields.io/github/license/sunilgentyala/gsh-framework)](LICENSE)
[![Version](https://img.shields.io/badge/version-1.9.0-brightgreen)](https://github.com/sunilgentyala/gsh-framework)
[![Paper](https://img.shields.io/badge/paper-in%20preparation-lightgrey)](https://github.com/sunilgentyala/gsh-framework#research)
[![Website](https://img.shields.io/badge/website-live-blue)](https://sunilgentyala.github.io/gsh-framework/)
[![MITRE ATLAS](https://img.shields.io/badge/MITRE-ATLAS-red)](https://atlas.mitre.org/)
[![NIST CSF](https://img.shields.io/badge/NIST-CSF%202.0-blue)](https://www.nist.gov/cyberframework)
[![Stars](https://img.shields.io/github/stars/sunilgentyala/gsh-framework?style=social)](https://github.com/sunilgentyala/gsh-framework/stargazers)
[![Forks](https://img.shields.io/github/forks/sunilgentyala/gsh-framework?style=social)](https://github.com/sunilgentyala/gsh-framework/network/members)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21384588.svg)](https://doi.org/10.5281/zenodo.21384588)

**Author:** Sunil Gentyala, IEEE Senior Member | Lead Cybersecurity and AI Security Consultant, HCLTech
**Contact:** [sunil.gentyala@ieee.org](mailto:sunil.gentyala@ieee.org)
**Website:** [sunilgentyala.github.io/gsh-framework](https://sunilgentyala.github.io/gsh-framework/)
**License:** [Apache 2.0](LICENSE)

---

Most enterprise security stacks were not built for the threat surface that agentic AI creates. Endpoint agents cannot see what an LLM gateway is doing. SIEMs have no baselines for multi-agent tool call chains. The GSH Framework closes that gap.

GSH is an open-source research artifact for autonomous agentic AI threat hunting. It provides structured detection playbooks, behavioral baselining logic, and a policy-driven enforcement engine (Sovereign Sentinel) designed for the cognitive cyber domain: the operational layer where large language models, autonomous agents, and multi-agent pipelines interact with enterprise infrastructure.

All detection signals are mapped to MITRE ATLAS and NIST CSF 2.0, giving practitioners framework-aligned coverage they can operationalize immediately.

---

## Try It in One Command

```bash
cd demo && docker compose up --build --abort-on-container-exit
```

Watch Hunt-005 catch an MCP rug pull, a poisoned tool description, and an implementation swap that keeps the tool schema identical. Details and limits: [demo/README.md](demo/README.md).

![GSH Hunt-005 demo: rug pull, tool poisoning and implementation swap are all caught](docs/demo.gif)

<sub>Replay of the real output of `python demo/run_demo.py`, rendered from captured terminal output (not a live screen recording). Very long lines are truncated and the local temp path is masked.</sub>

---

## Contributors Wanted

GSH is actively looking for security engineers, Python developers, detection engineers and AI-security researchers.

**Good first contributions** (each has a scoped issue with files, acceptance criteria and a difficulty estimate):

- [Sample benign and rogue MCP telemetry](https://github.com/sunilgentyala/gsh-framework/issues/3)
- [Sentinel policy JSON Schema validation](https://github.com/sunilgentyala/gsh-framework/issues/1)
- [Architecture diagram](https://github.com/sunilgentyala/gsh-framework/issues/4)
- [SARIF report output](https://github.com/sunilgentyala/gsh-framework/issues/10)
- CrewAI / AutoGen integrations and additional MCP transports (open an issue first)

Look for [`good first issue`](https://github.com/sunilgentyala/gsh-framework/labels/good%20first%20issue) and [`help wanted`](https://github.com/sunilgentyala/gsh-framework/labels/help%20wanted). First contribution? Documentation and tests are welcome too, and small fixes can go straight to a PR. See [CONTRIBUTING.md](CONTRIBUTING.md).

**Especially wanted:** people who will try to break the Hunt-005 detection assumptions (false positives, false negatives, bypasses of the Implementation Identity Gate).

---

## Current Status

The hunt playbooks, detection logic, thresholds, and policy schema are complete and documented.

**Hunt-001 through Hunt-004** (`scripts/gsh-sentinel-deploy.py`, `scripts/gsh-probe-eval.py`) implement the full baselining, drift-scoring, and ZTLV enforcement logic end-to-end, but ship with a **synthetic telemetry generator** (clearly marked `SIMULATION MODE` in the script output and `# Replace this block` in source) so you can see the detection logic run without a live environment first. Wiring `--target` to a real LLM gateway event stream is the integration step you complete before using this for actual enforcement.

**Hunt-005** (`adapters/mcp_proxy.py`, `scripts/gsh-mcp-proxy.py`, `scripts/gsh-baseline.py`) is different: it is a real MCP JSON-RPC stdio proxy that intercepts *actual* tool definitions and tool calls between a real MCP host and a real MCP server - approval-time schema hashing, drift detection, semantic poisoning scans, and per-call enforcement (permit/alert/block) all run against live traffic, not synthetic data. A captured baseline is never auto-trusted: it starts as UNVERIFIED and only becomes a trusted comparison point through the `gsh-baseline.py capture -> review -> approve -> verify` workflow; `--mode aggressive` refuses to even launch the wrapped server without an approved baseline. An approved baseline is also bound to an Implementation Identity (resolved executable/script hashes plus an adjacent dependency-lock file) so a server that keeps an identical, approved tool schema while its underlying implementation is swapped out under the same launch command is refused before it is even started, in any enforcement mode - not just when the baseline itself drifts. See `tests/test_mcp_proxy.py` and `tests/test_gsh_baseline.py` for subprocess-driven end-to-end tests of both CLIs. Known gaps: canary/response-asymmetry comparison and tool-return-value scanning are not implemented yet (see `playbooks/hunt-005-mcp-tool-poisoning.md` section 5.2 for details), and only the stdio transport is supported (not streamable HTTP/SSE MCP servers).

**SIEM output** (`adapters/splunk_hec.py`, `adapters/elastic_bulk.py`, `adapters/windows_eventlog.py`) is also real: set `siem_output: splunk`, `siem_output: elastic`, or `siem_output: windows_eventlog` in your policy YAML (see `configs/sentinel-policy-default.yaml`) and both `gsh-sentinel-deploy.py` and `gsh-mcp-proxy.py` will send findings there (Splunk HEC / Elasticsearch `_bulk` over real HTTP, or a registered source in the local Windows Application Event Log). A failed or unconfigured send always falls back to local file output - a finding is never silently dropped. The Windows Event Log adapter is Windows-only and requires `pywin32`; on any other platform (or without `pywin32`) it logs a warning and falls back like any other unconfigured destination. See `tests/test_siem_adapters.py` and `tests/test_windows_eventlog.py` (the latter includes a test that writes a real event and reads it back, not just a mocked one).

**LangChain telemetry** (`adapters/langchain_callback.py`) is a fourth real integration: `GSHCallbackHandler` attaches to any LangChain `Runnable`/agent via `config={"callbacks": [handler]}` and evaluates real tool-call rate, token velocity, unauthorized-tool invocations, and suspicious call parameters against Hunt-001/Hunt-004 thresholds - no synthetic data. **Important limitation:** LangChain callback handlers are notification hooks, not gates - by default LangChain swallows exceptions raised inside a callback rather than stopping the tool call, so this adapter can only alert, never block. Every finding it emits is explicitly marked `enforcement_mode: "alert_only"` and `action_taken: "ALERTED"`, regardless of policy mode. It also has no visibility into DNS queries (Hunt-002). See `tests/test_langchain_callback.py`, tested against `langchain-core` 1.4.x.

See [open issues](https://github.com/sunilgentyala/gsh-framework/issues) for remaining work (SARIF reporting and the Hunt-006 playbook). The Docker demo shipped as `demo/`.

---

## Version History

Full release notes (including known limitations at each release) are on the [Releases page](https://github.com/sunilgentyala/gsh-framework/releases). Summary:

| Version | Highlights |
|---|---|
| [v1.9.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.9.0) | Sentinel CLI error handling: clearer messages, `--log-level DEBUG` tracebacks and a remediation hint (#12, #16). Canonical Apache-2.0 license text so GitHub detects it, README banner, Zenodo DOI in `CITATION.cff`. Dependabot updates, CodeQL scanning and `main` branch protection enabled |
| [v1.8.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.8.0) | One-command Docker demo for Hunt-005 (`demo/`): drives the real baseline and proxy CLIs through a rug pull, a poisoned tool description and an implementation swap that keeps the schema identical, with a CI smoke test. Contribution path relaxed (small fixes go straight to a PR), Contributors Wanted block, scoped good-first-issue guides. No framework code changes |
| [v1.7.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.7.0) | Implementation Identity Gate for Hunt-005 (`adapters/mcp_proxy.py`): an approved baseline is now bound to the resolved executable/script hashes and adjacent dependency-lock file behind the launch command, not just the tool schema - a server that keeps an identical schema while its implementation is swapped out under the same command reference is blocked before it is ever launched, not just quarantined after the fact. Closes a gap identified in independent third-party review (schema-only trust). Breaking: pre-1.7.0 approved baselines have no identity data and must be re-captured and re-approved |
| [v1.6.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.6.0) | Security audit pass: newly-added MCP tools (added after an approved baseline) are no longer auto-authorized for invocation until reviewed; concurrent-write protection for MCP proxy stdout and LangChain adapter alert IDs; DNS-tunneling allowlist (Hunt-002) now raises its entropy/label-length bar for trusted apex domains instead of fully exempting them |
| [v1.5.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.5.0) | Real Windows Application Event Log output adapter (`adapters/windows_eventlog.py`); optional and Windows-only, safe no-op elsewhere |
| [v1.4.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.4.0) | Real LangChain callback adapter (`adapters/langchain_callback.py`) for Hunt-001/Hunt-004 telemetry - alert-only by design, since LangChain callbacks cannot block a tool call |
| [v1.3.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.3.0) | Real Splunk HEC and Elastic bulk SIEM output adapters, wired into both the Sentinel and the MCP proxy via a shared dispatcher; a failed/unconfigured SIEM send now always falls back to local file output |
| [v1.2.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.2.0) | Real MCP JSON-RPC stdio proxy for Hunt-005 (`adapters/mcp_proxy.py`) - schema-hash drift detection, semantic poisoning scan, and real per-call enforcement against live MCP traffic, not simulated |
| [v1.1.0](https://github.com/sunilgentyala/gsh-framework/releases/tag/v1.1.0) | Hunt-004 (rogue agent) completed; Hunt-005 (MCP supply chain / tool poisoning) added as a playbook; project website launched |
| v1.0.0-beta | Initial public release: Hunt-001 through Hunt-003 playbooks, Sentinel reference scripts (synthetic telemetry), default policy schema |

---

## Framework Components

| Component | Description |
|---|---|
| **Sovereign Sentinel** | Policy-driven behavioral enforcement agent deployed alongside LLM gateways |
| **Hunt Playbooks** | Structured threat detection playbooks for high-severity agentic AI threats |
| **DDI-AI Fusion** | DNS/DHCP/IPAM telemetry layer with AI-agent-aware baselining |
| **Zero-Trust Logic Validation (ZTLV) Gate** | Per-invocation tool call authorization engine |
| **Behavioral Baseline Engine** | Continuous model output drift detection and probe evaluation pipeline |

---

## Hunt Playbooks

| Playbook | Threat Class | Severity | Status |
|---|---|---|---|
| [Hunt-001](playbooks/hunt-001-agentic-loop-detection.md) | Agentic Loop / Resource Exhaustion | High | Active |
| [Hunt-002](playbooks/hunt-002-ddi-tunneling-anomaly.md) | DDI Covert Channel / C2 via DNS | Critical | Active |
| [Hunt-003](playbooks/hunt-003-model-poisoning-baseline.md) | ML Model Poisoning / Behavioral Drift | Critical | Active |
| [Hunt-004](playbooks/hunt-004-rogue-agent-detection.md) | Rogue Agent / Unauthorized Tool Use | Critical | Active |
| [Hunt-005](playbooks/hunt-005-mcp-tool-poisoning.md) | MCP Supply Chain / Tool Poisoning | Critical | Active |

---

## Quick Start

### 1. Clone the Repository

```bash
git clone https://github.com/sunilgentyala/gsh-framework.git
cd gsh-framework
pip install -r requirements.txt
```

**Alternative: install as a package.** The repo is also `pip`-installable from source (not yet published to PyPI, so install from the checkout, not `pip install gsh-framework`):

```bash
pip install .              # adapters + all CLIs, PyYAML only (no SIEM/LangChain/Windows extras)
pip install ".[splunk]"    # + Splunk/Elastic HTTP output (adapters/splunk_hec.py, elastic_bulk.py)
pip install ".[langchain]" # + LangChain callback adapter
pip install ".[windows]"   # + Windows Event Log adapter (Windows only)
pip install ".[llm]"       # + OpenAI-compatible client for gsh-probe-eval.py
pip install ".[dev]"       # + pytest, ruff, mypy, black
```

This installs `gsh-sentinel-deploy`, `gsh-mcp-proxy`, `gsh-baseline`, `gsh-probe-eval`, and `gsh-ddi-log-parser` as commands (equivalent to `python scripts/<name>.py`), and makes `adapters` importable without manually adjusting `sys.path`. Extras can be combined, e.g. `pip install ".[splunk,langchain]"`.

### 2. Review the Sentinel Policy

```bash
cat configs/sentinel-policy-default.yaml
```

Edit it to set your organization name, SIEM output destination, and egress allowlist before deploying.

### 3. Deploy a Sovereign Sentinel

Start in passive mode to build a 7-day behavioral baseline, then move to standard enforcement:

```bash
python scripts/gsh-sentinel-deploy.py \
  --target "llm-gateway-01" \
  --mode passive \
  --policy configs/sentinel-policy-default.yaml \
  --baseline-window 7d
```

As shipped, this generates synthetic telemetry (`SIMULATION MODE`, logged at startup) so you can watch the baselining and scoring logic run immediately. Replace the telemetry-generation block noted in the script (real LLM gateway/API metrics or LangChain callbacks) to run it against live traffic.

### 4. Run the MCP Proxy (Hunt-005 - real enforcement, not simulated)

Unlike step 3, this runs against real MCP traffic. A captured baseline is never auto-trusted - capture it, review it, then approve it:

```bash
python scripts/gsh-baseline.py capture \
  --server-id "corp-tools-mcp-01" \
  --server-cmd "npx -y @modelcontextprotocol/server-filesystem /srv/data"

python scripts/gsh-baseline.py review --baseline baselines/mcp/corp-tools-mcp-01.json

python scripts/gsh-baseline.py approve \
  --baseline baselines/mcp/corp-tools-mcp-01.json --reviewer "your-name-or-email"
```

Then configure your MCP host to launch the proxy instead of the real server directly:

```bash
python scripts/gsh-mcp-proxy.py \
  --server-cmd "npx -y @modelcontextprotocol/server-filesystem /srv/data" \
  --server-id "corp-tools-mcp-01" \
  --mode standard \
  --baseline baselines/mcp/corp-tools-mcp-01.json
```

The proxy will alert on (or, in `--mode aggressive`, block) definition drift, poisoned tool descriptions, invisible Unicode content, and unauthorized tool calls. **In `--mode aggressive`, the proxy refuses to launch the wrapped server at all unless the baseline above has been approved** - see `playbooks/hunt-005-mcp-tool-poisoning.md` section 5.1 for why, and section 5.2 for the full detection logic.

### 5. Wire a LangChain Agent to a Sentinel (real telemetry, alert-only)

```bash
pip install langchain-core
```

```python
from adapters.langchain_callback import GSHCallbackHandler

handler = GSHCallbackHandler(
    target="my-langchain-agent",
    allowlist=["web_search", "calculator"],   # unlisted tools trigger an immediate alert
)

# Attach to any LLM, tool, or chain via the standard LangChain callbacks config:
llm.invoke(prompt, config={"callbacks": [handler]})
my_tool.invoke(args, config={"callbacks": [handler]})

handler.flush()  # evaluate any partial window at the end of a run
```

This is alert-only, not enforcement - see `adapters/langchain_callback.py`'s module docstring for why LangChain callback handlers cannot reliably block a tool call.

### 6. Run a Hunt Playbook

Each playbook is a self-contained Markdown document with detection logic, data sources, MITRE ATLAS mapping, triage decision tree, and response actions. Start with Hunt-001 for loop detection:

```bash
cat playbooks/hunt-001-agentic-loop-detection.md
```

---

## Research

A companion research paper covering the full technical rationale, design decisions, and threat model is in preparation and not yet submitted. Per publication policy, the manuscript is not included in this repository. For research inquiries, contact [sunil.gentyala@ieee.org](mailto:sunil.gentyala@ieee.org).

---

## Repository Structure

```
gsh-framework/
├── README.md
├── SECURITY.md
├── LICENSE
├── CITATION.cff
├── CONTRIBUTING.md
├── requirements.txt
├── pyproject.toml                  # pip-installable package + console-script CLIs, extras
├── .github/
│   └── workflows/
│       └── ci.yml                  # pytest + ruff + mypy across Python 3.10-3.13
├── adapters/
│   ├── mcp_proxy.py                 # Real MCP JSON-RPC proxy (Hunt-005) + baseline approval governance
│   ├── langchain_callback.py        # Real LangChain telemetry, alert-only (Hunt-001/004)
│   ├── splunk_hec.py                # Real Splunk HTTP Event Collector output
│   ├── elastic_bulk.py              # Real Elasticsearch/OpenSearch _bulk output
│   ├── windows_eventlog.py          # Real Windows Application Event Log output
│   └── siem_dispatch.py             # Shared dispatcher used by all three SIEM adapters
├── configs/
│   └── sentinel-policy-default.yaml
├── docs/
│   └── index.html                  # Project website (GitHub Pages)
├── playbooks/
│   ├── hunt-001-agentic-loop-detection.md
│   ├── hunt-002-ddi-tunneling-anomaly.md
│   ├── hunt-003-model-poisoning-baseline.md
│   ├── hunt-004-rogue-agent-detection.md
│   └── hunt-005-mcp-tool-poisoning.md
├── probes/
│   └── standardized-probe-set-v1.json
├── scripts/
│   ├── _cli_shims.py               # console-script entry points (pyproject.toml) for the scripts below
│   ├── ddi-log-parser-ai.py
│   ├── gsh-baseline.py             # capture/review/approve/verify CLI for MCP baseline governance
│   ├── gsh-mcp-proxy.py            # CLI for adapters/mcp_proxy.py
│   ├── gsh-probe-eval.py
│   └── gsh-sentinel-deploy.py
├── tests/
│   ├── test_ddi_log_parser.py
│   ├── test_gsh_baseline.py
│   ├── test_mcp_proxy.py
│   ├── test_siem_adapters.py
│   ├── test_windows_eventlog.py
│   ├── test_langchain_callback.py
│   └── fixtures/
│       ├── mock_mcp_server.py      # Minimal MCP stdio server for testing
│       └── mock_http_sink.py       # Minimal HTTP server for testing SIEM adapters
├── baselines/
└── reports/
```

---

## Threat Coverage

| Threat | MITRE ATLAS | MITRE ATT&CK | NIST CSF 2.0 |
|---|---|---|---|
| Agentic Loop / Resource Exhaustion | AML.T0048, AML.T0040 | | DE.AE-02, DE.CM-01, RS.MI-01 |
| DDI Covert Channel Exfiltration | AML.T0048, AML.T0051 | T1071.004, T1048, T1568 | DE.CM-01, DE.AE-04, PR.DS-01 |
| ML Model Poisoning / Behavioral Drift | AML.T0020, AML.T0043, AML.T0044 | | ID.RA-01, DE.AE-02, DE.CM-06 |
| Rogue Agent / Unauthorized Tool Use | AML.T0051, AML.T0053, AML.T0054 | | PR.PS-04, DE.CM-01, RS.AN-03 |
| MCP Supply Chain / Tool Poisoning | AML.T0010, AML.T0051, AML.T0053 | T1195 | ID.SC-04, PR.PS-04, DE.CM-06 |

---

## Contributing

Security practitioners, AI safety researchers, and detection engineers are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a Pull Request.

High-priority contributions include: additional hunt playbooks, refined detection thresholds, and integration adapters for LangChain, AutoGen, CrewAI, and MCP host platforms.

---

## Citation

If you use the GSH Framework in your research, please cite:

```bibtex
@misc{gentyala2026gsh,
  author       = {Gentyala, Sunil},
  title        = {The Governed Security Hunting (GSH): An Autonomous Agentic Framework
                  for Defending the Cognitive Cyber Domain},
  year         = {2026},
  howpublished = {Open Source Research Artifact, GitHub},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.21384588},
  url          = {https://github.com/sunilgentyala/gsh-framework}
}
```

The DOI above is the Zenodo concept DOI, which always resolves to the latest archived release. Machine-readable metadata is in [`CITATION.cff`](CITATION.cff).

---

## Security Vulnerabilities

To report a vulnerability in the GSH Framework itself, use [GitHub's private vulnerability reporting](https://github.com/sunilgentyala/gsh-framework/security/advisories/new) or email [sunil.gentyala@ieee.org](mailto:sunil.gentyala@ieee.org) with the subject `[GSH Security Vulnerability] - [brief description]`. Do not open a public GitHub Issue. See [SECURITY.md](SECURITY.md) for the full policy, supported versions, and response timeline.

---

## Related Work

- [ContextGuard](https://github.com/sunilgentyala/contextguard): Zero-trust middleware for Model Context Protocol (MCP) server security. Precision 100%, Recall 96.7%, F1 98.3% at 1.005ms latency.
- [ARGUS](https://github.com/sunilgentyala/argus): LLM application security scanner.
- IEEE Senior Member Profile: [ORCID 0009-0005-2642-3479](https://orcid.org/0009-0005-2642-3479)
