🐛 Handle open_basedir restrictions in closest() directory traversal#512
Merged
🐛 Handle open_basedir restrictions in closest() directory traversal#512
Conversation
Add an `isWithinOpenBasedir()` check to prevent `closest()` from attempting to traverse into directories outside the `open_basedir` restriction, which caused `is_readable()` warnings that Acorn's error handler escalated into exceptions on shared hosting environments. Uses path-boundary-aware comparison to avoid false positives on sibling paths (e.g. `/home/user2` is not within `/home/user`). The `@` operator on `isReadable()` and `isFile()` calls provides a safety net for edge cases the boundary check may miss (e.g. symlinks). Closes #380 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isWithinOpenBasedir()boundary check toclosest()to prevent traversing into directories outsideopen_basedirrestrictions on shared hosting environmentsrtrim($path, '/') . '/') to avoid false positives on sibling paths (e.g./home/user2not matching/home/user)@onisReadable()/isFile()as a safety net for edge cases (e.g. symlinks) the boundary check may missisWithinOpenBasedir()covering allowed paths, sibling prefix traps, outside paths, and empty restriction entriesThe root cause was
closest()walking up the directory tree unbounded — when it hit a directory outsideopen_basedir,is_readable()emitted a warning that Acorn's error handler escalated into an exception. This was reported on shared hosting with both Sage and non-Bedrock installs.Closes #380
Verification
Verified on Radicle (Bedrock) and Sage (theme) installs. Full test suite passes (89 tests, 0 failures).
🤖 Generated with Claude Code