Skip to content

FOUR-34294-B: Plugins with K8s - #9193

Open
henryjonathanquispe wants to merge 39 commits into
developfrom
FOUR-34294-B
Open

henryjonathanquispe wants to merge 39 commits into
developfrom
FOUR-34294-B

Conversation

@henryjonathanquispe

@henryjonathanquispe henryjonathanquispe commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:deploy
ci:k8s-branch:FOUR-34294b

.

julceslauhub and others added 30 commits July 31, 2026 16:54
commit b84543b
Author: AugustoLopezProcess <augusto.lopez+github@processmaker.com>
Date:   Tue Apr 21 08:27:15 2026 -0400

    Adding plugin admin ui

commit ca8a863
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Mar 9 11:01:46 2026 -0700

    Add controllers and routes for plugin UI

    Copied from feature/plugins-poc-vite-ui (just without the vite/Vue3 integration)

commit 3cc89bc
Merge: 9e9b4aa 5da27ce
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Mar 9 10:58:27 2026 -0700

    Merge branch 'task/FOUR-28803' into feature/plugins-poc

commit 9e9b4aa
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Jan 19 12:30:54 2026 -0800

    Add install command and cached routes

commit 4a5df14
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Wed Dec 10 09:29:20 2025 -0800

    Start on plugins
Updating feature/plugins-poc-4 with last changes in develop
FOUR-32722 Some adjustments in plugins installation
FOUR-32760 After install/enable/disable a plugin, should be executed the command: php artisan horizon:terminate
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
@cursor

cursor Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Plugin install runs git/composer on the server and refreshes routes and workers; mistakes could affect all tenants or leak credentials if logging redaction fails.

Overview
Adds a plugin management stack: install/reinstall/uninstall/toggle from HTTPS git URLs, zip uploads, or optional local paths (PLUGIN_INSTALL_ALLOW_LOCAL_PATH), with queued jobs, PluginLog broadcasting, and a new admin Plugins screen/API. PluginManager validates composer.json PSR-4, runs composer and plugin artisan hooks, publishes tenant public assets, rebuilds route cache, and recycles Octane/Horizon locally or broadcasts Redis-backed runtime reloads (plugin:reload-listen). Screen builder now loads extension JS from enabled storage/plugins via PluginVendorAssets.

Also introduces the cross-project manage-requirements agent skill: JSON schemas, npm run validate:requirements / check:requirements (schema + heuristic Python QC), templates, and Laya-optional quality harness with unit tests.

Multitenancy extras: tenants:octane-sync syncs Caddyfile.edge and supervisor Octane programs; plugin:publish-tenant-assets copies plugin public files to tenant disks. Setting::readyToUseSettingsDatabase now uses an app container flag instead of a static. Initial ai-docs catalog for the admin plugins screen.

Reviewed by Cursor Bugbot for commit 12597d6. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 5 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.

$pluginPath = $pluginDisabledPath;
} elseif (!is_dir($pluginPath) && !is_link($pluginPath)) {
throw PluginNotFoundException::forPlugin($pluginName);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin names allow path traversal

High Severity

Uninstall, toggle, and reinstall join the route {name} onto storage/plugins with no basename or .. guard. A name of .. resolves to storage/ itself, so delete can wipe application storage and rename can move that directory aside.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.

'view-auth_clients' => 'auth-clients.index',
'manage-public-files' => 'file-manager.index',
'view-settings' => 'settings.index',
'view-plugins' => 'plugins.index',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin admin access is miswired

High Severity

The plugins UI is specified for manage-plugins, but /admin redirects on view-plugins while plugins.index requires manage-plugins. The Admin Plugins item is also gated on is_administrator only. Operators with manage-plugins but without the earlier view-* permissions never land on the screen, and view-plugins-only users are sent to a 403.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.


try {
$zip->extractTo($tmpExtractDir);
$zip->close();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zip extract allows path traversal

High Severity

installFromZip calls ZipArchive::extractTo() with no entry-name checks. A zip whose members contain .. or absolute paths writes outside the temp directory before validatePlugin runs, so a non-plugin archive can overwrite files such as .env or public assets.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.

public ?string $zipPath = null,
public ?string $gitUsername = null,
public ?string $gitToken = null,
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git tokens stored in queue payloads

Medium Severity

gitToken is a public constructor property on InstallPlugin and ReinstallPlugin. Laravel serializes those properties into the queue payload, so GitHub tokens persist in Redis or the jobs table (and Horizon) in plaintext even though log/error paths elsewhere redact credentials.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.

public function broadcastOn()
{
return new PrivateChannel('ProcessMaker.Models.User.' . $this->userId);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PluginLog broadcasts without user

Medium Severity

PluginLog always implements ShouldBroadcastNow and builds ProcessMaker.Models.User.{userId} even when userId is null. CLI install/uninstall failure paths fire that event with no user, so broadcasting targets User. and can throw after the command has already handled the error.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12597d6. Configure here.

@cursor
cursor Bot requested review from caleeli and nolanpro November 23, 2026 19:46
@decisions-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
2 New issues
2 New Maintainability Issues (required ≤ 0)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

# Schema/heuristic gates use requirements-schema.txt (pinned PyYAML).
PyYAML==6.0.3
laya>=0.3.21,<0.4
laya-evals>=0.1.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: MEDIUM

Description: The new optional Laya requirements file installs PyPI project laya-evals>=0.1.0, an unbound release stream owned by gjxv (github.com/Gjusev/laya-evals). That project states it is not the laya-evals CLI shipped inside upstream laya, and the quality harness never imports it. The documented pip install -r requirements.txt step therefore trusts a different publisher's current and future artifacts in the environment used for requirement evals. laya-evals 0.1.0 does not declare console scripts, so it does not override laya's laya-evals entry point today; the open floor still accepts a later release that can.

Impact: An operator following the new Laya install docs runs pip against an unrelated public package with no upper bound and no hash. The package owner can publish a new release that pip will install into that developer or optional CI environment, which is code execution as the installer even though judge_catalog.py and judge_extra.py only import laya.Router. This is a new dependency-identity trust boundary, not production request traffic: no GitHub workflow or npm script installs the file automatically.

Remediation: Delete the laya-evals line and install only the pinned laya distribution, which already provides the laya-evals CLI on the 0.3.x line this file selects. If the Gjusev project is actually required, depend on a hash-pinned artifact from that publisher, import it from the harness, and document that it is a different project from laya's CLI.

Comment thread routes/api.php

Route::middleware('auth:api', 'setlocale', 'bindings', 'sanitize', 'manager')->prefix('api/1.0')->name('api.')->group(function () {
// Plugins
Route::get('plugins', [PluginController::class, 'index'])->name('plugins.index')->middleware('can:manage-plugins');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: HIGH

Description: The new plugin API routes sit inside the existing manager middleware group and then use can:manage-plugins. For any authenticated non-administrator whose user_{id}_manager cache flag is set, IsManager copies that route ability into the legacy permission cache before authorization. CustomAuthorize's Gate check reads a different cache key and denies, then its fallback trusts the simulated legacy list and lets the request through. PluginController queues install, reinstall, uninstall, and toggle with no second permission check, and the worker runs the plugin's composer install and artisan commands.

Impact: A process manager who does not hold manage-plugins and is not an administrator can queue plugin install, reinstall, uninstall, or toggle. Install clones an attacker-supplied HTTPS repo or unpacks an uploaded zip, runs composer install without --no-scripts, executes the plugin artisan command, and later PluginServiceProvider registers the plugin's Laravel providers in the app. That is server-side code execution as the queue/app user, and the same path can recycle supervisor programs. The web plugins page is outside this middleware group, so this is a new API bypass of the manage-plugins boundary, not an existing admin workflow.

Remediation: Register the plugin API routes outside the manager group so IsManager cannot inject can:manage-plugins into the legacy cache. Keep can:manage-plugins, and before dispatching InstallPlugin, ReinstallPlugin, UninstallPlugin, or TogglePlugin require the caller's real permission via hasPermission('manage-plugins') or is_administrator, which reads user_permissions:{id} rather than user_{id}_permissions.

->env([
'PATH' => '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:' . (getenv('PATH') ?: ''),
])
->run(['composer', 'install', '--no-interaction']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: MEDIUM

Description: Plugin install treats a PSR-4 namespace prefix as enough to run composer install on a caller-supplied git or zip composer.json. The command is composer install --no-interaction with scripts, Composer plugins, and root repositories left at Composer defaults, and with no lockfile required. A composer.json that only declares an allowed ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages\ prefix can therefore run pre-install shell or PHP as the queue worker and can resolve require from an attacker repository before any plugin service provider is loaded.

Impact: manage-plugins is an explicit operator permission (not granted to every signed-up user, and not on the default Administrators group), but it is not host shell access. This PR adds a production path that executes the artifact publisher's dependency metadata on the worker. That is a larger blast radius than booting the plugin's own PHP: root scripts run even when extra.laravel.providers is absent, and repositories plus an unpinned require fetch and execute code that is not in the selected git ref or zip. Those commands run as the application user with the plugin directory under storage (landlord or storage/tenant_{id}), so they can read the application .env and tenant files on that host.

Remediation: Run composer with --no-scripts and --no-plugins. Reject composer.json scripts, config.allow-plugins, and repositories entries unless they are on an explicit allowlist. Require a committed composer.lock (or another pinned dist) and install from that lock so the selected git ref or zip cannot float dependencies.

File::deleteDirectory($destination);
}
File::ensureDirectoryExists(dirname($destination));
File::copyDirectory($source, $destination);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: MEDIUM

Description: TenantPluginAssetPublisher::publishPlugin copies plugin public/ onto the tenant public disk with File::copyDirectory and no symlink or realpath check. Laravel 13 Filesystem::copyDirectory recurses when SplFileInfo::isDir() is true and otherwise calls PHP copy(); unlike deleteDirectory in the same class, it never checks isLink(). On Linux, PluginManager::cloneRepository runs git clone without core.symlinks=false, so a committed symlink is materialized under storage/plugins (storage/tenant_{id}/plugins when the tenant storage path is active). A link whose target is a file is written to the destination as a regular file; a link whose target is a directory is walked and copied. publishPlugin's is_dir($source) also follows a public/ entry that is itself a symlink to a directory. finishPluginSetup publishes when multitenancy is on, PLUGIN_TENANT_ASSETS_ENABLED is true (the default), and a tenant is current; queued installs are tenant-aware by default. The bytes land at storage/tenant_{id}/app/public/vendor/processmaker/packages/{package}/, which SwitchTenant uses as the public disk root. GET /storage/{path} is registered before the auth middleware, and StorageController serves the path when is_file and is_readable. The copied object is a normal file, so the URL does not need '..'. From storage/tenant_{id}/plugins/{name}/public, a relative link such as ../../../../../.env resolves to the application .env; the same layout can point at another tenant's storage/tenant_{other}/ tree, which the shared PHP user can read. PluginManager::copyDirectory (zip and local installs) uses the same is_dir/copy follow. removePluginPath and deleteDirectory unlink plugin symlinks and return without deleting the target.

Impact: A manage-plugins user who installs an untrusted git plugin (or who runs plugin:publish-tenant-assets against one) publishes file contents from outside the plugin tree onto that tenant's public disk. Anyone who can request the tenant host can then read those bytes with no credentials, including application secrets in .env and other tenants' files on the same host. The new publisher is the boundary between the plugin tree and the world-readable storage disk, and this path crosses it.

Remediation: When publishing plugin public/ and when PluginManager::copyDirectory copies a plugin tree, skip or reject any symlink. Copy only regular files whose realpath stays inside the source directory being copied, and do not recurse through a directory symlink. Treat a public/ path that is itself a symlink to an outside directory as outside the plugin tree.

/**
* Path relative to a public disk root, e.g. vendor/processmaker/packages/package-plg.
*/
public static function relativeVendorPath(string $packageName): string

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: MEDIUM

Description: The tenant asset publisher builds a delete/copy path from the composer package segment and does not reject '.' or '..' after it turns backslashes into slashes. packageNameFromPluginPath() keeps only the substring after the last '/', so a name like attacker/............\tenant_2 stays a traversal segment. relativeVendorPath() then produces vendor/processmaker/packages/../../../../../../tenant_2, and tenantPackageRoot() concatenates that onto storage/tenant_{current}/app/public. File::isDirectory() and File::deleteDirectory() use is_dir and FilesystemIterator, which resolve '..' on Linux, so the delete runs on storage/tenant_2 (six '..' segments) or further up with more segments. filesystemPathForStorageUrl() already returns null when a URL contains '..'; the write path does not.

Impact: A tenant operator with manage-plugins can delete another tenant's storage tree (uploads, private files, and that tenant's plugin files under storage/tenant_{id}), or with additional '..' segments delete other app-owned directories such as the application root. That crosses the tenant public-disk boundary this publisher is supposed to keep: writes were meant to stay under storage/tenant_{id}/app/public/vendor/processmaker/packages/{package}. The app user owns every tenant directory, so the missing segment check is the only containment. This is not anonymous access; the caller must hold manage-plugins and multitenancy must be on so the tenant-aware queue restores currentTenant.

Remediation: After normalizing '' to '/', split the package folder and reject empty segments and any segment that is '.', '..', or contains '/'. Resolve the destination with realpath (create it only under the prefix) and require the resolved path to stay inside tenantPublicDiskRoot($tenantId).'/'.VENDOR_PACKAGES_PREFIX.'/{single-segment package}'. Apply the same check in both publishPlugin and removePublishedPlugin.

@henryjonathanquispe henryjonathanquispe changed the title Four 34294 b FOUR-34294-B: Plugins with K8s Nov 24, 2026
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.

4 participants