Skip to content

fix(fs): prevent sandbox escape via TOCTOU fallback in RealFs::resolve#1040

Merged
chaliy merged 1 commit intomainfrom
fix/issue-980-realfs-toctou
Apr 3, 2026
Merged

fix(fs): prevent sandbox escape via TOCTOU fallback in RealFs::resolve#1040
chaliy merged 1 commit intomainfrom
fix/issue-980-realfs-toctou

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Fix TOCTOU race condition in RealFs::resolve() fallback path that returned raw joined paths without traversal validation when parent directory didn't exist (issue RealFs TOCTOU race condition in path resolution enables sandbox escape #980)
  • Add normalize_host_path() helper that logically resolves .. components on host-side paths without touching the filesystem
  • Validate that the normalized fallback path stays within the RealFs root before returning it
  • Add security tests covering fallback containment, path normalization, and traversal prevention

Test plan

  • resolve_fallback_validates_containment — non-existent path under root succeeds
  • resolve_fallback_returns_normalized_path — fallback returns clean path without ..
  • normalize_host_path_resolves_dotdot.. components collapsed correctly
  • normalize_host_path_preserves_absolute — absolute paths stay absolute
  • security_traversal_blocked_all_paths — comprehensive traversal attempts fail
  • security_nonexistent_nested_stays_under_root — nested writes create under root
  • All 26 realfs tests pass

Closes #980

The resolve() fallback path returned raw joined paths without traversal
validation when the parent directory didn't exist. Add normalize_host_path()
to logically resolve .. components on host paths, and validate containment
in the fallback case. Add security tests for the fallback path.

Closes #980
@chaliy chaliy merged commit 4f06385 into main Apr 3, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-980-realfs-toctou branch April 3, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RealFs TOCTOU race condition in path resolution enables sandbox escape

1 participant