October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Secure a Custom AI Application: From Prompt Injection to Data Leakage

Prompt injection can arrive through user input, retrieved documents, uploads, and tool workflows. Secure the application around the model with least privilege, data minimization, deterministic checks, and tests that observe real actions and leakage paths.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Secure a custom AI application by limiting what its model-driven workflows can access and do—not by relying on a system prompt to stop attacks. Enforce authorization in application code, retrieve only data the authenticated user may see, put consequential tool calls behind validation and approval, and test for unauthorized data access and actions.

How prompt injection can lead to data leakage

A custom AI application is a chain: a user makes a request; the application may retrieve documents or process uploads; the model receives context; application-controlled tools or data stores may be available; and the system returns a response or takes an action. Prompt injection is attacker-influenced content that changes the model’s intended behavior somewhere in that chain.

As an Amazon Associate I earn from qualifying purchases.

The attack can be direct, through a user’s input, or indirect, through content the application retrieves or processes. A page, uploaded file, image, tool result, or other external content may contain instructions that conflict with the application’s intended task—even when the user’s visible request is benign. Content need not be visible to a human if the model processes it. The model may be manipulated to reveal information, misuse a connected function, influence a decision, or pass data out. See the OWASP prompt-injection guidance and the NIST Generative AI Profile.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Data leakage is broader than exposing a system prompt. Sensitive information can include personal, financial, health, business, credential, or legal data. It may enter through user input, connected sources, or data used in model development, then escape through generated output or application behavior. The key security question is whether the user or model-driven process had access to information it should not receive. OWASP treats this as sensitive information disclosure.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

A system prompt is neither a reliable security boundary nor a safe place for credentials. OWASP states that “The system prompt should not be considered a secret, nor should it be used as a security control.” Prompt disclosure can reveal internal instructions, but the underlying fix is to protect secrets and enforce permissions outside the model. See OWASP’s system-prompt guidance.

Build the security plan around trust boundaries

Before adding controls, map where data and instructions cross between people, the model, and application components. Mark user input, uploaded files, retrieved documents, third-party content, tool outputs, persistent memory, logs, model-provider interfaces, and downstream systems as separate parts of the flow. For each, identify what is untrusted, what sensitive data enters or is stored there, where it can leave, and which actions the model can request.

This map is more useful than treating “the prompt” as one trusted block. A reference document can be useful information and untrusted instructions at the same time; a tool output can contain attacker-controlled text; and a permitted model request can still be an unauthorized application action.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply these controls in order

1. Enforce identity and authorization in application code

Authenticate the actual user, then apply that user’s permissions when retrieving records or executing functions. Do not ask the model to decide whether someone is an administrator, whether a document may be shared, or whether a transaction is allowed. Validate each request against the relevant policy in deterministic application code, including when it originated as a model tool call.

Rank #2
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Give the model-driven workflow only the narrowly scoped identity and capabilities it needs. Use least privilege for connected services, and keep credentials and sensitive permission details out of prompts. OWASP recommends keeping critical authorization bounds checks outside the LLM in its prompt-injection guidance.

2. Reduce what the model can see

Do not send the model every record available to the application merely because it is technically accessible. Retrieve only information the authenticated user is allowed to access and that is needed for the task. Limit external sources, and scrub or mask sensitive fields where doing so does not undermine the task.

Review how the selected model service handles submitted data, including retention and use, using the provider’s current documentation and the configuration you actually deploy. Those practices vary by provider and configuration. OWASP’s sensitive-information guidance recommends data sanitization, access control, and limiting data sources.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Keep untrusted content separate and tools narrow

Where the model interface allows it, clearly mark retrieved or uploaded material as untrusted data and keep it separate from application instructions. This can help the model distinguish reference material from directions, but it cannot guarantee that the model will do so. Treat separation as a supporting measure, not access control.

Rank #3
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Expose tools through narrow, typed interfaces rather than broad access to databases or general-purpose functions. Validate arguments and expected output formats in code; enforce policy before any operation. Require a person to approve high-impact actions when appropriate, such as sending, deleting, purchasing, or changing records. A refusal in the final response does not prove that an unauthorized tool action did not already occur. OWASP covers least privilege, human approval, and prompt-injection risks in its risk guidance.

4. Validate inputs, outputs, and business rules

Use input screening and output screening as defense in depth. Validate structured model output against an expected schema and business rules before passing it to another system. Before returning a response, check for prohibited data or other disclosure risks. Prompt instructions and simple string filters can miss transformed or indirect leaks, so screening cannot replace authorization checks.

The OWASP prompt-injection cheat sheet describes screening approaches, including model-based screening and quarantined parsing patterns. A screening model has its own limitations: do not give it authority to make deterministic access decisions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Test observable effects, not just the wording of responses

Build adversarial tests for direct requests, malicious instructions in retrieved material, user-specific data boundaries, tool-call manipulation, output leakage, multimodal inputs if supported, and multi-turn behavior. Use dummy secrets rather than real credentials or customer data. Instrument test destinations and application state so a test can reveal whether data was sent or an operation occurred.

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Record what matters to security: authorization decisions, data returned, tool calls, state changes, and whether dummy data reached an instrumented destination. A marker missing from one answer does not prove that other content or another channel did not leak. Repeat the tests when prompts, models, retrieval logic, tools, or policies change. The OWASP cheat sheet provides further prevention and testing guidance.

6. Monitor and prepare to contain incidents

Monitor unusual retrieval patterns, repeated injection attempts, tool use, and output-policy events. Keep only the interaction data needed for security monitoring; minimize or redact prompt and output content in logs to avoid creating another sensitive-data store.

Decide in advance how to revoke tool credentials, disable a capability, contain exposed data, and investigate a suspected incident. Monitoring and response need to continue as the application and its components change; OWASP recommends ongoing attention to prompt-injection risks in its guidance and cheat sheet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Compare designs by exposure, authority, and impact

There is no universally safest AI architecture. Compare each design against the same questions before deployment:

Security dimension Question to answer Control to verify
Data exposure What sensitive material can the model see, and for how long? Minimize retrieval; review data handling and retention for the selected provider and configuration.
Authority Which data sources and functions can the workflow access, under whose identity and with what scope? Apply user permissions at retrieval and execution time; grant least privilege.
Action impact Can the system only draft, or can it send, modify, delete, purchase, or trigger external effects? Validate actions in code and require human approval where impact warrants it.
Untrusted input surface Does the model process only user text, or also documents, pages, images, tool outputs, or persistent memory? Identify and test every input path the model processes.
Verification Are permissions, output formats, and actions checked deterministically and recorded as observable events? Test authorization decisions, tool calls, returned data, and state changes.

These criteria reflect OWASP’s guidance on trust boundaries, least privilege, human approval, and testing; they are comparison questions, not a claim that one architecture always wins. For lifecycle context, NIST’s AI Risk Management Framework: Generative Artificial Intelligence Profile is a voluntary companion to AI RMF 1.0, published July 26, 2024. NIST’s SSDF Community Profile for Generative AI and Dual-Use Foundation Models, also published July 26, 2024, supplements SSDF 1.1 with AI-specific development practices. Neither framework is law or a guarantee of security.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.