1"use strict";(globalThis.webpackChunkcontrolzero_docs||=[]).push([[175],{22272(e,n,t){t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>s,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"blueprints/fortified-sre","title":"The Fortified SRE","description":"Protecting Production Infrastructure from Destructive Agent Actions","source":"@site/docs/blueprints/fortified-sre.md","sourceDirName":"blueprints","slug":"/blueprints/fortified-sre","permalink":"/docs/blueprints/fortified-sre","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1,"title":"The Fortified SRE"},"sidebar":"docsSidebar","previous":{"title":"Blueprint Library Overview","permalink":"/docs/guides/blueprints-library"},"next":{"title":"Cloud Firewall Guardian","permalink":"/docs/blueprints/cloud-firewall-guardian"}}');var i=t(74848),o=t(28453);const s={sidebar_position:1,title:"The Fortified SRE"},l="Blueprint: The Fortified SRE",c={},a=[{value:"Protecting Production Infrastructure from Destructive Agent Actions",id:"protecting-production-infrastructure-from-destructive-agent-actions",level:3},{value:"Architecture",id:"architecture",level:2},{value:"1. Master Policy Definition",id:"1-master-policy-definition",level:2},{value:"2. Implementation",id:"2-implementation",level:2},{value:"Python Prototype",id:"python-prototype",level:3},{value:"3. Validation Checklist",id:"3-validation-checklist",level:2}];function d(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",input:"input",li:"li",mermaid:"mermaid",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"blueprint-the-fortified-sre",children:"Blueprint: The Fortified SRE"})}),"\n",(0,i.jsx)(n.h3,{id:"protecting-production-infrastructure-from-destructive-agent-actions",children:"Protecting Production Infrastructure from Destructive Agent Actions"}),"\n",(0,i.jsxs)(n.p,{children:['Agents with access to terminal tools or cloud APIs have broad capabilities, but pose a serious risk to production environments. A single "hallucinated" or accidental command like ',(0,i.jsx)(n.code,{children:"rm -rf /"})," or ",(0,i.jsx)(n.code,{children:"db.dropDatabase()"})," can take down an entire company."]}),"\n",(0,i.jsxs)(n.p,{children:["This blueprint demonstrates how to implement ",(0,i.jsx)(n.strong,{children:"Pattern-Based Action Gating"})," and ",(0,i.jsx)(n.strong,{children:"Dynamic Risk ABAC"})," to protect critical infrastructure."]}),"\n",(0,i.jsx)(n.h2,{id:"architecture",children:"Architecture"}),"\n",(0,i.jsx)(n.mermaid,{value:"%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#059669', 'primaryTextColor': '#f1f5f9', 'primaryBorderColor': '#047857', 'lineColor': '#6ee7b7', 'secondaryColor': '#1e293b', 'tertiaryColor': '#0f172a'}}}%%\nflowchart TD\n A[\"SRE Agent Request\"] --\x3e B{\"Control Zero Gateway\"}\n B --\x3e|Check Pattern| C[\"Block: rm -rf, drop table, delete firewall\"]\n B --\x3e|Check Context| D[\"Allow only if Danger-Level: low OR User: Admin\"]\n C --\x3e|Match| E[Denied tool call removed and replaced with a policy-denial message]\n D --\x3e|Match| F[Execute Command]\n\n style A fill:#1e293b,stroke:#6ee7b7,color:#f1f5f9\n style B fill:#059669,stroke:#047857,color:#ffffff\n style C fill:#059669,stroke:#047857,color:#ffffff\n style D fill:#0f172a,stroke:#6ee7b7,color:#f1f5f9\n style E fill:#1e293b,stroke:#6ee7b7,color:#f1f5f9\n style F fill:#1e293b,stroke:#6ee7b7,color:#f1f5f9"}),"\n",(0,i.jsx)(n.h2,{id:"1-master-policy-definition",children:"1. Master Policy Definition"}),"\n",(0,i.jsxs)(n.p,{children:["Create a policy that gates the ",(0,i.jsx)(n.code,{children:"sys:execute"})," tool based on regex patterns and session risk attributes."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n "name": "sre-safety-policy",\n "priority": 5000,\n "rules": [\n {\n "id": "block-destructive-commands",\n "effect": "deny",\n "principals": ["*"],\n "actions": ["sys:execute"],\n "resources": ["*"],\n "conditions": {\n "danger_level": "critical"\n }\n },\n {\n "id": "deny-unauthorized-sre",\n "effect": "deny",\n "principals": ["group:intern"],\n "actions": ["sys:*"],\n "resources": ["*"]\n }\n ]\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"2-implementation",children:"2. Implementation"}),"\n",(0,i.jsx)(n.h3,{id:"python-prototype",children:"Python Prototype"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'import os\nimport requests\nfrom openai import OpenAI\n\n# Initialize Client pointing to Control Zero Gateway\nclient = OpenAI(\n api_key="ignored", # Real key injected by Gateway secret storage\n base_url="http://cz-gateway:8001/v1",\n default_headers={\n "X-ControlZero-User-ID": "sre-user-1",\n "X-ControlZero-User-Group": "sre-ops",\n "X-ControlZero-Environment": "production"\n }\n)\n\ndef run_command(command: str):\n # Pre-flight: Assess danger level (This can be done by a small local LLM or regex)\n is_destructive = any(p in command for p in ["rm -rf", "drop", "delete"])\n\n headers = {\n "X-ControlZero-Danger-Level": "critical" if is_destructive else "low"\n }
1\n\n try:\n response = client.chat.completions.create(\n model="gpt-5.4",\n messages=[{"role": "user", "content": f"Execute this: {command}"}],\n tools=[{\n "type": "function",\n "function": {\n "name": "sys:execute",\n "parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}}\n }\n }],\n extra_headers=headers # Inject risk context\n )\n return response\n except Exception as e:\n return f"Governance Intervention: {e}"\n\n# Scenario A: Safe command\nprint(run_command("ls -la")) # Allowed\n\n# Scenario B: Destructive command (Accidental halluncination)\nprint(run_command("rm -rf /app/data")) # BLOCKED by Control Zero\n'})}),"\n",(0,i.jsx)(n.h2,{id:"3-validation-checklist",children:"3. Validation Checklist"}),"\n",(0,i.jsxs)(n.ul,{className:"contains-task-list",children:["\n",(0,i.jsxs)(n.li,{className:"task-list-item",children:[(0,i.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,i.jsx)(n.strong,{children:"Identity Check"}),": Verify that a user in the ",(0,i.jsx)(n.code,{children:"intern"})," group is blocked from even simple ",(0,i.jsx)(n.code,{children:"ls"})," commands."]}),"\n",(0,i.jsxs)(n.li,{className:"task-list-item",children:[(0,i.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,i.jsx)(n.strong,{children:"Risk Check"}),": Verify that ",(0,i.jsx)(n.code,{children:"rm -rf"})," is blocked even when requested by an ",(0,i.jsx)(n.code,{children:"admin"})," user if the ",(0,i.jsx)(n.code,{children:"Danger-Level"})," is set to ",(0,i.jsx)(n.code,{children:"critical"}),"."]}),"\n",(0,i.jsxs)(n.li,{className:"task-list-item",children:[(0,i.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,i.jsx)(n.strong,{children:"Audit Trail"}),": Check the audit log store for entries where ",(0,i.jsx)(n.code,{children:"policy_decision = 'deny'"}),"."]}),"\n"]})]})}function u(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},28453(e,n,t){t.d(n,{R:()=>s,x:()=>l});var r=t(96540);const i={},o=r.createContext(i);function s(e){const n=r.useContext(o);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.