Skip to content

Prevent TemporaryFolder paths from escaping the root#1795

Closed
Q1Xuan wants to merge 1 commit into
junit-team:mainfrom
Q1Xuan:fix-temporary-folder-path-traversal
Closed

Prevent TemporaryFolder paths from escaping the root#1795
Q1Xuan wants to merge 1 commit into
junit-team:mainfrom
Q1Xuan:fix-temporary-folder-path-traversal

Conversation

@Q1Xuan

@Q1Xuan Q1Xuan commented Jun 7, 2026

Copy link
Copy Markdown

TemporaryFolder promises to create named files and folders under its temporary root. The existing implementation rejected absolute folder paths, but parent traversal such as .. could still create files or folders outside the root.

This change validates canonical paths before creating named files or folders, so traversal paths are rejected before anything is created.

Tests:

  • Manually ran org.junit.rules.TemporaryFolderUsageTest with JUnitCore (26 tests)
  • git diff --check

I could not run ./mvnw.cmd -Dtest=org.junit.rules.TemporaryFolderUsageTest test locally because Maven Wrapper was unable to download/start Maven in this environment.

@Q1Xuan Q1Xuan closed this Jun 10, 2026
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.

1 participant