By NHI Mgmt Group Editorial TeamBased on Flatt Security: “Securing LLM Function-Calling: Risks & Mitigations for AI Agents” (October 29, 2025)

TL;DR: LLM applications that call external tools expand capability, but they also enlarge the attack surface through SSRF, prompt injection, excessive delegation, and credential leakage, according to Flatt Security. The practical lesson is that tool design, context separation, and least privilege must be treated as core security architecture, not post-launch hardening.


At a glance

What this is: This article explains why LLM function-calling creates security risk when external tools, credentials, and model context are not separated cleanly.

Why it matters: IAM and security teams need to treat tool permissions, secret handling, and context boundaries as core control points for AI-enabled workflows, not as post-launch tuning.


Context

LLM applications become materially different once they can call tools, fetch URLs, or act on external systems. At that point, the governance problem is no longer only model output quality. It becomes a question of how much authority the application has, what data is allowed into the context window, and which trust boundaries separate the model from the systems it can reach.

The article focuses on AI agents and function-calling patterns that link LLMs to external services. That makes this an identity and access control issue as much as an application design issue, because the tool credentials, delegated permissions, and scope of context all determine how far a model can go when instructions are ambiguous or manipulated.


Key questions

Q: What breaks when LLMs can call external tools without strict boundaries?

A: The main failure is that the model can convert untrusted text into real action. Without strict boundaries, prompt injection, SSRF, and over-scoped credentials can push the system into unintended requests, data exposure, or destructive writes. The issue is not the LLM alone, but the delegated access path around it.

Q: Why do AI toolchains increase risk when credentials and context are mixed?

A: Because the model can only act on what enters its context, and anything in that context may be influenced by attacker-controlled text. If credentials or sensitive metadata are exposed there, malicious content can steer the model toward unintended access or disclosure. Mixing trust domains turns prompt injection into a control-plane problem, not just a content problem.

Q: How can security teams tell whether LLM tool boundaries are too loose?

A: The clearest sign is when one tool can both retrieve untrusted content and take privileged action based on it. If a single workflow can browse, infer intent, and then change state with little separation, the boundary is too weak. Another warning sign is when the same credential covers multiple unrelated tasks and environments.

Q: What should teams do when function-calling is needed for Git or web access?

A: Treat each integration as a separate delegated capability with its own scope, approval logic, and offboarding path. Git write access, URL fetching, and administrative actions should not share the same identity or token. That keeps a compromised or confused model from turning one task into broader system reach.


Technical breakdown

Why function-calling expands the attack surface

Function-calling lets an LLM choose a registered tool and pass arguments to it, after which the application executes the action outside the model. That architecture creates a new trust chain: prompt, tool selection, credentialed execution, and response injection back into context. The risk is not the model itself but the authority wrapped around it. If the tool can access internal services, Git hosting, or URLs, the LLM can be induced to reach places a normal user session would never touch. That is why the design must treat every tool as an access boundary, not just an integration layer.

Practical implication: define each tool as a separately governed access path and review its permissions before allowing LLM-mediated execution.

Least privilege for AI tools and credentials

The article’s central control recommendation is least privilege. In function-calling systems, the LLM often operates as a proxy for the user, but proxy does not justify broad rights. Fine-grained tokens are safer than broad tokens because they constrain what the tool can do even when the model misreads intent or ingests malicious instructions. This matters most when the LLM can create issues, modify repositories, or trigger administrative actions. If the credential can do too much, prompt injection becomes privilege amplification rather than just bad text handling.

Practical implication: scope tool credentials to the smallest action set needed for the specific workflow and avoid generic high-power tokens.

Context window separation and boundary hygiene

The article treats the context window as a security boundary because anything placed there is potentially reachable by the model and influenced by injected instructions. That means secrets, sensitive metadata, and unrelated internal content should not be passed through the model just because the application can technically handle it. Separating trusted execution logic from model-facing context reduces the chance that a prompt leak becomes a secret leak. This is especially important when external content is fetched into the same flow as credentialed actions, because hostile text can steer both information retrieval and execution.

Practical implication: keep credentials and sensitive control data outside the model context and only expose the minimum task data needed for execution.


Threat narrative

Attacker objective: The attacker wants the LLM to perform actions or disclose data outside the intended task boundary by abusing delegated tool access.

  1. Entry occurs through untrusted external content or user-provided URLs that the LLM is asked to process, creating an opening for SSRF or prompt injection.
  2. Credentialed execution follows when the model calls a tool with permissions broader than the task requires, turning ambiguous instructions into real external actions.
  3. Escalation happens when injected content persuades the LLM to use those permissions for unintended repository, network, or metadata access.
  4. Impact is unauthorized data exposure, destructive changes, or leakage of secrets through the tool chain and returned context.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Tool calling creates an identity problem, not just an LLM problem. Once the model can select actions that affect external systems, the security question becomes who or what is authorised to act on behalf of the user. That shifts the centre of gravity from prompt hygiene to delegated authority, scoped credentials, and action boundaries. Practitioners should assess AI toolchains as access paths with their own governance lifecycle, not as harmless automation.

Least privilege for function-calling is about preventing privilege amplification. The article shows that a model with broad tool rights can turn ambiguity into destructive capability, especially when the input is adversarial. That is the same failure pattern seen in overprivileged NHIs, but here the risk is compounded by language flexibility and runtime choice. The implication is that execution scope must be narrower than user intent, not merely equal to it.

Context window separation is the named control boundary that now matters most. Sensitive data passed into the model becomes part of the attack surface because the model can be manipulated by whatever enters that window. This breaks the assumption that prompts are just instructions. For practitioners, the design lesson is that model-facing context and trusted execution state must be separated as strictly as any other privileged interface.

Function-calling should be governed as a bounded delegation chain. The article connects external linkage, tool credentials, and response handling into a single flow that can be abused at any point. That makes tool identity, credential scope, and output handling part of one governance problem rather than three separate ones. Security teams should treat AI toolchains as delegated execution systems with explicit trust boundaries, not as ordinary application features.

AI agents inherit the same lifecycle discipline as other non-human identities, but with faster failure modes. Access reviews, credential scoping, and offboarding still apply, yet the model can consume and act on untrusted inputs within the same session. That makes slow governance cycles insufficient on their own. Practitioners need to rethink what must be decided at issuance time because the window for misuse is the execution session itself.

From our research library:

What this signals

Bounded delegation is the right mental model for LLM integrations. The article makes clear that once a model can call tools, the security boundary moves from prompt quality to runtime authority. That means teams need to govern what the model can reach, what it can return, and which actions remain outside its control. [AI Agent Authorisation Guide](https://nhimg.org/ai-agent-authorisation-guide) is relevant where teams are deciding how much action authority to expose.

Context window hygiene now functions like a control plane control. Sensitive data placed into model-visible context is exposed to both model error and adversarial instruction. The practical consequence is that retrieval, credential use, and state change should be separated as if they were distinct trust zones. For teams mapping this work to external standards, the OWASP Agentic AI Top 10 and MITRE ATLAS are useful lenses for tool misuse and adversarial manipulation.

AI systems do not need full autonomy to create identity risk. Even tool-bound applications can overreach when execution rights are broader than the task. According to the 2026 Infrastructure Identity Survey, 62% of organisations are at least experimenting with AI agents, but only 23% have scaled one into a single business function. That gap suggests the governance model is still catching up to practical deployment.


For practitioners

  • Boundary external tools by function Split retrieval, write, and administrative actions into separate tools with different permissions so the model cannot mix harmless and sensitive operations in one call.
  • Issue fine-grained credentials only Use scoped tokens for each tool and avoid broad personal access tokens or generic service credentials that can be reused across unrelated tasks.
  • Keep secrets out of model context Store and use credentials in trusted application logic rather than passing them through prompts, retrieved text, or other model-visible context.
  • Separate untrusted input from trusted execution Mark external content clearly, constrain what enters the context window, and prevent fetched text from directly shaping privileged actions.

Key takeaways

  • LLM function-calling turns model output into delegated execution, so security must focus on tool permissions and trust boundaries rather than prompts alone.
  • Least privilege, context separation, and secret isolation are the controls that determine whether an AI toolchain stays bounded or becomes a broad access path.
  • The article shows that AI agents and LLM tools can fail through the same governance gaps seen in overprivileged NHIs, but at a much faster operational pace.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10, OWASP Non-Human Identity Top 10 and MITRE ATT&CK define the specific risk controls and attack patterns relevant to this term.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI02 — Tool MisuseTool misuse is the core failure mode when LLMs call external functions with excessive scope.
ASI03 — Identity & Privilege AbuseThe article centres on delegated access that becomes too broad for the task.
Recommendation — Constrain each tool to a single purpose and block cross-purpose execution paths. Scope agent privileges to the minimum action set and separate read from write access.
OWASP Non-Human Identity Top 10NHI-04 — Insecure AuthenticationThe article discusses tool credentials and access tokens used by LLM-linked services.
NHI-05 — Overprivileged NHIExcessive delegation through broad tokens is the article's central governance problem.
NHI-10 — Human Use of NHIThe model acts as a proxy for human requests and can misuse human-intended authority.
Recommendation — Use narrowly scoped, service-specific credentials for each tool and avoid broad shared tokens. Review delegated credentials for excess privilege and remove capabilities the tool does not need. Separate user intent handling from credentialed execution so human requests do not inherit broad NHI rights.
MITRE ATT&CKTA0006;TA0008 — Credential Access; Lateral MovementThe threats described include credential leakage, SSRF, and movement into internal systems.
Recommendation — Map tool-mediated exposure to credential access and lateral movement detections in your monitoring program.

Key terms

  • Function Calling: A model integration pattern where the application embeds tool definitions in the request sent to the LLM and executes the chosen function itself. It is simple to implement, but the same process often carries the credentials and permissions for every exposed action.
  • Context Window: The context window is the text a model receives at one time, including prompts, retrieved documents, and conversation history. Security teams care about it because it becomes the practical boundary between trusted instructions and untrusted content, especially when the application assembles that text automatically.
  • Excessive Delegation: Excessive delegation occurs when an LLM or its tool identity is granted more authority than the task needs. The result is widened blast radius, because a single mistaken or malicious prompt can trigger actions, access paths, or repository changes that should never have been available to the workflow.
  • Boundary Separation: The practice of keeping untrusted input, model-visible context, and trusted execution logic in distinct security zones. For AI applications, boundary separation limits the chance that hostile text, sensitive data, or model error can cross into privileged action paths.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on September 14, 2026.
Updated on October 11, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org