Repository navigation
FOUR-34294 Plugins PM4 - #9125
FOUR-34294 Plugins PM4 #9125henryjonathanquispe wants to merge 38 commits into
Conversation
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
…the command: php artisan horizon:terminate
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
PR SummaryHigh Risk Overview Adds an end-to-end plugin platform for ProcessMaker 4: Admin and API expose list/install/reinstall/uninstall/toggle as queued jobs with Reviewed by Cursor Bugbot for commit dd739bb. Bugbot is set up for automated code reviews on this repo. Configure here. |
| } | ||
|
|
||
| try { | ||
| $zip->extractTo($tmpExtractDir); |
There was a problem hiding this comment.
Zip extract allows path escape
High Severity
ZipArchive::extractTo() writes every zip entry before plugin validation. Entries with ../ paths can overwrite files outside the temp directory, including .env or application code, even when composer.json later fails validation and the plugin is rejected.
Reviewed by Cursor Bugbot for commit 1a97475. Configure here.
| ->expectsOutput('The number of copies must be a positive integer.') | ||
| ->assertExitCode(1); | ||
| } | ||
| } |
There was a problem hiding this comment.
Unrelated duplicate-request test added
Medium Severity
This feature test invokes processmaker:duplicate-request, but that artisan command is not in this repository. The file is unrelated to plugins and will fail the console test suite whenever it runs.
Reviewed by Cursor Bugbot for commit 93a078b. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
| } | ||
| if (file_exists($zipPath)) { | ||
| unlink($zipPath); | ||
| } |
There was a problem hiding this comment.
Zip cleanup uses undefined name
Medium Severity
The installFromZip finally block passes $repoName to deleteDirectory before that variable is assigned when extractTo or early setup throws. PHP 8 then raises an ErrorException in finally, which drops the original error and skips the zip unlink.
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
| public function broadcastOn() | ||
| { | ||
| return new PrivateChannel('ProcessMaker.Models.User.' . $this->userId); | ||
| } |
There was a problem hiding this comment.
Plugin logs broadcast with null user
Medium Severity
PluginLog always broadcasts on ProcessMaker.Models.User.{userId} and has no broadcastWhen. CLI install/uninstall failure events omit userId, so Echo is pushed to User. (empty id). That can error the broadcaster and never reach an operator.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
| public ?string $zipPath = null, | ||
| public ?string $gitUsername = null, | ||
| public ?string $gitToken = null, | ||
| ) { |
There was a problem hiding this comment.
Git tokens persist on queued jobs
Medium Severity
InstallPlugin stores gitToken and gitUsername as public constructor properties on a ShouldQueue job. Horizon/Redis payloads and failed_jobs therefore keep the operator’s git credential after the request returns, even though logs redact the same secret.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
| . $fragment; | ||
| } | ||
|
|
||
| $token = env('GITHUB_TOKEN'); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: Plugin installs put a GitHub credential in the git remote URL. prepareGitUrl embeds the request git token, or env GITHUB_TOKEN when the request omits one and the URL is https://github.com/..., and cloneRepository / updateExistingRepository pass that URL to git clone and git remote set-url. Git keeps the URL in the clone process arguments for the whole clone and writes it to storage/plugins//.git/config before the later origin scrub. Those set-url calls ignore exit status, and a killed worker skips the scrub, so the credential can stay in the plugin origin. /proc//cmdline and a typical 0644 .git/config are readable by other users on the host; the environment is not. The admin API is not the leak: list() strips userinfo before returning the remote.
Impact: A same-host user who cannot read the worker environment can still capture the operator's git token or the deployment GITHUB_TOKEN while a plugin clone or fetch is running, and can read it later if the origin scrub never succeeds. That credential is the one this feature uses to fetch private plugin repositories, so disclosure gives access to whatever private GitHub content the token can read. This is limited to a host that already runs the queue worker; it does not hand the token to the repository owner. GitHub receives it only as clone authentication.
Remediation: Pass the token through a short-lived GIT_ASKPASS helper (or an equivalent credential helper) so it is not part of the remote URL, argv, or .git/config. After every clone or fetch, read origin back and fail the install if userinfo is still present. Do not fall back to the ambient GITHUB_TOKEN for an arbitrary operator-chosen github.com URL; require an explicit credential for that request.
| { | ||
| $app->forgetInstance('routes.cached'); | ||
|
|
||
| if (!$this->shouldReinitializeRouter() || !$app->routesAreCached()) { |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: On a long-lived multitenant worker, SwitchTenant::reloadRouteCache() require()s a tenant's routes-v7.php into the shared Laravel router and then leaves that compiled collection in place when a later tenant has no cache file. forgetCurrent() only clears APP_ROUTES_CACHE. Forgetting the routes.cached binding does not change what Router::dispatch() matches.
Impact: After any tenant installs, toggles, or uninstalls a plugin, route:cache writes storage/tenant_{id}/routes-v7.php and the next Octane request for that tenant loads it into the process-wide router. A later request for a tenant with no cache file is made current (database, storage, app key) and then dispatched with the previous tenant's compiled route table, including that tenant's plugin endpoints. CompiledUrlMatcher tries those routes first, so they are reachable on the victim tenant's host and run against the victim tenant's data. The cache file is Laravel's generated setCompiledRoutes payload, not arbitrary PHP; the impact is cross-tenant route dispatch, including extra or shadowing endpoints the victim did not enable.
Remediation: On every tenant switch, replace the shared route collection before serving the request. If storage/tenant_{id}/routes-v7.php exists, require it. If it does not, install a fresh RouteCollection and load the current process route map (or a landlord collection snapshotted before any tenant cache was applied). Do the same restore in forgetCurrent() so the previous compiled table cannot survive until the next makeCurrent(). Do not treat forgetInstance('routes.cached') as a router reset. Add a regression test that require()s one tenant cache, switches to a tenant with no cache file, and asserts the previous plugin route no longer matches.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
…ce for multitenancy support
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
1 similar comment
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
| } | ||
|
|
||
| return trim($reread->output() . "\n" . $update->output()); | ||
| } |
There was a problem hiding this comment.
Edge Caddyfile never reloads
High Severity
tenants:octane-sync --apply rewrites Caddyfile.edge then only runs supervisorctl reread/update. The edge program ini is unchanged, so supervisor does not restart octane-edge. That process is started with admin off, so Caddy cannot reload the new routes either. Added, removed, or renamed tenant domains stay on the old in-memory config until someone restarts the edge process by hand.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f9f0947. Configure here.
|
|
||
| $lines[] = ' handle {'; | ||
| $lines[] = ' respond "Unknown tenant host" 502'; | ||
| $lines[] = ' }'; |
There was a problem hiding this comment.
Edge proxy breaks Octane health
High Severity
The generated edge Caddyfile listens on the default Octane port (8001) and answers any non-tenant Host with 502 (or 503 when there are no tenants). OctaneHeartbeat probes 127.0.0.1:8001/health/live, whose host never matches a tenant domain, so liveness checks fail after switching to multitenant edge routing.
Reviewed by Cursor Bugbot for commit f9f0947. Configure here.
| $lines[] = " reverse_proxy {$upstream} {"; | ||
| $lines[] = ' header_up Host {http.request.host}'; | ||
| $lines[] = ' header_up X-Forwarded-Proto {http.request.header.X-Forwarded-Proto}'; | ||
| $lines[] = ' header_up X-Forwarded-For {http.request.remote.host}'; |
There was a problem hiding this comment.
Edge strips client forwarded IP
Medium Severity
The edge reverse_proxy sets X-Forwarded-For to {http.request.remote.host}. Nginx already terminates TLS and proxies to 127.0.0.1, so tenant Octane sees the loopback hop instead of the original client address nginx put on that header.
Reviewed by Cursor Bugbot for commit f9f0947. Configure here.
| protected function runComposerInstall(string $pluginPath, string $repoName, ?int $userId = null): void | ||
| { | ||
| set_time_limit(0); | ||
| $process = Process::path($pluginPath) | ||
| ->forever() | ||
| ->env([ | ||
| 'PATH' => '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:' . (getenv('PATH') ?: ''), | ||
| ]) | ||
| ->run(['composer', 'install', '--no-interaction']); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: Plugin install treats an operator-supplied composer.json as a trusted Composer project. finishPluginSetup always runs composer install --no-interaction with cwd set to storage/plugins/ after a PSR-4 prefix check only. Composer still runs root scripts and allowed Composer plugins, honors repositories, and resolves config.vendor-dir relative to that directory, so a relative vendor-dir such as ../../../vendor writes the application vendor tree. The subprocess environment is only PATH, which does not disable those features. Disable and uninstall only rename or delete the plugin directory, so packages and script side effects written outside it stay loaded by the application autoload.
Impact: A manage-plugins operator who installs a Git URL or zip (or reinstalls one) lets the queue user execute code chosen by the plugin author during dependency install, not only the plugin service provider that runs while the plugin directory is enabled. Install scripts and Composer plugins run as that user and can change any path the user can write. config.vendor-dir is three levels above storage/plugins/, i.e. the application vendor directory, whose packages the root autoload keeps loading after the plugin folder is renamed to _ or removed. That crosses the plugin-directory boundary this feature uses as the enable/disable gate.
Remediation: Run Composer only inside the plugin tree: set COMPOSER_VENDOR_DIR to storage/plugins//vendor, pass --no-scripts --no-plugins --no-dev, and reject composer.json repositories, scripts, config.allow-plugins, and config.vendor-dir (or any vendor-dir that does not resolve inside that plugin directory). Prefer a lockfile from the reviewed revision. On failed install, roll back files written outside the plugin directory, not only the plugin folder.
| '}', | ||
| '', | ||
| ":{$port} {", | ||
| ]; |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: Multitenant tenants:octane-sync writes a Caddyfile.edge site address of :{edge_port} (default :8001) with auto_https off, so the edge FrankenPHP process accepts cleartext HTTP on every interface. edge_host (default 127.0.0.1) is never applied to that listener. A client that can open that port sends a tenant Host and is reverse-proxied to that tenant's Octane.
Impact: Turning on multitenancy and applying tenants:octane-sync replaces the loopback Octane listener with an all-interfaces cleartext hop in front of every tenant app. Anyone who can route to the host on edge_port reaches tenant HTTP without the TLS-terminating nginx proxy the new config documents at http://127.0.0.1:{edge_port}. Tenant selection is the Host header, so one open port covers every configured tenant. Application auth still applies; the lost boundary is the localhost front proxy (TLS and any nginx access controls). Default port 8001 and public tenant hostnames make the request scriptable once the port is reachable.
Remediation: Set the edge site address to edge_host and edge_port, for example 127.0.0.1:8001 when those defaults are in use, matching renderSingleSupervisorProgram()'s --host flag and the nginx localhost proxy_pass. Keep auto_https off only for that loopback hop. Update OctaneTenantRuntimeSyncTest so it expects the edge_host bind instead of :{port}.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 11 total unresolved issues (including 10 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 15dcfed. Configure here.
| { | ||
| $pluginDir = storage_path('plugins'); | ||
| $pluginPath = "{$pluginDir}/{$pluginName}"; | ||
| $pluginDisabledPath = "{$pluginDir}/_{$pluginName}"; |
There was a problem hiding this comment.
Plugin names allow storage path traversal
High Severity
Uninstall, toggle, and reinstall join the unsanitized {name} route value onto storage/plugins. A name of .. resolves to the storage root, so uninstall can recursively delete it and toggle can rename it. API routes do not constrain the parameter to a plugin folder name.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 15dcfed. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
| continue; | ||
| } | ||
|
|
||
| app()->register($provider); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: A tenant user with manage-plugins can install a plugin whose extra.laravel.providers classes are app()->register()'d on TenantResolved. Horizon workers are shared across tenants and stay alive for many jobs (default maxJobs 100 on the default queue, 10 on bpmn). Spatie queue tenancy makes the job's tenant current in that same process, which boots those providers, and SwitchTenant::forgetCurrent never unregisters them or their listeners. The next tenant's job still runs the previous tenant's plugin code with the new tenant's database, storage path, and app key.
Impact: Plugin install is supposed to execute only inside the installing tenant. On a shared Horizon worker the provider stays booted after the tenant switch, so tenant A's plugin runs during tenant B's jobs: arbitrary PHP, listeners, and container bindings against B's database and decrypted app key. That is a cross-tenant execution boundary, not an in-tenant admin action. Per-tenant Octane programs (TENANT env and host-based upstreams) are not this sink; the proven path is the shared queue worker.
Remediation: On SwitchTenant::forgetCurrent, before the next tenant is made current, unregister every provider registered for the previous tenant and remove the listeners, bindings, and routes they added, or recycle the worker process on tenant switch. Track the providers loadPlugins registered and do not leave them on a Horizon worker that will makeCurrent() for a different tenant. Per-tenant Octane processes do not need this for HTTP, but the shared queue worker does.
| } | ||
|
|
||
| $command[] = 'restart'; | ||
| $command[] = config('plugin_manager.supervisor_restart_target', 'all'); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: A tenant operator with manage-plugins can toggle, install, or uninstall a plugin and cause this pod's supervisord to restart every program. The reload signal is tenant-prefixed, but supervisorctl restart uses plugin_manager.supervisor_restart_target, which defaults to all. tenants:octane-sync writes octane-edge and octane-tenant-{id} into one supervisor directory and applies them with one supervisorctl, so the default restart stops other tenants' Octane workers and the shared edge proxy.
Impact: On a multitenant Octane pod, an ordinary plugin toggle by one tenant's manage-plugins operator restarts every program in the shared supervisord, including other tenants' octane-tenant-{id} workers and octane-edge. That is a cross-tenant availability break of the shared edge and the other tenants' HTTP workers. Redis scoping shows the signal was meant to stay on the acting tenant; the restart target drops that boundary. The caller is an authenticated tenant API user with manage-plugins, not an anonymous client and not a host-local process.
Remediation: When a tenant is current, default the supervisor restart target to that tenant's program name (octane-tenant-{id}) and do not restart octane-edge or any other tenant program. Keep supervisor_restart_target=all only for the single-tenant supervisord layout. If queue workers must recycle, restart a program that belongs to the acting tenant rather than the shared set.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|






Related Tickets & Packages
Code Review Checklist
ci:deploy
ci:k8s-branch:FOUR-34294
.