Plugin Directory


Ignore:
Timestamp:
09/16/2026 06:00:14 PM (6 weeks ago)
Author:
yagniksangani
Message:

Release 4.5.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery/trunk/src/DisplayType/Controller.php

    r3680435 r3699076  
    475475                        }
    476476
     477                        $storage = StorageManager::get_instance();
     478
    477479                        foreach ( $dirs as $category => $dir ) {
    478480                                $category = preg_quote( $category . DIRECTORY_SEPARATOR, '#' );
    … …  
    480482                                        $display_type_view = $match[1];
    481483                                        $template_abspath  = $fs->join_paths( $dir, $display_type_view );
     484
     485                                        // join_paths() preserves "..", and this value comes from the gallery's stored
     486                                        // display_type_settings, which remote-editing endpoints can write. Without a
     487                                        // containment check, "default/../../../../uploads/2026/01/x.jpg" resolves here
     488                                        // and View::render() include()s whatever it points at. The refused case falls
     489                                        // through to the built-in template rather than failing the render.
     490                                        if ( ! $storage->is_path_contained( $dir, $template_abspath ) ) {
     491                                                $storage->log_path_refusal(
     492                                                        sprintf(
     493                                                                'NextGEN Gallery: refused display template "%s" for display type "%s" - resolves outside the template directory (%s)',
     494                                                                $template_abspath,
     495                                                                $display_type_name,
     496                                                                $dir
     497                                                        ),
     498                                                        StorageManager::REFUSAL_TEMPLATE_PATH
     499                                                );
     500                                                continue;
     501                                        }
     502
    482503                                        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    483504                                        if ( @file_exists( $template_abspath ) ) {
Note: See TracChangeset for help on using the changeset viewer.