You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "dxbjavid (via GitHub)" <gi...@apache.org> on 2026/06/01 09:44:35 UTC

[PR] fix path fence bypass for relative paths with leading .. [commons-text]

dxbjavid opened a new pull request, #745:
URL: https://github.com/apache/commons-text/pull/745

   PathFence.apply() calls path.normalize().toAbsolutePath(), so leading .. segments survive normalize() and toAbsolutePath() then prepends the working directory. The component-wise startsWith(root) check matches the prefix even though the real path escapes the fence, e.g. ${file:UTF-8:../secret} reads outside a fence rooted at the working directory. Resolve to absolute first, then normalize, for both the roots and the candidate path.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix path fence bypass for relative paths with leading .. [commons-text]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #745:
URL: https://github.com/apache/commons-text/pull/745#issuecomment-4591738210

   @dxbjavid 
   Thank you for the PR.
   You must provide a unit test that fails when the changes to main are not applied. Otherwise, this is a regression waiting to happen.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix path fence bypass for relative paths with leading .. [commons-text]

Posted by "dxbjavid (via GitHub)" <gi...@apache.org>.
dxbjavid commented on PR #745:
URL: https://github.com/apache/commons-text/pull/745#issuecomment-4591933495

   Added one. The existing `../` tests only passed because the escaped file didn't exist, so the read failed and got rethrown as IllegalArgumentException anyway. The new test in FileStringLookupTest points a relative `..` path at a real file outside the fence: on current main the fence lets it through and the file is read (nothing thrown), with the fix it's rejected.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix path fence bypass for relative paths with leading ".." [commons-text]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #745:
URL: https://github.com/apache/commons-text/pull/745#issuecomment-4594483002

   @dxbjavid 
   Thank you, merged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix path fence bypass for relative paths with leading .. [commons-text]

Posted by "dxbjavid (via GitHub)" <gi...@apache.org>.
dxbjavid commented on PR #745:
URL: https://github.com/apache/commons-text/pull/745#issuecomment-4593453348

   Added testFenceRootWithParentSegment. It builds a fence rooted at `target/..` (which resolves to the working dir) and reads an in-fence file. Without the constructor normalize the root keeps the trailing `..`, so the component-wise startsWith never matches and the legit file is wrongly rejected. The test fails on main and passes with the fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix path fence bypass for relative paths with leading ".." [commons-text]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #745:
URL: https://github.com/apache/commons-text/pull/745


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix path fence bypass for relative paths with leading .. [commons-text]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #745:
URL: https://github.com/apache/commons-text/pull/745#issuecomment-4592116166

   Hello @dxbjavid 
   Thank you for your prompt update.
   I can see the new test failing now without the `main` changes; BUT the changes to the constructor are not needed for the test to pass.
   Would you please add another test to validate the change to the constructor?
   TY!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org