t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Windows pre-tool permission hooks intermittently reject valid paths due to slash and drive-letter casing mismatches

Open HITECHDEM opened this issue 2 weeks ago • 2 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On Windows, define an agent pre-tool hook or permission policy restricting file access to a specific directory tree.
  2. During multi-step execution, an agent calls tools with paths formatted with forward slashes (e.g. C:/Tools/.../manifest.json or c:/...) while filesystem comparisons or workspace roots use backslashes (C:\Tools\...\manifest.json).
  3. Observe tool execution.

Expected behavior

Path comparison in permission checks should normalize paths case-insensitively and slash-agnostically on Windows (path.resolve / path.normalize / lowercase drive letters), allowing access to whitelisted project paths.

Actual behavior

The pre-tool hook denies access to valid files inside allowed directories with:

Encountered error in step execution: denied by pre-tool hook: Access to path "C:/Tools/..."

This occurs because strict string comparisons (targetPath.startsWith(allowedRoot)) fail when:

  • Drive letters differ in casing (C: vs c:).
  • Slashes differ (/ vs \).
  • Relative segments (./, ../) are present.

Impact

Minor bug or occasional failure

Version or commit

T3 Code 0.1.9 / core 0.169.0

Environment

Windows 11 x64, Desktop app

Workaround & Suggested Fix

In permission checks and hook evaluators, normalize both target and candidate paths using Windows path canonicalization before evaluating prefixes:

function isPathAllowed(targetPath: string, allowedRoot: string): boolean {
  const normTarget = path.normalize(path.resolve(targetPath)).toLowerCase();
  const normRoot = path.normalize(path.resolve(allowedRoot)).toLowerCase();
  return normTarget.startsWith(normRoot);
}

HITECHDEM avatar Nov 15 '26 23:11 HITECHDEM

@HITECHDEM Which provider were you running (Claude Code, Codex, Antigravity, Kiro, ...), and is the pre-tool hook that prints 'denied by pre-tool hook' a script you wrote or that provider's built-in check? Please paste its configuration. T3 Code has no pre-tool hook or path policy of its own, so the comparison that fails must be in that hook.

juliusmarminge avatar Nov 15 '26 23:11 juliusmarminge

Thanks for investigating. I rechecked the original failure: the provider was Antigravity ACP, and the denial came from its pre-tool check. I cannot substantiate my claim that T3 Code mishandles Windows path normalization; the attempted access was outside the permitted workspace. The original report and suggested fix were incorrect. Sorry for the misleading report; I am closing this issue.

HITECHDEM avatar Nov 15 '26 23:11 HITECHDEM