{"id":5577,"date":"2026-08-31T12:49:44","date_gmt":"2026-08-31T12:49:44","guid":{"rendered":"https:\/\/www.hackmosphere.fr\/ai-security-and-function-calling-risks-and-best-practices\/"},"modified":"2026-09-03T13:30:32","modified_gmt":"2026-09-03T13:30:32","slug":"ai-security-function-calling","status":"publish","type":"post","link":"https:\/\/www.hackmosphere.fr\/en\/ai-security-function-calling\/","title":{"rendered":"AI Security and Function Calling: Risks and Best Practices"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_row _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.27.8&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<!-- divi:paragraph --><\/p>\n<p>Before invoking a tool via MCP or performing several steps independently, an agent relies on a fundamental mechanism: the <em><strong>function calling<\/strong><\/em> . <em>Function calling<\/em> allows an LLM to translate a natural-language request into a structured instruction (JSON format) that can be directly used by code or an API. In other words, the model no longer simply responds with text; it prepares the technical action and extracts the parameters.  <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:paragraph --><\/p>\n<p>By evolving from a simple text generator to a system capable of triggering real-world actions (database queries, third-party APIs, business tools), the LLM moves to a whole new level. It is precisely this transition that introduces a new set of risks, at the very moment that language becomes structured data. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:heading --><\/p>\n<h2 class=\"wp-block-heading\">How Function Calling Works: From Natural Language to API Calls<\/h2>\n<p><!-- \/divi:heading --><!-- divi:paragraph --><\/p>\n<p>The technical principle has remained consistent since its widespread adoption in 2023: a model receives a description of one or more available functions, in the form of a schema that specifies their names, their purposes, and the expected type of each parameter. When faced with a user request, the model decides whether to invoke a function, which one, and with which arguments\u2014all extracted from the conversation. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:paragraph --><\/p>\n<p>This JSON structure, validated against a schema, eliminated the unreliable parsing and errors of the early integrations. But while schema validation ensures the format is correct, it in no way guarantees the intent or security of the transmitted data. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:heading --><\/p>\n<h2 class=\"wp-block-heading\">Type Confusion and Prompt Injection: Vulnerabilities in Function Calling<\/h2>\n<p><!-- \/divi:heading --><!-- divi:paragraph --><\/p>\n<p>This is the risk most specific to function calling, distinct from general prompt injection\u2014which has already been covered in the dedicated article\u2014although it shares the same underlying logic. When a model extracts a parameter from natural language (an amount, a date, an identifier) to match the expected schema, it performs a type coercion operation that can be exploited. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:paragraph --><\/p>\n<p>A <a href=\"https:\/\/arxiv.org\/html\/2601.09292v1\"><u>recent security research on function-calling agents<\/u><\/a> documents how this step can be bypassed: text containing an explicit type indication, written in natural language, can influence the value that the model extracts and passes to the target function, without any conventional safeguards detecting it, since the result remains, on the surface, a valid parameter in the expected format.<\/p>\n<p><!-- \/divi:paragraph --><!-- divi:paragraph --><\/p>\n<p>The risk is exacerbated in multi-agent architectures, where the parameter extracted by a first agent directly feeds into a call made by a second agent. In this type of chain, each extraction point provides an additional opportunity for a corrupted value to slip through the cracks at an intermediate stage, before propagating all the way to the final call. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:heading --><\/p>\n<h2 class=\"wp-block-heading\">AI Permissions Management: Preventing Excessive API Access<\/h2>\n<p><!-- \/divi:heading --><!-- divi:paragraph --><\/p>\n<p><em>Function calling<\/em> in and of itself does not pose any intrinsic risk: a function that retrieves business hours or calculates a route does not expose any sensitive information, even in the event of a successful attack. The risk arises from<strong>the discrepancy<\/strong> <strong>between the functions exposed to the model and those actually necessary for its task<\/strong>: an email-sending function exposed to an assistant who is supposed to only view data, write access granted where read-only access would suffice, or a delete function made available without intermediate validation. <\/p>\n<p><!-- \/divi:paragraph --><!-- divi:paragraph --><\/p>\n<p>In each of these cases, model manipulation via injection directly inherits this excess capacity, regardless of the robustness of the parameter extraction mechanism itself. <strong>Every<\/strong> <strong>function exposed to a model should be treated as an extension of its scope<\/strong> , with the same rigorous review as a new access granted to a service account.<\/p>\n<p><!-- \/divi:paragraph --><!-- divi:heading --><\/p>\n<h2 class=\"wp-block-heading\">Best Practices for Securing Function Calls at the Source<\/h2>\n<ul class=\"wp-block-list\">\n<ul class=\"wp-block-list\">\n<li><strong>Validate each parameter on the server side, not just against the schema<\/strong>: do not simply verify compliance with the data schema; implement application-level validation that is independent of the model (value range, business context, consistency rules) before any execution.<\/li>\n<li><strong>Strictly limit the set of functions exposed in each context: a <\/strong> wizard dedicated to a specific task should have access only to the functions required for that task, never to a broad set of functions exposed simply for the sake of development convenience.<\/li>\n<li><strong>Reapply validation at each link in a multi-agent chain<\/strong>: never assume that a parameter validated by an upstream agent remains reliable once it is transmitted to a downstream agent; revalidate the arguments and context at every trust boundary (every tool call, every transition from one agent to another).<\/li>\n<li><strong>Require human confirmation for functions with irreversible consequences<\/strong>: Require explicit validation for any function that could have an irreversible or high-risk effect, such as data deletion, sending external communications, financial transactions, or changing permissions, etc.<\/li>\n<\/ul>\n<\/ul>\n<p><!-- \/divi:list-item --><!-- divi:list-item --><!-- \/divi:list-item --><!-- divi:list-item --><!-- \/divi:list-item --><!-- divi:list-item --><!-- \/divi:list-item --><!-- \/divi:list --><!-- divi:heading --><\/p>\n<h2 class=\"wp-block-heading\">FAQ: Security of Function Calling and AI Agents<\/h2>\n<p><!-- \/divi:heading -->[\/et_pb_text][et_pb_accordion _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_accordion_item title=&#8221;What Is Function Calling?  &#8221; open=&#8221;on&#8221; _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Function calling is the ability of an AI model to convert a natural language request into a structured instruction (e.g., JSON) that can be processed by an API.<\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;How can you verify that an AI agent does not have excessive privileges?&#8221; _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; open=&#8221;off&#8221;]<\/p>\n<p>Start by <b data-path-to-node=\"5,0\" data-index-in-node=\"16\">taking inventory of the functions, APIs, technical accounts, and data accessible to each agent<\/b>. Remove unnecessary permissions, separate read and write access, and limit each permission to a specific resource, time frame, and environment. This approach applies the principle of least privilege to AI agents.  <\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;Which function calls must be subject to human validation?&#8221; _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; open=&#8221;off&#8221;]<\/p>\n<p>Require explicit confirmation before any data deletion, financial transaction, external communication, change in permissions, or production intervention. The confirmation request must specify the tool being used, the target, and the exact parameters to enable an informed decision. <\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;How can we document and audit these controls for our auditors, insurers, and regulators?&#8221; _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; open=&#8221;off&#8221;]<\/p>\n<p>By maintaining structured records: function diagrams, catalogs organized by agent, call logs (function, parameters, result), model decisions (if available), and human validations. These elements help demonstrate compliance with the principles of least privilege, validation, and traceability required by compliance frameworks (GDPR, AI Act, security standards). <\/p>\n<p>[\/et_pb_accordion_item][\/et_pb_accordion][et_pb_text _builder_version=&#8221;4.27.8&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>Audit the functions exposed to your AI systems<\/h2>\n<p><span>Our experts assess the actual scope of the functions available to your models and agents and test their resistance to manipulation as part of our <\/span><a href=\"https:\/\/www.hackmosphere.fr\/en\/?p=5149\"><u>AI penetration testing<\/u><\/a>service.<\/p>\n<p>Would you like to discuss your project or assess your needs?  <a href=\"https:\/\/www.hackmosphere.fr\/en\/contact\/\"><u>Contact our experts.<\/u><\/a><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before invoking a tool via MCP or performing several steps independently, an agent relies on a fundamental mechanism: the function calling . Function calling allows an LLM to translate a natural-language request into a structured instruction (JSON format) that can be directly used by code or an API. In other words, the model no longer [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":5573,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_titles_title":"AI Security and Function Calling: Risks and Best Practices","_seopress_titles_desc":"How Can You Secure Function Calling and AI Agents? Vulnerabilities, prompt injection, and best practices for protecting your APIs and sensitive data.","_seopress_robots_index":"","_seopress_robots_follow":"","_seopress_robots_imageindex":"","_seopress_robots_snippet":"","_seopress_robots_primary_cat":"","_seopress_robots_breadcrumbs":"","_seopress_robots_freeze_modified_date":"","_seopress_robots_custom_modified_date":"","_seopress_robots_canonical":"","_seopress_social_fb_title":"","_seopress_social_fb_desc":"","_seopress_social_fb_img":"","_seopress_social_fb_img_attachment_id":0,"_seopress_social_fb_img_width":0,"_seopress_social_fb_img_height":0,"_seopress_social_twitter_title":"","_seopress_social_twitter_desc":"","_seopress_social_twitter_img":"","_seopress_social_twitter_img_attachment_id":0,"_seopress_social_twitter_img_width":0,"_seopress_social_twitter_img_height":0,"_seopress_redirections_value":"","_seopress_redirections_enabled":"","_seopress_redirections_enabled_regex":"","_seopress_redirections_logged_status":"","_seopress_redirections_param":"","_seopress_redirections_type":0,"_seopress_analysis_target_kw":"","_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[46,18],"tags":[],"class_list":["post-5577","post","type-post","status-publish","format-standard","has-post-thumbnail","category-other","category-red-team"],"_links":{"self":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/5577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/comments?post=5577"}],"version-history":[{"count":9,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/5577\/revisions"}],"predecessor-version":[{"id":5742,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/posts\/5577\/revisions\/5742"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/media\/5573"}],"wp:attachment":[{"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/media?parent=5577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/categories?post=5577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hackmosphere.fr\/en\/wp-json\/wp\/v2\/tags?post=5577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}