AI agents

Prompt Injection in AI Apps: Protect Tools and Customer Data

An AI app may read a webpage, uploaded document or customer message containing instructions written by someone else. Prompt injection attempts to make that content control the assistant. Treating the text as untrusted input is more reliable than assuming a stronger instruction will always defeat it.

Identify untrusted entry points

List every source the assistant reads: search results, support tickets, PDFs, database fields and tool responses. Even a document stored in your own system may contain text supplied by an external person with different intentions.

Use a test document that asks the assistant to reveal secrets or send data elsewhere. The test should confirm that document content cannot grant new permissions, change the authenticated user or choose an unapproved destination.

Keep enforcement outside the model

Validate tool arguments on the server and check authorization for each resource. Restrict external destinations where practical. An instruction in a retrieved page must not turn a read-only research tool into an unrestricted network or file-access tool.

Keep credentials out of prompts and retrieved content. Supply secrets directly to the authorized backend integration when required. A model cannot disclose a credential it never receives, although other data still needs access controls.

Constrain the consequences

Start with read-only tools and narrow result fields. Require approval before sending messages, exporting data or changing permissions. Display the real destination and data involved, especially when an external document suggested the action.

Apply output checks appropriate to the destination. Escape generated HTML, validate links and reject unsupported structured fields. A plausible answer can still contain an unsafe URL or an action outside the user's request.

Test and respond

Add adversarial cases to release checks and record which safeguard blocked the action. Avoid claiming complete prevention: model behavior, tools and content change. A documented incident response path is part of the design.

If an unexpected action occurs, pause the affected integration, preserve necessary audit evidence and review its permissions. For a CloudWira-hosted interface, also inspect the external AI service and backend; the interface host is only one part of the system.

Follow an attack through a realistic document workflow

Suppose a support assistant retrieves an uploaded troubleshooting document. Most of the document describes an error, but one paragraph asks the assistant to ignore its instructions and export all customer records. That paragraph is content from an untrusted source. It is not an authorization from the account owner. The application should allow the assistant to quote or summarize it without allowing it to expand the tool permissions available for the task.

Draw the boundary between instructions supplied by your application and text supplied by customers, websites or retrieved files. Preserve source labels when passing text to the model. Do not concatenate everything into one indistinguishable instruction block. Clear labels can help the model reason correctly, but they are only one layer. Backend authorization must still prevent an unexpected record export even if the model follows the malicious text.

Reduce the amount an injected instruction can reach

Expose narrow tools that perform specific authorized operations. A lookup tool should obtain customer scope from the session and return only necessary fields. A message tool should not accept arbitrary recipients merely because a document contains an address. Keep secrets outside prompts and browser code. If the model does not need a credential to decide what to recommend, do not provide it as context.

Separate retrieval from execution where practical. An agent can prepare a proposal from untrusted material, while another deterministic step validates the proposed operation against the customer's request. Require review for consequential changes. This does not guarantee that every injected answer is prevented, but it reduces the consequences of a bad interpretation. The objective is to contain mistakes at enforceable boundaries rather than rely on perfect model obedience.

Create an adversarial test pack before launch

Include instructions hidden in document footnotes, copied support messages, page titles and tool results. Test a request to reveal secrets, a request to access another tenant and a request to send data to an unrelated destination. Include benign documents that discuss attacks so the agent can distinguish analysis from execution. Run these cases after changes to prompts, retrieval and tool descriptions.

Check side effects as well as text responses. A model saying it refused is not enough if a tool already returned private data. Assert that forbidden queries were denied, no unexpected external requests occurred and the audit trail identifies the attempt without storing excessive private content. Keep the test environment isolated from production accounts so an evaluation cannot accidentally contact customers or alter real records.

Prepare a response process for suspicious behavior

Give operators a way to stop tool execution, revoke affected access and preserve the minimum evidence needed for investigation. Record which input sources, tool calls and records were involved. Avoid automatically banning a customer solely because a document contains suspicious language; legitimate users may upload material describing an attack. Review intent and impact using the application's operating procedures.

After an incident, add a regression case and inspect the permission boundary that allowed the action. Rewriting the prompt may help, but a backend correction is often necessary when the tool accepted an unauthorized operation. CloudWira's managed app permissions and an external agent backend are separate controls; test both. Security improves when an injected instruction remains an untrusted sentence instead of becoming a new capability.

Should you block every document mentioning instructions?

No. Legitimate documents can discuss prompts, security tests or operating procedures. Treat their text as untrusted content and control what the agent can do with it. A blanket keyword block can interfere with useful work while missing attacks written in different language. The stronger boundary is a tool layer that cannot access or change resources outside the authorized task.

For a suspicious result, preserve the source reference and relevant action trace without exposing unnecessary customer material. Review whether any private data was returned or side effect occurred. Then correct the affected boundary and add a regression case. Keep customer communication factual and avoid claiming compromise from a suspicious sentence alone. The response should follow evidence of impact rather than the dramatic wording of the input.

Continue reading