Skip to content

fix: reject path traversal and null bytes in path resolver#68

Merged
zfarrell merged 6 commits intomainfrom
fix/path-traversal-null-bytes
Feb 24, 2026
Merged

fix: reject path traversal and null bytes in path resolver#68
zfarrell merged 6 commits intomainfrom
fix/path-traversal-null-bytes

Conversation

@zfarrell
Copy link
Contributor

Summary

  • Add validate_no_null_bytes(), validate_no_path_traversal(), and validate_path() to path_resolver.rs
  • Changed resolve_path, join_paths, PathResolver::resolve, PathResolver::child_resolver to return Result<String> so validation errors propagate
  • Added validation at entry point (parse_object_store_url) and in join_paths/resolve_path for relative and absolute paths
  • Updated all callers in catalog.rs, schema.rs, table.rs, table_changes.rs, table_deletions.rs, table_functions.rs
  • Rejects: literal \0, URL-encoded %00, .. path components, URL-encoded %2e%2e
  • Allows: single dots, file extensions, version strings (e.g. schema.v2/), %20 spaces

Closes #54, closes #55

Test plan

  • 15+ new validation tests in path_resolver.rs covering null bytes, path traversal, and allowed patterns
  • All 170+ existing tests pass (including integration, sqllogictest, and doc-tests)
  • cargo build compiles cleanly

🤖 Generated with Claude Code

zfarrell and others added 3 commits February 24, 2026 02:24
Add validation functions to path_resolver.rs that reject:
- Literal null bytes (\0) and URL-encoded null bytes (%00)
- Path traversal sequences (..) and URL-encoded variants (%2e%2e)

Changed resolve_path, join_paths, PathResolver::resolve, and
PathResolver::child_resolver to return Result<String> so validation
errors propagate to callers. Added validate_path() call at the start
of parse_object_store_url().

Updated all callers in catalog.rs, schema.rs, table.rs,
table_changes.rs, table_deletions.rs, and table_functions.rs to
handle the new Result return types.

Includes comprehensive tests for null bytes, path traversal, and
allowed patterns (single dots, file extensions, version strings).

Closes #54, closes #55

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
join_paths now returns Result<String> after path validation was added.
Update all call sites in table_writer.rs to propagate errors with ?.
Also fix clippy warning for manual char comparison in path_resolver.rs.
@zfarrell zfarrell closed this Feb 24, 2026
@zfarrell zfarrell reopened this Feb 24, 2026
- Remove unnecessary to_ascii_lowercase() in validate_no_null_bytes()
  since %00 contains no letters (zero-allocation improvement)
- Replace %2e%2e substring check with full percent-decode approach
  in validate_no_path_traversal() to catch ..%2f, ..%2F, and mixed
  encoded traversal patterns that bypassed the literal `/` split
- Restore missing closing paren in doc comments for object_store_url
  field in catalog.rs and schema.rs
@zfarrell zfarrell closed this Feb 24, 2026
@zfarrell zfarrell reopened this Feb 24, 2026
- Restore percent-decoding in parse_file_url() to handle non-ASCII
  filesystem paths (regression from main)
- Add fast-path in validate_no_path_traversal() to skip allocation
  when path contains no percent-encoded characters
- Remove unnecessary .map_err() in encryption block where caller
  and callee share the same error type
@zfarrell zfarrell closed this Feb 24, 2026
@zfarrell zfarrell reopened this Feb 24, 2026
@zfarrell zfarrell closed this Feb 24, 2026
@zfarrell zfarrell reopened this Feb 24, 2026
…ll-bytes

# Conflicts:
#	src/path_resolver.rs
@zfarrell zfarrell force-pushed the fix/path-traversal-null-bytes branch from 90ff643 to 33b0035 Compare February 24, 2026 17:35
@zfarrell zfarrell merged commit 3be818e into main Feb 24, 2026
3 checks passed
@zfarrell zfarrell deleted the fix/path-traversal-null-bytes branch February 24, 2026 19:38
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.

SECURITY: Null bytes pass through path functions unchecked SECURITY: Path traversal via ../ not sanitized in path resolver

1 participant