The vulnerability lies in the SessionsPythonPlugin available in both the .NET and Python versions of the Semantic Kernel SDK. The core issue is a path traversal vulnerability within the UploadFileAsync/.upload_file and DownloadFileAsync/.download_file functions. These functions, which can be invoked by an AI agent, accepted a local file path from the agent without sufficient validation.
For uploads, an attacker could craft a malicious path (e.g., ../../../../path/to/sensitive/file) to make the AI agent read arbitrary files from the host filesystem and exfiltrate them. For downloads, an attacker could instruct the agent to write a file to an arbitrary location on the filesystem, potentially overwriting critical system or application files, which could lead to remote code execution.
The patch addresses this by introducing security controls that are disabled by default. To enable file operations, a developer must now explicitly set EnableDangerousFileUploads to true and configure an allowlist of directories for uploads (AllowedUploadDirectories) and downloads (AllowedDownloadDirectories). The patched functions now canonicalize the file paths using Path.GetFullPath (in .NET) or os.path.realpath (in Python) and validate them against the configured allowlists, effectively preventing the path traversal attacks.