Inferensys

Prompt

Network Policy Change Impact Analysis Prompt

A practical prompt playbook for using Network Policy Change Impact Analysis Prompt in production AI workflows to map rule changes to affected service communication paths and identify unintended exposure.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and limitations for the Network Policy Change Impact Analysis Prompt.

Network security engineers and platform teams use this prompt to analyze firewall rule diffs, Kubernetes NetworkPolicy changes, or security group modifications before deployment. The core job-to-be-done is translating a low-level policy diff into a high-level service impact assessment. Instead of manually tracing every CIDR block, port, and label selector to understand which service-to-service communication paths are affected, the engineer provides the diff, a service inventory, and the change rationale. The prompt returns a structured analysis that maps each rule change to the specific service pairs impacted, identifies unintended exposure or isolation, flags egress rule gaps, and assigns a risk severity to each finding. This turns a pre-deployment review that might take hours of cross-referencing architecture diagrams into a consistent, repeatable analysis that surfaces hidden blast radius before the change is applied.

This prompt assumes you have three concrete inputs ready: the policy diff itself (whether from git diff, a firewall management console, or a Kubernetes manifest comparison), a service inventory or architecture map that defines known service identities and their expected communication patterns, and the intended change rationale (such as a ticket description or change request summary). Without these inputs, the model cannot ground its analysis in your actual architecture and will produce generic or misleading findings. The prompt is designed for pre-deployment review, not for analyzing already-deployed policies or for generating new policy rules from scratch. It also does not replace penetration testing, runtime network monitoring, or eBPF-based flow analysis—it operates purely on the static policy definitions you provide.

Do not use this prompt when the policy change is trivial and well-understood by the team, such as adding a single known IP to an existing allowlist with no architectural implications. Do not use it as a substitute for a security architect's judgment on complex zero-trust migrations or when the service inventory is stale or incomplete—garbage in, garbage out applies with full force here. Every finding marked critical or high severity must receive human review before the change is applied. The prompt's risk severity assignments are a starting point for triage, not an automated approval gate. Wire the output into your change management workflow so that high-severity findings block the deployment until a qualified engineer acknowledges them.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Network Policy Change Impact Analysis Prompt fits your current workflow, inputs, and risk tolerance.

01

Good Fit: Structured Policy Diffs

Use when: you have a clean diff of firewall rules, network policies, or security group changes in a machine-readable format (JSON, YAML, CSV). The prompt excels at mapping rule modifications to affected service pairs and identifying unintended exposure. Guardrail: pre-process raw configs into a structured diff before calling the prompt to reduce hallucination risk.

02

Bad Fit: Raw Config Snapshots Without Diffs

Avoid when: you only have a full configuration snapshot with no computed diff. The prompt is designed for change impact analysis, not baseline architecture review. Without a clear before/after, the model will invent hypothetical changes or miss the actual delta. Guardrail: always compute the diff externally and pass only the changed rules plus their immediate context.

03

Required Inputs

What you must provide: a structured diff showing added, removed, and modified rules with source/destination CIDRs, ports, protocols, and action fields. Service topology context (which services talk to which) dramatically improves accuracy. Guardrail: if service topology is unavailable, explicitly instruct the model to flag assumptions and mark unknown communication paths as 'requires human verification'.

04

Operational Risk: False Confidence on Complex Topologies

What to watch: the model may assert service communication paths with high confidence even when the provided topology context is incomplete. This is especially dangerous in microservice environments with indirect dependencies. Guardrail: require the output to include a confidence level per finding and automatically escalate low-confidence service-pair mappings to a human reviewer before any remediation action.

05

Operational Risk: Egress Rule Gap Blindness

What to watch: the prompt may focus heavily on ingress exposure and under-analyze egress rule changes that could indicate data exfiltration paths or C2 communication channels. Guardrail: add explicit egress analysis instructions in the prompt and include a dedicated egress risk section in the output schema with severity scoring.

06

Operational Risk: Stale Topology Context

What to watch: if the service topology context provided to the prompt is outdated, the impact analysis will be wrong. Services may have been added, removed, or re-architected since the topology was last mapped. Guardrail: timestamp all topology context, include a freshness check in the prompt instructions, and reject analysis when topology data is older than your change window threshold.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for analyzing network policy changes and their impact on service communication paths.

This prompt template is designed to be copied directly into your AI harness, LLM playground, or application code. It accepts a network policy diff, an inventory of affected services, and optional environment context, then produces a structured impact analysis. Every placeholder in square brackets must be replaced with actual data before the prompt is sent to the model. The template enforces a strict output schema so downstream systems can parse the results without custom post-processing.

text
You are a network security reviewer analyzing a firewall or network policy change.

Your task is to map the rule changes in the provided diff to affected service communication paths, identify unintended exposure or isolation, flag egress rule gaps, and assign a risk severity to each finding.

## INPUT

**Network Policy Diff:**
[POLICY_DIFF]

**Service Inventory (name, IP/CIDR, port, protocol, role):**
[SERVICE_INVENTORY]

**Environment Context (e.g., production, staging, PCI scope, multi-account):**
[ENVIRONMENT_CONTEXT]

**Previous Policy Version (optional, for comparison):**
[PREVIOUS_POLICY]

## CONSTRAINTS

- Only report findings that are supported by specific rule changes in the diff.
- Do not speculate about services not listed in the service inventory.
- If a rule change affects multiple service pairs, list each pair separately.
- For each finding, cite the exact rule line or rule ID from the diff.
- If no high or critical findings exist, state that explicitly rather than inventing risks.
- Flag any egress rules that appear to allow traffic to `0.0.0.0/0` or broad CIDR ranges without documented justification.

## OUTPUT SCHEMA

Return a JSON object with the following structure:

{
  "analysis_summary": {
    "total_rules_changed": <integer>,
    "total_affected_service_pairs": <integer>,
    "highest_risk_level": "critical" | "high" | "medium" | "low" | "none",
    "requires_human_review": <boolean>
  },
  "findings": [
    {
      "finding_id": "string",
      "severity": "critical" | "high" | "medium" | "low",
      "rule_reference": "string (line number or rule ID from diff)",
      "change_type": "added" | "modified" | "removed",
      "affected_service_pair": {
        "source": "string (service name from inventory)",
        "destination": "string (service name or CIDR)",
        "protocol": "string",
        "port": "string or integer"
      },
      "impact_description": "string (what changed and why it matters)",
      "risk_rationale": "string (why this severity was assigned)",
      "unintended_exposure": <boolean>,
      "unintended_isolation": <boolean>,
      "egress_gap": <boolean>,
      "recommendation": "string (actionable fix or verification step)"
    }
  ],
  "egress_rule_gaps": [
    {
      "rule_reference": "string",
      "destination": "string",
      "gap_description": "string",
      "risk": "string"
    }
  ],
  "services_without_explicit_rules": [
    "string (service names from inventory not referenced in any rule)"
  ]
}

## RISK SEVERITY DEFINITIONS

- **critical**: Unrestricted exposure of sensitive services to public or untrusted networks; removal of isolation for PCI/PII-scoped services; egress to `0.0.0.0/0` from high-privilege services.
- **high**: Broadening of access to internal services beyond documented requirements; removal of egress restrictions for services with sensitive data access.
- **medium**: Rule modifications that expand port ranges or protocol access without clear justification; stale rules that should be audited.
- **low**: Cosmetic changes, rule reordering, comment updates, or changes that do not alter traffic flow.

## EXAMPLES

[FEW_SHOT_EXAMPLES]

## INSTRUCTIONS

1. Parse the policy diff and identify every added, modified, or removed rule.
2. For each rule change, determine which service pairs from the inventory are affected.
3. Assess whether the change introduces unintended exposure, unintended isolation, or an egress gap.
4. Assign a severity based on the definitions above.
5. Populate the output JSON completely. Do not omit fields.
6. If the diff is empty or contains no rule changes, return an empty findings array with `highest_risk_level: "none"`.

To adapt this template for your environment, replace [SERVICE_INVENTORY] with a structured list of your services including their network identifiers, roles, and data classification levels. The [ENVIRONMENT_CONTEXT] placeholder should include whether the change targets production, PCI-scoped networks, or multi-account deployments, as this directly affects severity assignment. The optional [FEW_SHOT_EXAMPLES] placeholder can contain one or two example input-output pairs showing correct severity calibration for your organization's risk tolerance. If your policy management system uses rule IDs rather than line numbers, adjust the rule_reference field description accordingly. For high-risk environments, wire the requires_human_review flag into your deployment pipeline so any analysis returning true blocks the apply step until a human approves.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before sending.

PlaceholderPurposeExampleValidation Notes

[NETWORK_POLICY_DIFF]

The raw diff of network policy or firewall rule changes to analyze

diff --git a/policies/prod/ingress.yaml b/policies/prod/ingress.yaml ...

Must be non-empty string. Parse check: contains at least one '+' or '-' line. Reject if only whitespace or no-op diff.

[SERVICE_TOPOLOGY]

Current service-to-service communication map with ports, protocols, and namespaces

{"services": [{"name": "api-gateway", "namespace": "prod", "exposes": [{"port": 443, "protocol": "TCP"}]}]}

Must be valid JSON with 'services' array. Each service requires 'name', 'namespace', and 'exposes' fields. Null allowed if topology unknown; prompt must then flag topology gaps.

[ENVIRONMENT_CONTEXT]

Deployment environment identifier and risk tier

{"environment": "production", "tier": "critical", "compliance": ["PCI-DSS"]}

Must include 'environment' string. 'tier' must be one of: critical, high, medium, low, development. Reject unknown tier values.

[CHANGE_REQUEST_ID]

Unique identifier linking this analysis to a change ticket or PR

CHG-2025-00421

Must match pattern ^[A-Z]+-\d+-\d+$. Used for traceability in output. Reject if missing or malformed.

[PREVIOUS_RULE_STATE]

The network policy configuration before the change, for comparison context

apiVersion: networking.k8s.io/v1 kind: NetworkPolicy ... spec: {ingress: [{from: [{podSelector: {matchLabels: {app: frontend}}}]}]}

Must be non-empty string. If unavailable, set to null and prompt must note that pre-change comparison is limited. Validate it parses as YAML if Kubernetes policy.

[KNOWN_EXCEPTIONS]

List of service pairs or paths that are known exceptions and should not trigger alerts

["monitoring-agent->all:8080", "backup-job->storage:443"]

Must be array of strings in format 'source->destination:port'. Null allowed. If provided, prompt must suppress findings matching these patterns.

[OUTPUT_SCHEMA]

Expected JSON schema for the structured analysis output

{"affected_service_pairs": [...], "risk_findings": [...], "egress_gaps": [...], "severity_summary": {...}}

Must be valid JSON Schema object. Required fields: affected_service_pairs, risk_findings, severity_summary. Validate with JSON Schema validator before prompt assembly.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Network Policy Change Impact Analysis prompt into a CI/CD pipeline or security review workflow with validation, retries, and human approval gates.

This prompt is designed to run as a gating step in a CI/CD pipeline when network policy manifests (e.g., Kubernetes NetworkPolicy, Calico, Cilium, or cloud firewall rules) are modified in a pull request. The implementation harness should extract the diff of the changed policy files, assemble the required context (current policy state, service dependency map, and organizational security constraints), and invoke the model. The output must be parsed into a structured risk report that downstream systems can act on: blocking the PR, creating Jira tickets, or notifying the security team. Because network policy misconfigurations can cause both security breaches and production outages, the harness must treat this as a high-risk workflow with mandatory human review for any finding rated CRITICAL or HIGH severity.

Integration pattern: Use a webhook or CI plugin that triggers on changes to paths like **/network-policies/**, **/firewall/**, or **/security-groups/**. The harness should: (1) extract the policy diff using git diff against the base branch; (2) retrieve the current service-to-service communication map from a service mesh control plane API, CMDB, or a pre-built dependency graph file in the repository; (3) inject the organizational security constraints from a policy-as-code repository (e.g., "no egress to 0.0.0.0/0", "all inter-namespace traffic requires explicit allow rules"); (4) call the model with the assembled prompt; (5) parse the JSON output and validate it against the expected schema using a JSON Schema validator; (6) on parse failure, retry once with a repair prompt that includes the validation error; (7) route CRITICAL and HIGH findings to a human approval queue (e.g., a GitHub Review or ServiceNow change request) and auto-approve LOW and informational findings with a comment on the PR.

Model choice and latency budget: Use a model with strong structured output and reasoning capabilities, such as Claude 3.5 Sonnet or GPT-4o, with the response_format set to json_schema or the equivalent structured output mode. Set a timeout of 30 seconds and a token budget of 4000 output tokens. For large policy sets, split the diff into chunks of no more than 10 rule changes per invocation and merge the results. Logging and audit trail: Log the full prompt, raw model response, parsed output, and validation result to an immutable audit store. This is critical for compliance and post-incident review. Include the diff SHA, PR number, and timestamp in the log metadata. Eval gate: Before deploying this harness to production, run it against a golden dataset of 20 known policy changes (10 safe, 10 risky) and measure precision and recall on CRITICAL/HIGH findings. Require 100% recall on known breaking changes before enabling the blocking gate. What to avoid: Do not auto-apply remediation suggestions. Do not run this prompt on every commit if policy files haven't changed. Do not skip the service dependency map injection—without it, the model cannot accurately assess blast radius and will produce generic, low-value output.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the structured JSON response returned by the Network Policy Change Impact Analysis Prompt. Use this contract to parse, validate, and integrate the model output into downstream security workflows or dashboards.

Field or ElementType or FormatRequiredValidation Rule

change_summary

string

Must be a non-empty string under 500 characters summarizing the net effect of the policy diff.

risk_severity

enum: CRITICAL, HIGH, MEDIUM, LOW, INFO

Must match one of the allowed enum values. CRITICAL is reserved for changes that open all ports or disable all policies.

affected_service_pairs

array of objects

Array must contain at least 1 object. Each object must have valid 'source_service' and 'destination_service' string fields matching [a-z0-9-]+.

affected_service_pairs[].source_service

string

Must match the Kubernetes service name or workload label from the input manifest. Regex: ^a-z0-9?$.

affected_service_pairs[].destination_service

string

Must match the Kubernetes service name or workload label from the input manifest. Regex: ^a-z0-9?$.

affected_service_pairs[].new_communication_path

enum: ALLOWED, DENIED, RESTRICTED

Must be one of the three allowed values. RESTRICTED indicates a port or CIDR range was narrowed but not fully denied.

unintended_exposure

array of strings

If present, each string must describe a specific CIDR, port, or namespace that became more permissive. Null or empty array is allowed if no exposure detected.

egress_gap_flags

array of objects

Each object must have 'destination_cidr' (string, CIDR notation) and 'missing_rule_description' (string) fields. Null allowed if no egress gaps found.

PRACTICAL GUARDRAILS

Common Failure Modes

Network policy changes are high-stakes. A single misconfigured rule can partition services, expose internal endpoints, or silently drop critical traffic. These are the most common failure modes when using LLMs to analyze policy changes—and how to catch them before they reach production.

01

Hallucinated Service Dependencies

Risk: The model invents communication paths between services that don't exist in your actual topology, producing a false-positive impact map that wastes engineering time. Guardrail: Always provide a current service dependency graph or CMDB extract as grounding context. Require the model to cite specific source data for each claimed dependency. If no source data is available, the prompt must instruct the model to flag the gap rather than guess.

02

Missed Egress Rule Gaps

Risk: The analysis focuses narrowly on the changed ingress rules and ignores whether the affected service can still reach its own dependencies (DNS, databases, auth services) after the change. Guardrail: Structure the output schema to require explicit egress impact analysis for every affected service. Include a checklist of required egress targets (monitoring, logging, secrets management) that must be verified as still reachable.

03

CIDR Range Misinterpretation

Risk: The model treats overlapping or adjacent CIDR blocks as equivalent, misclassifying the blast radius of a rule change. A /24 to /16 expansion looks like a minor edit but can expose an entire subnet. Guardrail: Include a CIDR normalization step in the prompt that expands ranges and checks for containment relationships. Require the output to flag any rule where the effective IP range changed by more than 20% of the original scope.

04

Rule Ordering Blindness

Risk: The model analyzes a single rule change in isolation without considering its position in the rule chain. A new deny rule inserted before an existing allow rule silently overrides it. Guardrail: Require the full rule set as input, not just the diff. Instruct the model to simulate rule evaluation order and flag any existing rules that become unreachable or overridden by the change. Include a shadowed-rule detection step.

05

Environment Parity Assumption

Risk: The model assumes staging and production topologies are identical and applies the same impact analysis to both. A change safe in staging can be catastrophic in production due to different CIDR allocations or service instance counts. Guardrail: Include environment-specific topology metadata in the input. Require the output to include an environment-specific risk score. Add a validation step that compares the analysis against a known-good staging dry-run result before production approval.

06

Implicit Deny Oversight

Risk: The model focuses on explicit rule changes and ignores the implicit deny-all default at the end of the rule chain. Removing an allow rule without adding a replacement can isolate a service entirely. Guardrail: Require the output to include a connectivity matrix showing allowed paths before and after the change. Flag any service that loses all ingress or egress paths, even if no explicit deny rule was added. Include a pre-apply connectivity test recommendation.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of 10-20 known policy diffs with expected findings. Each diff should have pre-labeled affected service pairs, risk severities, and exposure classifications to measure precision, recall, and severity agreement.

CriterionPass StandardFailure SignalTest Method

Affected Service Pair Recall

= 0.90 recall against golden labels for all service pairs that should be flagged

Output misses a service pair that the golden dataset labels as affected; recall drops below 0.85

Count true positives and false negatives across the golden dataset; compute recall per diff and macro-average

Affected Service Pair Precision

= 0.85 precision; no more than 15% of flagged service pairs are false positives

Output flags a service pair not present in golden labels; precision falls below 0.80

Count true positives and false positives per diff; compute precision and flag diffs where false positive rate exceeds threshold

Risk Severity Agreement

= 0.80 exact-match agreement with golden severity labels (CRITICAL, HIGH, MEDIUM, LOW)

Severity assigned differs from golden label by more than one level or agreement rate drops below 0.75

Compare each finding's severity to the golden label; compute exact-match rate and adjacent-match tolerance

Exposure Classification Accuracy

= 0.90 accuracy for unintended-exposure vs. intended-exposure vs. no-change classifications

Output classifies an intended exposure as unintended or vice versa; accuracy below 0.85

Binary or multi-class comparison per service pair against golden exposure labels; compute per-class precision and recall

Egress Rule Gap Detection

= 0.80 recall for golden-labeled egress gaps; no critical egress gap missed

Output fails to flag a golden-labeled egress gap, especially one marked CRITICAL in the golden set

Filter golden dataset to egress-gap-labeled items; verify each is present in output with matching service pair

Isolation Risk False Positive Rate

<= 0.10 false positive rate for isolation risk flags

Output flags isolation risk for a service pair the golden dataset labels as no-isolation-risk; rate exceeds 0.15

Count isolation-risk flags not in golden labels; divide by total isolation flags raised; flag if rate exceeds threshold

Output Schema Compliance

100% of outputs parse successfully against the expected [OUTPUT_SCHEMA]; no missing required fields

JSON parse failure, missing required field, or field type mismatch in any golden dataset run

Validate each output against the JSON schema; reject any output that fails structural validation

Evidence Grounding Completeness

= 0.90 of findings include a non-empty rule reference or diff line citation in the evidence field

Findings with null, empty, or placeholder evidence strings exceed 10% of total findings

Parse each finding's evidence field; count null or empty values; compute ratio of ungrounded findings

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single firewall rule diff. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with no schema enforcement. Paste the diff and ask for affected service pairs and risk severity in plain text. Accept a paragraph or bullet list as output.

Watch for

  • The model inventing service names not present in the diff
  • Missing egress rule gaps because the prompt doesn't enforce exhaustive checks
  • Overly broad risk labels without evidence from the rule change
  • No structured output, making downstream automation difficult
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.