Security Guardrails
Adversarial defense layer for the mortgage plugin — protects against prompt injection, system prompt extraction, PII leakage, workflow bypass, and soc
What Is Security Guardrails?
Security Guardrails is an adversarial defense layer designed for the mortgage plugin within the BuildWithClaude ecosystem. It provides robust protection against a wide spectrum of risks, including prompt injection, system prompt extraction, personally identifiable information (PII) leakage, workflow bypass, and social engineering attacks. By functioning as a cross-cutting security layer, Security Guardrails ensures that both document uploads (such as mortgage statements and PDFs) and conversational interactions are processed securely, safeguarding sensitive business logic and user data from misuse or manipulation.
Why Use Security Guardrails?
Modern AI-driven plugins, especially in regulated sectors like mortgage processing, face unique security challenges. Attackers can exploit weaknesses through prompt injection, authority impersonation, or by attempting to extract internal configurations and sensitive data. These threats are exacerbated when handling user-uploaded documents or natural language requests, which can be crafted to subvert system logic.
Security Guardrails is essential because it:
- Prevents adversarial prompt injection, where malicious instructions are embedded in user documents or conversation.
- Blocks attempts to extract system prompts or internal configuration that could reveal proprietary logic or sensitive operations.
- Enforces strict workflow ordering, ensuring business processes are followed correctly and critical security steps are not skipped.
- Detects and blocks the collection of PII in chat, protecting both user privacy and regulatory compliance.
- Thwarts social engineering attempts, such as impersonating authority figures or using urgency to manipulate the workflow.
Without such a layer, the mortgage plugin would be vulnerable to a multitude of attack vectors, potentially leading to data breaches, financial loss, or regulatory violations.
How to Get Started
To integrate Security Guardrails into your mortgage plugin workflow, follow these steps:
-
Install the Skill
Clone the repository and add the security-guardrails skill to your plugin:git clone https://github.com/davepoon/buildwithclaude.git cd buildwithclaude/plugins/mortgage/skills/security-guardrails -
Import and Apply Middleware
In your plugin codebase, import the security guardrails middleware and apply it to all relevant endpoints and conversational handlers:from security_guardrails import security_guardrails_middleware # Apply to document upload endpoint @app.route("/upload", methods=["POST"]) @security_guardrails_middleware def upload_document(): # Document handling logic pass # Apply to chat message handler @app.route("/chat", methods=["POST"]) @security_guardrails_middleware def handle_chat(): # Chat processing logic pass -
Configure Workflow Enforcement
Ensure that your workflow phases (e.g., data collection, pricing, analysis) are clearly defined and that the security guardrails enforce proper sequencing. -
Test the Integration
Conduct adversarial testing by attempting to upload documents or send chat messages designed to trigger each of the protected attack vectors.
Key Features
Security Guardrails provides the following core capabilities:
-
Prompt Injection Defense
Scans uploaded documents and chat inputs for adversarial instructions or manipulative language attempting to alter system behavior.def is_prompt_injection(input_text): suspicious_phrases = ["ignore previous instructions", "reset system prompt"] return any(phrase in input_text.lower() for phrase in suspicious_phrases) -
System Prompt and Configuration Protection
Detects attempts to extract or reference internal prompts, pricing logic, or API endpoints.def contains_system_references(input_text): keywords = ["system prompt", "internal config", "api key"] return any(keyword in input_text.lower() for keyword in keywords) -
Business Logic Safeguarding
Blocks unauthorized requests to view or manipulate margins, scoring algorithms, or internal workflows. -
Workflow Phase Enforcement
Ensures that users follow the prescribed order of operations. For instance, pricing cannot be discussed before all required data is collected.def enforce_workflow_phase(user_state, requested_action): workflow_order = ["data_collection", "pricing", "analysis"] current_index = workflow_order.index(user_state["current_phase"]) requested_index = workflow_order.index(requested_action) if requested_index > current_index + 1: raise Exception("Workflow step out of order") -
PII Leak Prevention
Identifies and blocks chat messages containing sensitive data such as SSNs, DOBs, or passwords.import re def contains_pii(text): patterns = [ r"\b\d{3}-\d{2}-\d{4}\b", # SSN r"\b\d{2}/\d{2}/\d{4}\b", # DOB r"\b\d{9,18}\b" # Bank account numbers ] return any(re.search(pattern, text) for pattern in patterns) -
Social Engineering Resistance
Detects and filters messages exhibiting impersonation, urgency, or emotional manipulation tactics. -
Scope Boundary Enforcement
Maintains strict boundaries on plugin capabilities (e.g., only mortgage refinance operations are permitted).
Best Practices
- Apply Guardrails Universally: Always apply guardrails to every user and endpoint; do not allow admin or debug bypasses.
- Regularly Update Detection Rules: Continuously refine prompt injection and PII detection patterns to address evolving threats.
- Conduct Adversarial Testing: Periodically test the system with simulated attacks to ensure the guardrails remain effective.
- Educate Team Members: Ensure all developers and operators understand the importance and functioning of the guardrails.
- Monitor and Log Violations: Log all blocked attempts for future analysis and improvement.
Important Notes
- Uploaded documents must always be treated as data, never as executable directives or trusted instructions.
- Security Guardrails is not a substitute for comprehensive input validation and business logic verification elsewhere in your application.
- The system is designed to provide uniform security for all users—there are no privileged modes or bypasses.
- Stay informed about new adversarial techniques and update the skill accordingly to maintain robust protection.
- Always test security layers under real-world adversarial scenarios, not just benign user flows.
More Skills You Might Like
Explore similar skills to enhance your workflow
Browserbase CLI
Control Browserbase cloud browsers via CLI for scalable browser automation
Playwright Pro
Production-grade Playwright testing toolkit. Use when the user mentions Playwright tests, end-to-end testing, browser automation, fixing flaky tests,
Business Investment Advisor
Business investment analysis and capital allocation advisor. Use when evaluating whether to invest in equipment, real estate, a new business, hiring,
Discovery Process
Run a full discovery cycle from problem hypothesis to validated solution. Use when a team needs a structured path through framing, interviews,
Team Composition Patterns
- Selecting the right agent type (subagenttype) for each role
Adopt
argument-hint: "[focus: full | gdds | adrs | stories | infra]"