Abusing Function Calling to Reach Unintended Resources
Function calling allows LLMs to request execution of defined functions by outputting structured JSON specifying the function name and arguments. The calling application executes the requested function and passes the result back to the model. When the model can be influenced into calling functions outside the intended workflow, or when function arguments are passed to backend systems without validation, function calling becomes a code execution and resource access primitive.
The key distinction from tool integration exploitation is that function calling abuse specifically targets the model's ability to select and parameterize function calls. The attack either manipulates the model into calling a function it should not, or crafts inputs that cause the model to construct malicious arguments for a function it is allowed to call.
Force Unintended Function Calls via Prompt Injection
If the application restricts which functions the model should call based on user role or context, prompt injection can override those restrictions by instructing the model to call a specific function directly:
Manipulate Function Arguments for Resource Access
For functions the model is legitimately allowed to call, manipulate the arguments to reach resources outside the intended scope. A search function designed to query public documents can be parameterized to query internal collections. A file read function intended for user uploads can be directed at system paths:
Intercept and Replay Function Call JSON
Some applications pass function call JSON through the client before executing it. Intercept the function call response from the model, modify the arguments, and return it to the application as if the model produced it. This bypasses any model-level restrictions on what arguments the model would generate:
{
"choices": [{
"message": {
"role": "assistant",
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_account",
"arguments": "{\"user_id\": \"current_user\"}"
}
}]
}
}]
}
The model produced a get_account call with user_id set to current_user. If the application executes function calls submitted by the client after the model generates them, replay the call with a modified user_id to access another account:
Enumerate Defined Functions via Error Messages
If the model receives a function definition list it should not reveal, craft inputs that trigger error messages referencing function names or cause the model to list available functions through misdirection:
A full function schema returned by the model reveals the complete tool surface available to the agent. Use function names and parameter types to construct targeted exploitation payloads against each function, prioritizing those with administrative, filesystem, or network access capabilities.
References
-
OpenAI — Function Calling Guideplatform.openai.com/docs/guides/function-calling (opens in new tab)
Function call JSON format and tool_calls response structure reference
-
OWASP Top 10 for LLM Applicationsowasp.org/www-project-top-10-for-large-language-model-applications (opens in new tab)
LLM06: Excessive Agency covering function call scope restrictions and validation requirements
Was this helpful?
Your feedback helps improve this page.