Banner image upload fails with "The banner image field contains a file path that is not permitted"

Open Beginner friendly
#467 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
laravel, php
Domain
backend

Research direction

Start in src/Filament/Pages/Settings/ManageTheme.php and inspect the app_banner FileUpload definition, especially preventFilePathTampering(), alongside the current Filament and Livewire versions. Reproduce the dashboard upload, compare behavior with that option removed, and confirm that a valid supported banner image is accepted and saved without the file-path validation error.

Written by the indexing model from the issue text.

Description

When attempting to upload a new banner image from the Cachet 3 dashboard, the upload fails with:

The banner image field contains a file path that is not permitted

The image is a valid supported image type and the upload reaches the Livewire temporary upload stage successfully, but the Cachet settings form subsequently rejects the file.

Environment
Cachet: cachethq/core dev-main
Commit: 5ee03e64e7ecc7eae085b05cce4740477da91954

Filament Forms: v5.7.6
Livewire: v4.4.2

Steps to reproduce

Log into the Cachet 3 administration dashboard.
Navigate to the theme/settings page.
Select a new banner image.
Save the settings.
The form returns:
The banner image field contains a file path that is not permitted

Cause
The app_banner field in:
src/Filament/Pages/Settings/ManageTheme.php

currently uses:
FileUpload::make('app_banner')
   ->acceptedFileTypes((array) config('cachet.uploads.image_mime_types'))
   ->maxSize((int) config('cachet.uploads.max_size'))
   ->preventFilePathTampering()

The issue appears to be related to preventFilePathTampering().

Filament's validation checks submitted string file paths against the original path associated with the record. With a newly uploaded banner, the resulting path does not match the existing/original app_banner value, resulting in the upload being rejected as an unauthorised file path.

Workaround
Removing:
->preventFilePathTampering()

from the app_banner FileUpload definition allows the banner to upload successfully.

The resulting configuration is:
FileUpload::make('app_banner')
   ->acceptedFileTypes((array) config('cachet.uploads.image_mime_types'))
   ->maxSize((int) config('cachet.uploads.max_size'))
   ->imageEditor()
   ->label(('cachet::settings.manage_theme.app_banner_label'))
   ->hiddenLabel()
   ->helperText(
('cachet::settings.manage_theme.app_banner_helper'))
   ->disk((string) config('cachet.uploads.disk'))
   ->columnSpanFull()

Expected behaviour
A valid supported image should be accepted as the new banner image and saved successfully.
Actual behaviour
The upload fails validation with:
The banner image field contains a file path that is not permitted

Suggested investigation
Please investigate the use of:
->preventFilePathTampering()

on the app_banner field and its interaction with the current Filament/Livewire versions.
Removing this option resolves the issue, suggesting that the banner upload is being incorrectly treated as an unauthorised existing file path rather than a legitimate newly uploaded file.
This may be a Cachet/Filament/Livewire compatibility issue rather than an issue with the uploaded image itself.

Dominant language
PHP
Stars
228
Forks
84
Avg merge
11h 19m
Merged PRs (30d)
22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cachethq/core

All issues in cachethq/core

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.