- Affected version
- 2.3.13
When an add-on build.json contains:
but src/addons/ExampleAddon/_files/js does not exist, running php cmd.php xf-addon:build-release ExampleAddon
includes the installation’s entire js directory under upload/js/, including XenForo core files and other add-ons assets
Cause: In
The resulting directory is then copied recursively
Suggested fix: Reject fallback to an entire top-level directory
JSON:
{
"additional_files": [
"js/"
]
}
but src/addons/ExampleAddon/_files/js does not exist, running php cmd.php xf-addon:build-release ExampleAddon
includes the installation’s entire js directory under upload/js/, including XenForo core files and other add-ons assets
Cause: In
XF\Service\AddOn\ReleaseBuilderService::prepareFilesToCopy(), a missing _files path silently falls back to the XF root:
PHP:
$filePath = $rootPath . $ds . $additionalFile;
The resulting directory is then copied recursively
Suggested fix: Reject fallback to an entire top-level directory
Diff:
diff --git a/src/XF/Service/AddOn/ReleaseBuilderService.php b/src/XF/Service/AddOn/ReleaseBuilderService.php
--- a/src/XF/Service/AddOn/ReleaseBuilderService.php
+++ b/src/XF/Service/AddOn/ReleaseBuilderService.php
@@ -160,6 +160,15 @@
{
continue;
}
+
+ if (is_dir($filePath)
+ && dirname(realpath($filePath)) === realpath($rootPath))
+ {
+ throw new PrintableException(
+ 'Cannot include an entire top-level directory. Specify a scoped path.'
+ );
+ }
+
$root = $rootPath;
}