Skip to content

fix: prevent path traversal in development server rewrite script - #10526

Closed
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/rewrite-path-traversal
Closed

fix: prevent path traversal in development server rewrite script#10526
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/rewrite-path-traversal

Conversation

@gr8man

@gr8man gr8man commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Description
Validates that requested paths in system/rewrite.php stay within DOCUMENT_ROOT using realpath(), preventing the built-in development server (php spark serve) from serving files outside the public directory via path traversal.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@gr8man
gr8man force-pushed the fix/rewrite-path-traversal branch from deedfda to 48615f2 Compare September 5, 2026 21:09

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide an HTTP-level reproduction showing a file outside the document root being served before this change, including the PHP version and OS? Returning false delegates handling to PHP built-in server, it does not directly serve the resolved path. I couldn't reproduce the issue on PHP 8.2 or 8.5.

This also blocks intentional public symlinks pointing outside the document root. Without a reproduction, I'm not convinced the additional restriction and compatibility impact are justified for the development server.

@gr8man gr8man closed this Sep 6, 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.

2 participants