octobercms/october · error · ApplicationException
Invalid hash
Error message
Invalid hash
What it means
Thrown by Files::findFileObject when the hash portion of the decoded code does not match md5(file_name!disk_name) of the located record. This guard (plus the class-swap logic above it) ensures the code was minted by the system for that exact file; a mismatch means the code was tampered with or refers to different file metadata.
Solutions
- Use only file URLs/codes generated by the system for that file
- Regenerate the link from the current file model (name/disk_name changed codes)
- Do not alter the base64 code parameter in file URLs
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/controllers/Files.php:190 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/7d0f1ec1423e5e26.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/controllers/Files.php:190
throw new ApplicationException('File not found');
}
// Ensure that the file model utilized for this request is
// the one specified in the relationship configuration
if ($file->attachment) {
$fileModel = $file->attachment->{$file->field}()->getRelated();
// Only attempt to get file model through its assigned class
// when the assigned class differs from the default one that
// the file has already been loaded from
if (get_class($file) !== get_class($fileModel)) {
$file = $fileModel->find($file->id);
}
}
$verifyCode = self::getUniqueCode($file);
if ($code != $verifyCode) {
throw new ApplicationException('Invalid hash');
}
/**
* @event backend.files.get
* Fires before a file is output.
*
* Example usage:
*
* Event::listen('backend.files.get', function ((\System\Models\File) $file) {
* // Block access to this file
* return false;
*
* // Or signal access denied
* throw new \ForbiddenException;
* });
*
*/
$response = Event::fire('backend.files.get', [$file], true);View on GitHub (pinned to b608633a7e)