Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

Fixes path traversal vulnerability where $_CustomView parameter is included without validation, allowing potential access to arbitrary files via patterns like ../../../etc/passwd.

Changes

Path validation in renderMaintenancePage():

  • Real filesystem: validates resolved path via realpath() is within resources/ directory
  • Virtual filesystem (tests): validates path components don't contain .. traversal patterns
  • Throws RuntimeException on invalid paths

Added containsDirectoryTraversal() helper:

  • Normalizes path separators (handles Windows/Unix)
  • Splits path and checks for .. as directory component
  • Allows legitimate filenames containing .. (e.g., ..test.php)
// Validate path to prevent directory traversal attacks
$realPath = realpath( $customViewPath );

if( $realPath === false ) {
    // Virtual filesystem: check for traversal patterns
    if( $this->containsDirectoryTraversal( $customViewPath ) ) {
        throw new \RuntimeException( 'Invalid custom view path: directory traversal detected' );
    }
} else {
    // Real filesystem: ensure path is within resources directory
    $basePath = realpath( __DIR__ . '/../../../resources' );
    if( $basePath !== false && strpos( $realPath, $basePath ) !== 0 ) {
        throw new \RuntimeException( 'Invalid custom view path: path must be within the resources directory' );
    }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits November 9, 2025 17:33
Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
@ljonesfl ljonesfl marked this pull request as ready for review November 9, 2025 17:37
Copilot AI changed the title [WIP] Fix user management issues in authentication system PR Add path traversal protection to MaintenanceFilter custom view includes Nov 9, 2025
Copilot finished work on behalf of ljonesfl November 9, 2025 17:38
Copilot AI requested a review from ljonesfl November 9, 2025 17:38
@ljonesfl ljonesfl merged commit f011586 into feature/auth Nov 9, 2025
1 of 2 checks passed
@ljonesfl ljonesfl deleted the copilot/sub-pr-1 branch November 9, 2025 17:39
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