Explain a common security vulnerability with a broken code example and its fix side by side, showing the specific habit that closes the gap.
You are a secure coding instructor who teaches every vulnerability defensively, why ordinary, well-intentioned beginner code tends to create the opening by accident and exactly what habit closes it, never as an offensive technique to actually exploit something, because the goal is code that resists this class of problem, not code that demonstrates breaking it. My vulnerability is [VULNERABILITY:select:SQL injection,cross-site scripting,insecure input validation,hardcoded secrets and credentials], and my language is [LANGUAGE:select:Python,JavaScript,PHP,any language, just explain the general idea]. Explain [VULNERABILITY] starting from the specific, ordinary beginner habit that creates it, such as building a database query by directly joining a variable into a string instead of using a parameterized query, or inserting a piece of user-provided text directly into a page's HTML without escaping it first, described as an understandable shortcut rather than a careless mistake, since almost every beginner reaches for it before knowing better. Write one small, realistic code example in [LANGUAGE] that has this exact vulnerability, kept simple enough to see the actual problem clearly, and explain in plain language what could go wrong if untrusted input reached that code, described at the level of what category of harm becomes possible, data exposure, unintended commands running, a script executing in someone else's browser, rather than as a working attack payload. Then write the fixed version of the identical example, and name the specific change that closes the gap, a parameterized query instead of string building for SQL injection, escaping or a templating system that escapes by default for cross-site scripting, an allowlist of acceptable values instead of trusting the input's shape for insecure input validation, an environment variable or secret manager instead of a literal value in the code for hardcoded secrets. State plainly why this fix works structurally, not just that it happens to avoid the specific example shown, so the underlying principle transfers to code that looks different but has the same shape, treating anything coming from outside the program's own trusted code as data to be handled carefully rather than as safe instructions. Close by asking whether I want a second, different code example of the same vulnerability, in a different context than the first one, since seeing the identical underlying problem show up in two different-looking pieces of code is usually what makes a beginner start recognizing the pattern on their own instead of only recognizing the one example shown.
Use this prompt anywhere
10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.
Get Early AccessMost beginner security vulnerabilities are not carelessness, they are an understandable shortcut taken before knowing better, joining a variable straight into a database query string instead of using a parameterized query, or dropping user text directly into a page's HTML without escaping it first. Naming the shortcut honestly is what makes the fix stick, instead of a vague warning to just be more careful with user input.
This tool takes your chosen [VULNERABILITY] and writes one small, realistic broken example in your [LANGUAGE], explaining what category of harm becomes possible if untrusted input reached that exact code, described at the level of what goes wrong rather than as a working exploit. It then writes the fixed version of the identical example, names the specific structural change that closes the gap, a parameterized query, escaping by default, an allowlist, an environment variable instead of a hardcoded secret, and explains why that fix works structurally so it transfers to code that looks different but shares the same shape.
Every explanation stays defensive, teaching what closes the opening, never how to exploit one. Run it in the Dock Editor to build a set of vulnerabilities studied, pair with the sql query explainer for how a parameterized query actually gets built, or the api request explainer for where untrusted input usually enters an application first.
Bring this into the Dock Editor or into ChatGPT, Claude, or Gemini, then choose [VULNERABILITY] from SQL injection, cross-site scripting, insecure input validation, or hardcoded secrets and credentials.
Set [LANGUAGE] to Python, JavaScript, PHP, or a general language-agnostic explanation of the idea.
Get the specific, ordinary shortcut named that opens this vulnerability, explained as an understandable habit rather than carelessness.
Get one small code example with the actual vulnerability present, with the category of harm explained rather than a working exploit.
Get the identical example fixed, with the specific structural change named and why it transfers to differently-shaped code with the same underlying problem.
Learn what a common vulnerability looks like in realistic beginner code before it ships, catching the habit early instead of after something goes wrong in production.
Fill a real gap most self-taught paths skip entirely, learning why an ordinary shortcut creates a specific class of risk and what habit replaces it.
Get each core vulnerability explained through a broken-then-fixed example pair, building intuition before a course covers the same material formally.
Compare your own code's shape against the realistic broken examples shown here to recognize whether the same habit made it into your own project.
Discover more prompts that could help with your workflow.
Build a small working program that calls a real public API, with the request, response, and API key setup explained step by step.
Explain a core functional programming idea, such as pure functions or immutability, with a broken code example and its fixed version shown side by side.
Explain a built-in math function, square root, power, absolute value, or rounding, covering math and syntax, then generate practice calls to predict before revealing results.
10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.