Skip to content

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

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

henryjonathanquispe wants to merge 46 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
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@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.

Stale Bugbot comment from a previous run.

}

return config('plugin_manager.supervisor_restart_target', 'all');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tenant restart skips Horizon workers

High Severity

When a reload message includes tenant_id, supervisorRestartTarget restarts only octane-tenant-{id}:* and ignores supervisor_restart_target. Other pods therefore no longer recycle Horizon (or other workers) after a plugin install, uninstall, reinstall, or toggle. Queue jobs and plugin listeners keep stale code until Horizon is restarted some other way.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aced486. Configure here.

return;
}

$this->applyReload($reload, $version, $reload->tenantIdFromMessage($message));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Global version can skip tenant reloads

Medium Severity

The reload version counter and applied-version file are now global, but each message restarts only one tenant. The listener still drops any payload whose version is not strictly greater than the last applied version. Concurrent publishes can deliver a higher version first, so an earlier message for a different tenant is skipped and that tenant's Octane never restarts.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aced486. Configure here.

continue;
}

app()->register($provider);

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: Enabled tenant plugins are booted into the long-lived shared Horizon worker and never unloaded. PluginServiceProvider listens for TenantResolved and calls app()->register() on every extra.laravel.providers entry under the current tenant's storage/plugins directory. Laravel boots those providers immediately in an already-booted worker, so their listeners, observers, and container bindings stay on the process-global dispatcher. SwitchTenant::forgetCurrent() restores storage, disks, the encrypter, and Passport singletons, but it does not unregister those providers. The next tenant-aware job calls makeCurrent(), switches the database and storage, and the previous tenant's plugin code still runs. horizon:terminate after install or toggle only recycles the process; the new worker accumulates providers again as soon as it serves more than one tenant (default supervisor maxProcesses is 1 and maxJobs is 10–100). Per-tenant Octane HTTP workers pinned with TENANT= are not this sink.

Impact: A tenant administrator (is_administrator bypasses manage-plugins) can install a plugin whose service provider registers process-global callbacks. Those callbacks then execute inside later jobs while the shared Horizon worker is switched onto another tenant, so the plugin can read and write that tenant's database and storage and use that tenant's app key. That crosses the tenant code and data boundary this PR otherwise enforces by loading plugins only from the current tenant storage path and skipping disabled '_' directories. The actor is an authenticated tenant admin on the public API, not an anonymous client and not a corp-network operator.

Remediation: Do not leave app()->register() side effects in a process that serves more than one tenant. On forgetCurrent, before the next makeCurrent, unregister plugin providers and remove the listeners, observers, middleware, and bindings they added (or boot plugins only in a TENANT-pinned process, the way multitenant Octane HTTP already is). horizon:terminate on install is not a substitute: the replacement worker still loads every tenant's providers into the same process.

{
$app->forgetInstance('routes.cached');

if (!$this->shouldReinitializeRouter() || !$app->routesAreCached()) {

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: On a shared Octane worker (octane:start with no TENANT pin), reloadRouteCache() forgets only the routes.cached binding and returns when the incoming tenant has no storage/tenant_{id}/routes-v7.php. The singleton router keeps the previous tenant's compiled route collection, so the next request is matched with that collection after the database has already switched.

Impact: Tenant route isolation fails on the shared HTTP worker. A plugin install, toggle, or uninstall on tenant A runs route:cache and require()s storage/tenant_A/routes-v7.php into the long-lived router. A later request for tenant B, which never built that file, is dispatched through A's compiled routes, including A's plugin routes, while SwitchTenantDatabaseTask uses B's database. Callers on B's host therefore execute A's controllers against B's data. Workers started as octane-tenant-{id} with TENANT set do not switch tenants and are outside this chain; tenants:octane-sync is a separate supervisor layout and does not clear the router on the miss path.

Remediation: On every tenant switch, install that tenant's compiled routes or explicitly drop the previous compiled collection and load the uncached route files when storage/tenant_{id}/routes-v7.php is absent. Do the same in forgetCurrent so a worker cannot keep another tenant's CompiledRouteCollection. Add a test that require()s tenant A's cache, switches to tenant B with no cache file, and asserts the router no longer contains A's routes.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@henryjonathanquispe henryjonathanquispe changed the title FOUR-34294-B: Plugins with K8s FOUR-34294-B: Plugins with K8s Nov 25, 2026
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@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.

Stale Bugbot comment from a previous run.

customModalButtons.value[2].disabled = false;
customModalButtons.value[0].hidden = true;
customModalButtons.value[1].hidden = true;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Install modal stuck after failure

High Severity

After a failed install, showInstallCloseButton still requires serverRestartReady, which is never set on the error path. The isDone watcher used to reveal Close whenever the job finished; Cancel and Save stay disabled from the running state, so the modal has no working action to dismiss it.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 66d86aa. Configure here.

Comment thread resources/js/admin/plugins/Plugins.vue Resolved
Comment thread resources/js/admin/plugins/Plugins.vue Resolved
}
}

private function catchUp(PluginRuntimeReload $reload): void

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:reload-listen catch-up applies a global Redis reload version with no tenant id, so PluginRuntimeReload::supervisorRestartTarget(null) schedules supervisorctl restart all. A tenant-scoped plugin reload that was only carried on the pub/sub message therefore recycles every supervisor program on the pod, including other tenants' octane-tenant-* programs. The live subscribe path still passes tenant_id and restarts only octane-tenant-{id}:*.

Impact: A manage-plugins operator on one tenant can cross the tenant process boundary this PR adds. publish() stores only an integer at plugin-runtime-reload:version and puts tenant_id solely on the Redis pub/sub payload. On listener startup, or on the reconnect loop after the subscription drops, catchUp() sees the version skew and calls applyReload() without that tenant id. The null-tenant fallback is config('plugin_manager.supervisor_restart_target'), default all, and scheduleSupervisorRestart() documents that restart all stops every program on the pod. Other tenants' Octane workers on that supervisord are restarted even though the live message path was built to restart only octane-tenant-{id}:*. This is a cross-tenant availability break, not code execution in another tenant. It runs when a reload was actually published: PluginManager publishes only after recycleLocalRuntime() fails, which is the coded fallback when this pod cannot restart the tenant program. A healthy local recycle never increments the version.

Remediation: Persist the tenant id with the reload version (or another durable pod-visible record), and have catchUp() pass that id into applyReload(). In multitenant mode, do not call scheduleSupervisorRestart() when the tenant id is missing; skip or fail closed instead of using supervisor_restart_target all. Keep the live message path's octane-tenant-{id}:* target.

@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.

Stale Bugbot comment from a previous run.

serverRestartTimer = setTimeout(() => {
checkServerRestart();
serverRestartTimer = setInterval(checkServerRestart, 3000);
}, 4000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Restart poll beats supervisor delay

Medium Severity

The new first health probe waits 4 seconds, but scheduleSupervisorRestart still sleeps 5 seconds before supervisorctl restart. When local recycle falls back to the Redis reload (the K8s multi-pod path), /health/live can succeed while the pod is still up, serverRestartReady flips true, and Close/reload is enabled about a second before the actual restart begins.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 583701b. Configure here.

Comment thread ProcessMaker/Managers/PluginManager.php Outdated
?string $gitUsername,
?string $gitToken,
): array {
$repoName = $this->extractRepoName($repoUrl);

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: POST /api/1.0/plugins/install takes any https URL and uses the last path segment, after stripping one trailing .git, as the directory under storage/plugins. A segment of . or .. (https://attacker.example/.. or https://attacker.example/....git) resolves to an existing ancestor once storage/plugins exists, so install takes the existing-directory path and runs git remote set-url, fetch, checkout, and pull with that working directory. Git then uses the application repository above storage/ (or above storage/tenant_{id}). Origin restore runs only when pluginPath/.git is a directory, which is storage/.git or storage/plugins/.git, not the repository git updated, so the attacker origin stays. Checkout and pull apply to that application work tree before composer.json validation.

Impact: A caller who can pass can:manage-plugins can point the application git origin at an attacker remote and fetch, check out, and pull that remote over the application work tree. Plugin git commands are supposed to stay in a direct child of storage/plugins that has its own .git. This matters on a same-filesystem git checkout whose queue worker may use that repository: packaged trees are unaffected when .git has been removed, and git safe.directory blocks the worker only when the discovered .git is owned by a different user. storage/plugins must already exist for . and .. to stat; zip install creates it. A checkout git refuses (dirty tracked files) still leaves the attacker origin in place because the restore check never sees the repository that was updated.

Remediation: Accept only a single repo basename that is a direct child of storage/plugins, and reject . and ... If the destination exists, require its realpath to stay inside storage/plugins and require that directory to contain its own .git. Do not run git when the working-directory realpath is storage/, a tenant storage directory, or the application root. Restore remotes using the git dir git actually updated (git rev-parse --git-dir), not destination/.git.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@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.

Stale Bugbot comment from a previous run.

Comment thread tests/Managers/PluginManagerTest.php Resolved
$this->runtime->command($command, $name, $userId);
$this->publishAssets($path, $name, $userId);
$this->runtime->refresh($name, $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.

Refresh failure deletes finished plugin

High Severity

finishPluginSetup used to clear incompleteInstallPath after composer and {name}:install succeeded, before route refresh, so a later refresh failure would not delete the plugin. That clear is gone, and finish() still runs refresh(). A route:cache timeout or bad route cache require now rolls back a completed install.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e97444b. Configure here.

if (is_link($destination)) unlink($destination);
elseif (is_dir($destination)) $this->filesystem->deleteDirectory($destination, $name, $userId, $this->log);
$this->log->running('Copying plugin from local path...', $name, $userId);
$this->filesystem->copyDirectory($source, $destination, $name, $userId, $this->log);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failed symlink unlink is ignored

Medium Severity

Local install used to treat a failed unlink of an existing plugin symlink as a hard PluginInstallException. copyIntoStorage now calls unlink() with no check. If unlink fails and execution continues, copyDirectory can write through the leftover symlink into its target instead of replacing it.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e97444b. Configure here.

return $this->formatUrl($parts, $pass !== '' ? "{$user}:{$pass}@" : "{$user}@");
}
}
$envToken = env('GITHUB_TOKEN');

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: When a manage-plugins caller installs or reinstalls from a https://github.com URL and omits git credentials, PluginGitService::prepareUrl embeds the worker's GITHUB_TOKEN into that URL with no owner or repository allowlist. git clone/fetch then runs as the deployment credential, and a repository that passes plugin validation is written under the current tenant's storage/plugins directory and composer-installed.

Impact: manage-plugins is a tenant permission on the internet-facing API, while GITHUB_TOKEN is a process-wide worker secret that SwitchTenant does not replace. In a multitenant deployment that sets that token, any tenant operator with manage-plugins can point install at a private github.com repository the platform credential can read. The worker checks the repo out into that tenant's plugin directory (storage/tenant_{id}/plugins via the tenant storage path). If composer.json has an allowed ProcessMaker PSR-4 prefix, the private tree stays installed and is loaded for the tenant; otherwise the directory is rolled back after the authenticated fetch. The token string is not returned on the success path (origin is rewritten and log lines redact userinfo). The boundary failure is use of the deployment GitHub identity, not an echo of the secret.

Remediation: Do not apply env('GITHUB_TOKEN') to tenant-supplied URLs. Require the caller to pass git_token for API installs, or allowlist GitHub owners (or repo prefixes) that the deployment credential may fetch. Keep the deployment token on the console/operator path only if that path is not reachable by tenant manage-plugins users.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@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 4 potential issues.

There are 16 total unresolved issues (including 12 from previous reviews).

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 2c1f4ef. Configure here.

Comment thread ProcessMaker/Jobs/InstallPlugin.php Resolved
if (!is_dir($path) && !is_link($path)) {
$this->incompleteInstallPath = $path;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failed zip reinstall deletes existing plugin

High Severity

markForRollback() only records a path when it does not already exist, but zip and local installs still deleteDirectory() an existing plugin first. If copy, validate, or composer install fails afterward, revertFailedInstall() is a no-op and the previously working plugin is gone.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c1f4ef. Configure here.

return;
}
$this->log->running("Plugin {$command} command output:\n\n{$result->output()}", $pluginName, $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.

Plugin install command failures are ignored

High Severity

PluginRuntimeService::command() logs artisan failures and returns without throwing, and it inspects stdout for is not defined even though Symfony Console writes that to stderr. PluginSetupService::finish() then still publishes assets, refreshes routes, and reports the plugin installed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c1f4ef. Configure here.


if ($userId) {
event(new PluginLog($message, $type, $pluginName, $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.

CLI plugin logs never fire

Medium Severity

PluginLogService only dispatches PluginLog when $userId is set. plugin:install and plugin:uninstall listen for that event to print progress but call the manager with a null user id, so success-path logs never reach the console.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c1f4ef. Configure here.

set_time_limit(0);
$process = Process::path($path)->forever()->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: HIGH

Description: With multitenancy enabled, a tenant is_administrator (Gate::before) or any tenant user with manage-plugins can POST /api/1.0/plugins/install with an attacker-controlled HTTPS repo or zip. The tenant-aware InstallPlugin job runs PluginSetupService::finish, which executes composer install with only --no-interaction, so the package's Composer scripts run as the shared queue user. PluginServiceProvider then app()->register's extra.laravel.providers into that same long-lived worker. Sibling tenant data lives in storage/tenant_{id} directories created mode 0755, and SwitchTenant::forgetCurrent only restores the storage path, database, and a few singletons.

Impact: A customer tenant administrator reaches host PHP execution as the shared application user (default Octane supervisor user nginx, one Horizon pool). That identity can read other tenants' storage/tenant_{id} trees and the deployment environment, and plugin providers stay registered in the shared Horizon worker after the tenant switch, so later jobs for other tenants still run the injected code. Per-tenant Octane HTTP programs are separate processes, but they use the same OS user, so the Composer-script sink does not depend on those HTTP workers being shared.

Remediation: When multitenancy is on, treat plugin install as a host operation: require a landlord operator, or run composer and plugin providers under a per-tenant uid whose filesystem view and database credentials cannot see other tenants or the landlord environment. Pass --no-scripts and --no-plugins unless scripts are reviewed. On forgetCurrent, unregister plugin service providers and drop their autoloaders so a shared Horizon worker cannot keep tenant A code while serving tenant B.

public function register(): void
{
// Load plugins when the tenant is resolved
Event::listen(TenantResolved::class, function (): void {

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: With multitenancy on, a tenant administrator (is_administrator, which passes every gate, or manage-plugins) can install a plugin whose PHP stays loaded in the shared Horizon worker. PluginServiceProvider registers each enabled plugin's Composer autoloader and extra.laravel.providers on TenantResolved. Queue jobs are tenant-aware, so one long-lived worker calls makeCurrent per job and forgetCurrent afterward. forgetCurrent restores storage, cache, and database configuration and never unregisters those providers, PSR-4 prefixes, or already-defined classes. The next tenant's job therefore runs the previous tenant's listeners, observers, and container bindings against the new tenant database and storage. Octane HTTP is not this sink: tenants:octane-sync starts one program per tenant with TENANT set. Horizon is a single program with no TENANT, and horizon.php keeps each worker alive for up to maxJobs (100 on supervisor-1). Recycling Horizon after install only restarts the process; the next job for the plugin tenant loads the code again.

Impact: Tenant isolation fails on the shared queue worker. A tenant administrator can install arbitrary plugin PHP (zip or https git; validation only checks composer.json PSR-4 prefixes). After that worker handles one job for their tenant, later jobs for other tenants still execute their plugin code while SwitchTenantDatabaseTask and useStoragePath point at the victim tenant. That is cross-tenant read and write of another tenant's database and files from an internet-facing tenant admin, not a same-tenant plugin action.

Remediation: Do not load tenant plugin providers into a process that will later make another tenant current. Run tenant-aware queue workers as one process per tenant (TENANT set, same pattern as octane-tenant-{id}), or boot plugins in a fresh process per job and exit before the next tenant. forgetCurrent must not be treated as code isolation: PHP cannot unload classes, so unregistering listeners is not sufficient. Stop require()ing storage/tenant_{id}/routes-v7.php into a shared console worker.

public function terminateHorizon(): bool
{
try {
return Artisan::call('horizon:terminate', ['--no-interaction' => true]) === 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: A tenant operator with manage-plugins can install, reinstall, toggle, or uninstall a plugin and, on the successful local Octane recycle path, run a global horizon:terminate. Octane is restarted as octane-tenant-{id} only. Horizon is one shared master (config horizon.prefix is not switched per tenant, and tenants:octane-sync does not render a per-tenant Horizon program). horizon:terminate has no tenant argument, so it drains that shared master and the workers that process every tenant's queues. fast_termination is false, so the command waits for workers to exit; Supervisor is expected to start Horizon again, but every tenant on that Horizon loses queue processing until the restart finishes. The Redis broadcast fallback does not do this: scheduleSupervisorRestart(tenantId) restarts only octane-tenant-{id}:*.

Impact: This crosses the tenant boundary the rest of the new recycle path keeps. A customer tenant admin, reaching the public API with manage-plugins, can repeatedly pause background work for every other tenant that shares the Horizon deployment (timers, BPMN, default/high/low queues). It does not take over the host or disclose secrets. Single-tenant installs are unaffected in kind: there is only one tenant's Horizon to recycle. The path is not available to an ordinary signed-up member without manage-plugins.

Remediation: Do not call horizon:terminate from a tenant plugin refresh when one Horizon serves multiple tenants. After a successful supervisorctl restart of octane-tenant-{id}:*, return without terminating Horizon. Keep the existing fallback, which already restarts only that tenant program. If workers must reload one tenant's plugin code, recycle a tenant-scoped queue program or reload plugins inside the current tenant instead of signaling the shared Horizon master.

return $this->formatUrl($parts, $pass !== '' ? "{$user}:{$pass}@" : "{$user}@");
}

private function withGithubToken(string $url): 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: POST /api/1.0/plugins/install is available to any authenticated administrator (Gate::before) or user with manage-plugins. The url field is only constrained to an https:// prefix. When git_username and git_token are omitted, PluginGitService::prepareUrl falls through to withGithubToken, which reads env('GITHUB_TOKEN') and rewrites every https://github.com/ URL to https://@github.com/. PluginManager::installRepository passes that URL to git clone, so the deployment credential is used for a repository the caller chose. The token is also present in the clone process argv. Clone runs before plugin validation. PluginSetupService::validate then keeps the tree only when composer.json has a PSR-4 namespace under ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages; otherwise install() calls revertFailedInstall and deletes the directory. Repositories that pass that check remain under the current tenant storage/plugins directory (queues are tenant-aware by default). If multitenancy and tenant plugin assets are enabled, public/ is copied onto the tenant public disk and served unauthenticated at /storage/vendor/processmaker/packages//.... The same operator can install a second plugin, which is loaded in-process, and read the retained tree; plugin command stdout is returned through PluginLog. stripCredentials and redactHttpUserInfoFromString remove the token from the stored remote and operator-visible errors after the fetch.

Impact: The host GitHub credential is applied to a caller-selected repository. A tenant plugin operator is a lower-trust principal than the deployment token and does not present their own GitHub credential. They can pull private repositories that token can read into the tenant plugin directory. Durable file disclosure applies to repositories that already meet the plugin composer/PSR-4 check, which is the normal shape of ProcessMaker private packages: the tree stays on disk, public/ is published on the unauthenticated storage route when tenant assets are enabled, and a second plugin install can read the rest. Non-plugin private repositories are still fetched with the token, then deleted, so they are an access oracle rather than a retained copy. This is a host-credential to tenant-operator scope expansion, not an install of a zip the operator already had.

Remediation: Do not attach env('GITHUB_TOKEN') to caller-supplied repository URLs. Require the caller to send git_token, or allowlist the GitHub org/repo before injecting a deployment credential. Keep the token out of git argv (for example GIT_ASKPASS or a credential helper) and continue stripping stored remotes.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

public ?string $tag = null,
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.

🔒 Agentic Security Review

Severity: MEDIUM

Description: Plugin install and reinstall place the caller-supplied Git username and personal access token on public queued-job properties. Laravel serializes those properties into the queue payload, tenant job tracking copies that payload into Redis, and the tenant queue job-details API unserializes the command and returns every property. The admin job-details page prints that JSON, so any other tenant administrator can read the token for the 24-hour Redis TTL.

Impact: A manage-plugins user can submit a Git personal access token that then becomes readable by every is_administrator in the same tenant. Those principals are not the same: manage-plugins is a grantable permission, while getJobDetails only checks is_administrator and the current tenant. The token is an external repository credential and can authorize private Git hosts beyond ProcessMaker. With multitenancy left at its default queue settings, tracking is on and the queue UI is limited to the current tenant. Cross-tenant reads require QUEUE_UI_ALLOW_ALL_TENANTS, which defaults to false.

Remediation: Keep git_username and git_token off serialized job properties. Resolve them inside the worker from a short-lived secret store keyed by a random id, and omit credential fields in TenantQueueServiceProvider before the Redis hash is written and in getJobDetails before properties are returned.

return [$path, $name];
}

private function installedPath(string $name): 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: DELETE /api/1.0/plugins/{name} queues UninstallPlugin with the raw route parameter. installedPath() treats that string as a path segment under storage_path('plugins') and accepts it whenever is_dir() is true, so the single segment '..' resolves to the storage directory that contains plugins. uninstall() still calls removePluginPath()/deleteDirectory() after the generated '..:uninstall' artisan command fails and returns. deleteDirectory() recursively unlinks every child and rmdirs the directory. A caller who already has manage-plugins can therefore wipe the storage root (that tenant's storage/tenant_{id} when the queue is tenant-scoped, or the shared storage directory, including tenant_* trees, when it is not) instead of one plugin folder. The same '..' name on PATCH toggle does not complete the rename: the destination storage/plugins/_.. is inside the source, and rename() fails. '.' resolves only to the plugins directory itself.

Impact: manage-plugins is an explicit grant (it is not on the default Requesters, Process Designers, or Administrators groups; the installer seed user receives every permission). That grant is supposed to remove one direct child of storage/plugins. On the documented nginx + php-fpm install, REQUEST_URI is the original URI, Laravel matches {name} with no pattern, and %2e%2e is decoded to '..', so the worker deletes every file under the storage directory the path resolves to: other users' uploads and private files, logs, and framework state for that tenant, or the shared storage tree when the job has no current tenant. That is a scripted integrity and availability break past the plugin folder. Default FrankenPHP/Caddy does not deliver this payload: Caddyfile and the generated edge Caddyfile leave path sanitizing on, so '.' / '..' / '%2e%2e' are collapsed before PHP. The application has no equivalent gate, and php-fpm remains a supported front end.

Remediation: Before delete or rename, reject plugin names that are not one safe path segment (deny '.', '..', slashes, and empty), then require realpath($target) to be a direct child of realpath(storage_path('plugins')). Apply that check in installedPath() and toggle(), and do not call deleteDirectory() on a path that fails it.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-18d4ccee08.engk8s.processmaker.net

@decisions-sonarqube

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants