What is path canonicalization?

Path canonicalization is turning a file path into its one true, final form before checking it, so tricks like trailing dots, symlinks or "..\" can't sneak past a protected-file rule.

Share

Path canonicalization is turning a file path into its one true, final form before checking it, so tricks like trailing dots, symlinks or "..\" can't sneak past a protected-file rule.

Why it matters

AI coding agents are often told they may not edit certain files, such as their own configuration. If the check compares the path as raw text, an attacker who plants instructions can make the agent write to the same file under a different spelling. The operating system then resolves it to the real file, and the agent has changed its own rules.

Example

In CVE-2026-103572, fixed on 13 October 2026, Copilot in Visual Studio and SQL Server Management Studio compared filenames as raw strings. Instructions hidden in a file made it write ".mcp.json." with a trailing dot; Windows saved that to the real .mcp.json, adding an attacker's MCP server that the IDE then ran. Microsoft's fix resolves the full path first (Embrace The Red).

How to defend against it

  • Resolve paths to their final form (for example GetFullPath or realpath) before any allow or deny check.
  • Test checks against trailing dots, alternate data streams, short names, symlinks and ".." traversal.
  • Store agent config where the agent's process cannot write, enforced by the OS.
  • See our agent security checklist.

Time-of-check to time-of-use (TOCTOU), repo-planted agent config, MCP tool poisoning.

Sources

From AgentSec Brief, the daily brief on securing agentic AI. Subscribe free at https://www.agentsecbrief.com