Urgent.News

What's breaking now, across hundreds of outlets.

AI

Let the model propose, let code decide: a tiny action gate for prompt-injection-prone AI workflows

If your app feeds customer emails, tickets, web pages or files to an LLM and then does something with the output, you have a prompt-injection problem whether or not you've seen an attack yet. OWASP lists prompt injection as LLM01 in its 2025 Top 10 for LLM applications and says it is "unclear if there are fool-proof methods of prevention." The UK NCSC argued in December 2025 that it isn't…

This tutorial describes a method to prevent prompt injection attacks on LLM applications. Prompt injection occurs when an attacker manipulates the input to an AI system, causing it to perform unintended actions. The author emphasizes that while there may not be foolproof prevention methods, the goal is to minimize the impact of such attacks.

The tutorial presents a Python action gate implementation, a deterministic component that sits between an LLM's proposed actions and actual systems. The gate ensures that once untrusted content is present in the model's context, it cannot trigger consequential actions on its own. Instead, consequential actions are queued for human approval, and any attempt to send data outside an allowlist is refused.

The author defines a set of allowed actions, each associated with a boolean value indicating whether it can send output outside the system and whether it is consequential. Additionally, a list of allowed domains is provided for URL and email-related actions. If any domain in the proposal's context is not in this list, the action is refused.

The gate function takes a proposal and a boolean flag indicating whether the context contains untrusted content. It checks if the action is allowed and if any domains in the proposal are outside the allowlist. Based on these checks, the gate decides whether to run the action, send it to a human for review, or refuse it altogether. The decision is returned as a JSON object with the chosen action, verdict, reason, and any relevant arguments.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

The 12 Security Questions Most Japanese Companies Will Ask Before Approving Your AI Tool

This article was originally published on Medium . Nobody said no. Then a spreadsheet arrived. You found an AI tool that would genuinely help your team. You mentioned it to your manager.

  • Japanese companies require a 12-question security questionnaire before approving AI tools.
  • The questionnaire covers data usage, retention, storage, and encryption details.
  • Understanding and addressing the questions improves the chances of a smooth approval process.

AI impersonation fraud: a no-cost defence plan for small businesses

This month the US Department of Justice announced an indictment alleging that three foreign nationals used AI to impersonate CEOs and attorneys in a fraud scheme worth more than US$129 million, as…

  • Verify payment changes via secondary channel
  • Establish delay for urgent requests
  • Enable two-step verification for accounts

More from Friday 27 November →