Python: Lack of Runtime Access Control (RBAC/Approval Mechanism) in Auto Function Invocation Leads to Unauthorized Execution via Indirect Prompt Injection
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 kernel_function_decorator.py、kernel.py 和 kernel_function.py 开始,沿着 AUTO_FUNCTION_INVOCATION 路径跟踪 invoke_function_call 和 _inner_auto_function_invoke_handler。审查 native 函数的描述和调用方式,然后定义在执行高风险调用之前所需的批准和安全控制行为;完成这项工作需要达成一致的设计以及相应的运行时强制执行。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Semantic Kernel (Python) lacks declarative security controls and runtime mid-execution interception/approval mechanisms for Native Functions during Auto Function Invocation.
The specific security flaw lies in the "blind trust" of the execution chain:
-
Missing security attributes at the metadata layer: The @kernel_function decorator (kernel_function_decorator.py) is solely responsible for extracting the function signature for LLM consumption. It does not provide any declarative interfaces for permission level classification or approval requirements (e.g., requires_approval).
-
Unconditional execution at the execution layer: In the invoke_function_call logic of kernel.py, when parsing the FunctionCallContent returned by the LLM, the framework only validates the presence or absence of parameters. Subsequently, it directly invokes the native method (await context.function.invoke) within _inner_auto_function_invoke_handler.
As a result, when the system is subjected to Prompt Injection (such as reverse psychology attacks), if the LLM is deceived into orchestrating high-risk native skills (e.g., sensitive file writing, data deletion), the SK framework will execute these underlying destructive operations directly and without any hindrance.
To Reproduce
Steps to reproduce the behavior:
-
Register a native function involving sensitive operations (e.g., WriteAsync for writing files to the system) and mount it using the @kernel_function decorator.
-
Load this Plugin into the Kernel and configure it to enable Auto Function Invocation.
-
As an external user, submit a malicious Prompt containing "unauthorized/reverse psychology" instructions (e.g., construct a specific context to induce the LLM to ignore original system settings and force the invocation of the aforementioned write function).
-
Tracing the execution stack will reveal: Upon receiving the Tool Call request planned by the LLM, the Kernel directly invokes the underlying write operation without triggering any security interceptors or Human-in-the-Loop (HITL) confirmation mechanisms.
Expected behavior
-
Declarative Security: The @kernel_function decorator should support security attribute tags (e.g., requires_approval=True, risk_level="High").
-
Mid-execution Approval: Built-in permission interceptors or checkpoints should be present in the Kernel.invoke execution stack. When a high-risk function is about to be executed, the system should be able to suspend the task pending authorization based on configurations, or refuse indiscriminate execution, thereby enforcing a Zero Trust architecture.
Screenshots
No runtime logs are provided. This report's conclusions are derived from a static source code security audit of the execution chains in kernel_function_decorator.py, kernel.py, and kernel_function.py.
Platform
- Language: Python
- Source: main branch of repository
- AI model: Any (Mainstream models supporting Tool Calling are affected by this architectural flaw)
- IDE: VS Code
- OS: Mac
Additional context
Large Language Models (LLMs) are inherently highly susceptible to Prompt Injection attacks. Directly and seamlessly mapping untrusted LLM planning results to a high-privilege physical function execution chain poses severe security risks. It is strongly recommended to introduce fine-grained authorization and standard Human-in-the-Loop (HITL) paradigms at the FilterTypes.AUTO_FUNCTION_INVOCATION level as soon as possible.
- 主要语言
- C#
- 星标
- 28.7k
- 派生
- 4.8k
- 平均合并
- 8 天 9 小时
- 30 天内合并 PR
- 67
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/semantic-kernel 的其他 Issue
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23可能已有人在做 @nightcityblade 于 25 天前认领。 未关闭.NET triage
难度 2/5 1-3 小时 新手友好度 73/100
microsoft/semantic-kernel#14526 · 1 条评论 ·
维护者通常 6 天内回复
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)可能已有人在做 @VANDRANKI 于 27 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/semantic-kernel#14522 ·
维护者通常 6 天内回复
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI可能已有人在做 @Laurianti 于 27 天前认领。 未关闭.NET triage
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/semantic-kernel#14518 ·
维护者通常 6 天内回复
-
Python: FunctionCallContent.combine_arguments drops a streamed "{}" chunk, producing invalid JSON arguments可能已有人在做 @VANDRANKI 于 28 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14512 · 2 条评论 ·
维护者通常 6 天内回复
-
Python: NAMED_ARG_REGEX character-class bug [${1}] lets non-$-prefixed values ({, 1, }) be silently parsed as variable references可能已有人在做 @aniketkrs 于 31 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/semantic-kernel#14491 · 1 条评论 ·
维护者通常 6 天内回复
查看 microsoft/semantic-kernel 的全部 Issue
相似的 Issue
-
devtools documentation
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Azure.Identity bug Client
难度 2/5 1-3 小时 新手友好度 76/100
Azure/azure-sdk-for-net#64293 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
Live-Charts/LiveCharts2#2403 ·
-
Rework budget never counts Claude review rounds: review comments lack the claude-code-review marker未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
thomhurst/AsyncSemaphore#618 ·
维护者通常 1 天内回复
-
Importer: an empty or non-numeric Error cell is imported as 0 instead of missing可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
Open-Systems-Pharmacology/OSPSuite.Core#3049 ·
维护者通常 1 天内回复