Join our Newsletter — 33% off our NHI Course

LLM Function Calling

LLM Function Calling is the mechanism that lets a language model request external actions or data through predefined functions. In practice, the model emits a structured call, the application executes it, and the result is returned for the next response. This pattern links AI decisions to tools, APIs, and governed workflows.

How LLM Function Calling Works

LLM function calling is a controlled handoff between model output and application logic. The model does not execute tools itself, it proposes a structured call, and the host application decides whether and how to run the requested function.

This makes the pattern useful for workflows that need live data, side effects, or governed actions. It also means the security boundary sits between model suggestion and tool execution, which is where validation and policy enforcement belong.

Why Function Calling Matters for Security

Function calling expands what an LLM can influence, because a model that can trigger searches, ticket creation, payments, account changes, or data retrieval can also trigger harm if the call is malformed, overbroad, or untrusted. The main security question is not whether the model can speak in JSON, but whether the application constrains which functions exist, what arguments they accept, and what the model is allowed to reach.

Good designs treat the model as an untrusted planner and the application as the enforcement point. That separation helps prevent accidental action, unsafe tool selection, and privilege creep across connected systems.

Common Failure Modes

Function calling fails when the model is allowed to choose from too many tools, when the schema is loose enough to smuggle unsafe parameters, or when tool output is trusted without verification. Prompt injection can also redirect a model into calling the wrong function or passing attacker-influenced values into a legitimate one.

Another common issue is over-automation. If the tool layer can mutate records, expose secrets, or reach privileged APIs without strong approval logic, a small model error becomes an operational incident.

How Organisations Use It Safely

Safe deployments start with scoped tool design, strict schemas, explicit allowlists, and server-side checks that validate every argument before execution. Sensitive functions should require additional policy decisions, not just a model suggestion.

It is also important to separate read-only tools from state-changing tools, monitor tool invocation patterns, and review whether the model can be induced to call functions outside the intended workflow. For teams building agent-like systems, NHIMG’s AI Agent Tool and Plugin Security Guide is the most direct companion resource for scoped permissions, validation, and tool misuse prevention.

Risk and Threat Considerations

Function calling becomes risky when attacker-influenced text can steer the model into choosing a harmful tool, exposing data, or performing an action the user never intended. The security impact grows fast when tool access reaches business systems, because the model can become a path from conversational input to real-world side effects.

Failure mechanism: Attackers exploit prompt injection, tool confusion, or weak argument validation to make the model invoke the wrong function or pass unsafe values into a trusted workflow.

Impact: The result can be data leakage, unauthorized actions, corrupted records, or abuse of downstream systems that trust the application to enforce policy.

Standards & Framework Alignment

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

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP API Security Top 10 API5 — Broken Function Level Authorization Function calling hinges on which functions the model may invoke.
Recommendation — Enforce server-side function authorization before executing any model-requested action.
NIST SP 800-53 Rev 5 IA-9 — Identification and Authentication (Service and Organization Users) Tool calls often act through service or workload identities behind the model.
AC-6 — Least Privilege Function calling is safest when every tool is scoped to the minimum needed authority.
SI-10 — Information Input Validation Model-generated function arguments must be validated before execution.
Recommendation — Bind each function to an authenticated service identity and validate its delegated authority. Restrict tool permissions to the minimum access needed for each workflow. Validate every function argument on the server side before the request reaches a backend.

Practitioner Guidance

Governance implication: Treat function calling as a privileged integration boundary, not a convenience feature. The safest pattern is to define only the minimum functions needed, keep business-critical actions behind deterministic application logic, and require human or policy approval for high-impact operations.

What to watch for: Watch for broad tool catalogs, vague schemas, hidden side effects, and model access to functions that can modify identity, money, data, or infrastructure state. Those are the conditions that turn a useful orchestration pattern into an exposure multiplier.