惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
量子位
腾讯CDC
A
About on SuperTechFans
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
V
V2EX
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
罗磊的独立博客
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
有赞技术团队
有赞技术团队

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Inside Secure Playground — building an interactive prompt...
Harish Kotra · 2026-05-06 · via DEV Community
Cover image for Inside Secure Playground — building an interactive prompt-injection simulator

Harish Kotra (he/him)

This technical post walks through the design and implementation of Secure Playground: a local web app that simulates prompt-injection attacks against large language models and demonstrates simple defenses.

Goals

  • Provide a minimal, reproducible environment to test payloads and defensive strategies.
  • Make it easy to add new providers and run mutation-based red-team experiments.
  • Offer a leaderboard and scoring model so defenders can iterate on mitigations.

High-level architecture

High-level architecture

Key components

  • secure_playground/app/engine/agno_pipeline.py — orchestrates a set of agents (prompting, defense, scoring) using an Agno-style pipeline.
  • secure_playground/app/engine/redteam.py — mutation utilities to create adversarial payload variants.
  • secure_playground/app/providers/client.py — adapter/factory for OpenAI-compatible clients (OpenAI, Ollama, Featherless).
  • secure_playground/app/scoring/resilience.py — heuristics that turn model output into a numeric risk score.

Provider integration (example)

Providers are implemented as small adapters that expose a generate(prompt, system_prompt) method. The make_client factory returns an adapter based on a provider enum.

Excerpt (adapted from secure_playground/app/providers/client.py):

class OpenAICompatibleClient:
    def __init__(self, base_url: str | None, api_key: str, model: str) -> None:
        self.model = model
        self.client = OpenAI(base_url=base_url, api_key=api_key)

    def generate(self, prompt: str, system_prompt: str) -> str:
        res = self.client.responses.create(
            model=self.model,
            input=[
                {"role": "system", "content": system_prompt},
                {"role": "user", "content": prompt},
            ],
        )
        return res.output_text

Enter fullscreen mode Exit fullscreen mode

This pattern makes it straightforward to add other providers — implement the same generate signature and return plain text.

Pipeline & scoring

The pipeline accepts a SimulationInput object (user prompt + payload + defense configuration + provider) and returns a result object with score, blocked, and risk_flags. The scoring module encapsulates the heuristics used to judge whether a response constitutes a successful injection.

Design notes:

  • Keep the scoring deterministic and reproducible: small, well-defined heuristics are easier to iterate on and test than complex black-box models.
  • Treat mutations as a separate stage; the pipeline can replay/persist mutation results to build robust datasets.

Running experiments

  1. Start the app locally with uvicorn secure_playground.app.main:app --reload.
  2. Use the UI to select a seed payload and run the simulation. Optional: enable mutations to run multiple mutated variants.
  3. Export leaderboard entries (the store is a simple JSON file) and analyze patterns in successful payloads.

Extending the project

  • Add provider integrations (Anthropic, Vertex AI). Create wrappers that follow the generate(prompt, system_prompt) contract.
  • Add a Docker compose file that brings up a local Ollama image, the web app, and an experiment runner.
  • Implement a test harness and CI that rejects PRs which reduce resilience score on a canonical payload set.

Security & ethics

This project is intended for research and defensive work. Do not use it to target third-party services or to create exploit infrastructure. When adding new payloads or experiments, ensure they are stored locally and never posted to public services without explicit permission.

Screenshots

Output Example 1

Output Example 2

Github and more: https://www.dailybuild.xyz/project/123-secure-playground