Skip to content

fix(file_tools): normalize path separator before device-path blocklist compare (#69373) - #69401

Closed
Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/69373-windows-blocklist-path-normalize
Closed

Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/69373-windows-blocklist-path-normalize

Conversation

@Enough1122

Copy link
Copy Markdown
Contributor

Summary

_is_blocked_device_path() normalizes with os.path.normpath and compares against POSIX strings. On Windows, normpath("/dev/zero") returns "\dev\zero" (backslashes) which never matches the POSIX "/dev/zero". The same applies to the startswith("/proc/") checks. The entire device/fd/proc read-guard was a silent no-op on Windows, and read_file("/dev/zero") genuinely hung via Git Bash's MSYS /dev/zero emulation.

Fix

Add _normalize_for_blocklist() helper that converts to forward slashes after os.path.normpath, then use it in _is_blocked_device_path(). The fix is cross-platform (same code path on all platforms, no platform-specific branches).

Files touched

  • tools/file_tools.py — add _normalize_for_blocklist() helper + one-line change in _is_blocked_device_path()
  • tests/tools/test_file_read_guards.py — add TestWindowsBlocklistSeparatorNormalize with 4 regression tests

Test plan

cd /c/Users/admin/AppData/Local/hermes/hermes-agent
./venv/Scripts/python.exe -m pytest tests/tools/test_file_read_guards.py::TestWindowsBlocklistSeparatorNormalize -v
# 4 passed in 0.79s

What this does NOT do

  • No change to the blocklist contents — only the comparison path
  • No platform-specific branches — the fix is one-line normalization that works identically on all platforms
  • No public API change

Fixes #69373. Refs #4427.

— written by Hermes Agent on behalf of @Enough1122

…t compare (NousResearch#69373)

On Windows, os.path.normpath preserves backslashes which never match the POSIX strings in _BLOCKED_DEVICE_PATHS. The entire device/fd/proc read-guard — including the /proc/*/environ secret-leak family added for NousResearch#4427 — was a silent no-op on Windows, and read_file(/dev/zero) genuinely hung via Git Bash's MSYS /dev/zero emulation.

Normalize to forward slashes (POSIX form) before the blocklist compare so the check is cross-platform.

Fixes NousResearch#69373. Refs NousResearch#4427.
@Enough1122

Copy link
Copy Markdown
Contributor Author

cc @teknium1 @alt-glitch — fix pushed for #69373.

Verification on head a597b9f9:

Check Result
pytest tests/tools/test_file_read_guards.py::TestWindowsBlocklistSeparatorNormalize -v 4 passed in 0.79s
git diff --check ✅ clean
git diff --stat origin/main..HEAD ✅ 2 files, +47/-1

Implementation summary:

  • _normalize_for_blocklist() helper in tools/file_tools.py — applies os.path.normpath then converts to forward slashes with .replace(os.sep, "/")
  • One-line change in _is_blocked_device_path(): os.path.normpath(...)_normalize_for_blocklist(...)
  • 4 regression tests covering the fix

NOT doing: not changing the blocklist contents, not adding platform-specific branches, no public API change.

Ready for maintainer review.

— written by Hermes Agent on behalf of @Enough1122

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jul 22, 2026
@Enough1122

Copy link
Copy Markdown
Contributor Author

Closing this stale PR for now: it has had no substantive human review/action and is unlikely to be merged in its current state. Reopen or submit a fresh PR if the issue remains relevant.

@Enough1122 Enough1122 closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/file File tools (read, write, patch, search) type/security Security vulnerability or hardening

Projects

None yet

2 participants