Python: Lack of Runtime Access Control (RBAC/Approval Mechanism) in Auto Function Invocation Leads to Unauthorized Execution via Indirect Prompt Injection
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia da kernel_function_decorator.py, kernel.py e kernel_function.py, seguendo il percorso AUTO_FUNCTION_INVOCATION attraverso invoke_function_call e _inner_auto_function_invoke_handler. Esamina come vengono descritte e invocate le funzioni native, quindi definisci il comportamento di approvazione e dei controlli di sicurezza necessario prima che possano essere eseguite chiamate ad alto rischio; per completare il lavoro sono necessari un design concordato e la relativa applicazione a runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 28.6k
- Fork
- 4.8k
- Merge medio
- 12h 20m
- PR unite (30g)
- 12
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/semantic-kernel
-
python triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
microsoft/semantic-kernel#14491 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
python triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
microsoft/semantic-kernel#14490 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Python: [Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution)Apertapython triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
microsoft/semantic-kernel#14483 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
.NET python triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
microsoft/semantic-kernel#14482 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Python: [Python] as_agent_framework_tool drops parameter defaults (optionals become required)Apertapython triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
microsoft/semantic-kernel#14481 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di microsoft/semantic-kernel
Issue simili
-
area-ai untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
dotnet/extensions#7790 ·
I maintainer di solito rispondono entro 1 giorno
-
P2 testing
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
area-Infrastructure-coreclr os-ios os-maccatalyst os-tvos untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/runtime#134766 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
0 - Backlog Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
BrighterCommand/Brighter#4444 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno