Skip to content

FOUR-34294 Plugins PM4 - #9125

Open
henryjonathanquispe wants to merge 31 commits into
developfrom
FOUR-34294
Open

henryjonathanquispe wants to merge 31 commits into
developfrom
FOUR-34294

Conversation

@henryjonathanquispe

@henryjonathanquispe henryjonathanquispe commented Nov 6, 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-34294
.

julceslauhub and others added 17 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 6, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Plugin install runs shell/git/composer and rewrites tenant route caches with broad runtime impact; API accepts git tokens and file uploads, so misconfiguration or overlapping plugin ops could affect multitenancy stability.

Overview
Adds two major capabilities: a cross-project requirements management toolchain and first-class plugin install/runtime support in ProcessMaker.

Requirements (manage-requirements) introduces shared JSON schemas, MD/YAML templates, and npm gates (check:requirements, validate:requirements) that validate catalog shape, companion markdown, dependsOn, and stub acceptance criteria. A new Python quality harness (judge_catalog.py, question YAML, optional Laya evals) can fail builds on weak FR quality alongside unit tests for the validators.

Plugins adds PluginManager plus artisan commands and queued jobs (install/reinstall/uninstall/toggle from HTTPS git, zip, or optional local path via PLUGIN_INSTALL_ALLOW_LOCAL_PATH), PluginLog broadcasts for the admin UI, and API routes under api/1.0/plugins. Install flows run composer, plugin install commands, per-tenant public asset publishing, route:cache in tenant-aware subprocesses, and Redis-driven supervisor reload (plugin:reload-listen). Multitenancy changes include tenant-scoped route cache paths in SwitchTenant, Mix resolution for tenant-published vendor assets, and Screen builder / modeler loading of enabled storage/plugins scripts without duplicate tags. Admin navigation gains Plugins (view-plugins); .env.example documents the local-install flag.

Reviewed by Cursor Bugbot for commit b7cbb66. 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.

Stale Bugbot comment from a previous run.

Comment thread ProcessMaker/Managers/PluginManager.php Resolved
}

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

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

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a97475. Configure here.

Comment thread ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
page.value = Math.floor(total / value) + 1 || 1;
}
fetch();
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Per-page last page is off-by-one

Medium Severity

changePerPage sets the page to Math.floor(total / value) + 1 when the current page would exceed the new size. When total is an exact multiple of the new page size that becomes one past the last page, so the table shows an empty range such as 31–60 of 30.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a97475. Configure here.

Comment thread ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved

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

@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 ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved

@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 ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
->expectsOutput('The number of copies must be a positive integer.')
->assertExitCode(1);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93a078b. 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.

Stale Bugbot comment from a previous run.

Comment thread tests/Managers/PluginManagerTest.php Resolved
@nolanpro

nolanpro commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.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 ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
@cursor
cursor Bot requested review from caleeli and nolanpro November 10, 2026 17:01
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
Comment thread ProcessMaker/Managers/PluginManager.php Resolved
public function uninstall(string $pluginName, ?int $userId = null): void
{
$pluginDir = storage_path('plugins');
$pluginPath = "{$pluginDir}/{$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.

🔒 Agentic Security Review

Severity: MEDIUM

Description: DELETE /api/1.0/plugins/{name} forwards the raw route parameter into PluginManager::uninstall, which joins it onto storage_path('plugins') and recursively deletes that path. The route has no where() constraint, and uninstall does not reject '.', '..', or other dot segments or require the realpath to stay inside the plugins directory. For name=.. (or %2e%2e, which Laravel rawurldecodes before routing), is_dir succeeds once storage/plugins exists and deleteDirectory unlinks the parent directory: the current tenant storage root when multitenancy is on (storage/tenant_{id}), or the application storage directory when it is off. The missing artisan command is only logged; deletion runs before route-cache refresh. Toggle is not a second successful sink for '..': rename() of that parent into plugins/_.. fails because the destination is inside the source.

Impact: A caller who can pass auth:api and can:manage-plugins (or is_administrator, which Gate::before allows) can destroy the current tenant storage tree, including the local upload disk under storage/app and the default keys disk under storage/keys, instead of one plugin directory. That is other users' files and on-disk key material for the tenant, not another tenant and not code execution. The same permission can install plugin code; this path still matters because it skips plugin validation and the plugins-directory boundary with one queued request.

Remediation: Before uninstall or toggle, take the plugin name with basename, reject empty, '.', '..', slashes, and backslashes, and require realpath of the resolved directory to be a direct child of realpath(storage_path('plugins')). Do not call deleteDirectory or rename until that check passes. Abort uninstall when the plugin command cannot be run rather than continuing into deletion.

@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 ProcessMaker/Managers/PluginManager.php Resolved
}

$cleanOrigin = $this->stripEmbeddedCredentialsFromHttpUrl($canonicalRepoUrl ?? $repoUrl);
Process::path($destination)->timeout(60)->run(['git', 'remote', 'set-url', 'origin', $cleanOrigin]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reinstall drops private git credentials

Medium Severity

After clone, origin is rewritten to a credential-free URL, and updateExistingRepository now always restores a stripped origin. reinstall fetches from that origin and never reapplies GITHUB_TOKEN or the install token, so private Git plugins fail on reinstall.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2179897. Configure here.

}

$command[] = 'restart';
$command[] = 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.

🔒 Agentic Security Review

Severity: MEDIUM

Description: A tenant user with manage-plugins can install, reinstall, uninstall, or toggle a plugin and thereby restart every program on the shared pod's supervisord. The job publishes a tenant-prefixed Redis reload; plugin:reload-listen, running with that tenant current, launches supervisorctl restart using plugin_manager.supervisor_restart_target, which defaults to all. .env.example does not override that default. The in-repo supervisord owns one processmaker-horizon and one processmaker-echo-server for the whole instance, and queues are tenant-aware by default, so those programs serve every co-located tenant.

Impact: On a multitenant instance, one tenant's plugin operator can repeatedly stop the shared Horizon workers and the shared echo server, plus any other program that supervisord owns (including other tenants' reload listeners). In-flight jobs and realtime notifications for co-located tenants drop. Plugin lifecycle is a tenant permission; process control of the shared supervisord is an instance-level boundary this change crosses.

Remediation: Do not default the reload action to supervisorctl restart all. Signal only the queue workers that must reload plugin code (for example horizon:terminate or queue:restart), or default supervisor_restart_target to the single queue-worker program. If a deployment is known to be one tenant per supervisord, require an explicit opt-in before restarting every program. Keep the tenant-prefixed channel, and do not let one tenant's plugin job restart programs that serve other tenants.

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: A Git token submitted to the plugin install API is stored on the public InstallPlugin::$gitToken property and serialized into the queue command. With multitenancy job tracking left at its default, that command is copied into the Redis hash tenant_jobs:{tenant}:{job} for 24 hours, and GET api/1.0/tenant-queues/{tenantId}/jobs/{jobId} unserializes it and returns every property. The job-details screen prints that JSON. Any is_administrator of the same tenant can read the token; QUEUE_UI_ALLOW_ALL_TENANTS (default false) is required before another tenant's administrator can.

Impact: The token is a caller-supplied Git credential used for a private clone, and this change is the first path that places it in queue state. Plugin logs and the submitting user's PluginLog broadcast run that text through redactHttpUserInfoFromString, while the tenant job hash, job-details API, and on failure the failed_jobs.payload column keep the raw token. Every administrator of the tenant can retrieve a credential the submitter entered for the clone, including a manage-plugins user who is not an administrator. The live queue copy exists until the worker finishes; the tenant hash remains for 24 hours after processing; a failed install also leaves the serialized command in failed_jobs with no expiry.

Remediation: Do not leave gitToken or gitUsername on the serialized job. Load them from a short-lived encrypted store keyed by the job id and consume that entry in handle(), and make InstallPlugin serialization drop both properties. Also omit those keys in TenantQueueController::getJobDetails and in the payload copied by trackJobByTenant so an in-flight or completed hash cannot return them. Encrypting the command with ShouldBeEncrypted protects the queue backend and failed_jobs only if the value stored and reflected is still ciphertext; pair that with the property strip so the admin job view cannot show the token.

@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 ProcessMaker/Managers/PluginManager.php Resolved
Comment thread routes/api.php
@@ -47,6 +48,13 @@
use ProcessMaker\Http\Controllers\TestStatusController;

Route::middleware('auth:api', 'setlocale', 'bindings', 'sanitize', 'manager')->prefix('api/1.0')->name('api.')->group(function () {

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: Plugin install, reinstall, uninstall, and toggle routes were added inside the api/1.0 group that already runs the manager middleware. A non-administrator process manager who has previously received a non-empty processesIManage task page keeps the user_{id}_manager cache flag. On the later plugin request, IsManager parses can:manage-plugins from the route and writes that ability into the legacy permission cache before CustomAuthorize runs. The Gate still denies manage-plugins because it checks PermissionServiceManager, then CustomAuthorize accepts the simulated legacy list and the controller queues the plugin job.

Impact: A process manager who was not granted manage-plugins can queue installation of an attacker-controlled HTTPS repository or zip. The worker runs composer install --no-interaction in the plugin directory, so composer scripts execute as the application user, then runs the plugin artisan install command and registers the plugin service providers in the application. When the plugin reload listener is running, the same path publishes a runtime reload that schedules supervisorctl restart. That is host and application control beyond the process-manager role, and it is broader than script tasks that already execute inside the Docker script executor.

Remediation: Do not let IsManager simulate manage-plugins. Move the plugin mutation routes out of the manager middleware group, or make IsManager ignore manage-plugins (and install, uninstall, and toggle equivalents) when it builds the simulated legacy list. Authorize these routes only from a stored manage-plugins grant that CustomAuthorize cannot satisfy from the request-scoped cache.

protected function runComposerInstall(string $pluginPath, string $repoName, ?int $userId = null): void
{
set_time_limit(0);
$process = Process::path($pluginPath)

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: A tenant administrator (is_administrator) or any principal with manage-plugins can install an arbitrary plugin from an https URL or zip. POST /api/1.0/plugins/install only checks that permission, then queues InstallPlugin in the current tenant. finishPluginSetup accepts the package when composer.json has a ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages\ PSR-4 prefix, then runs composer install --no-interaction in the plugin directory and php artisan {folder}:install. Composer runs root-package scripts by default; --no-interaction does not disable them, and the command is not passed --no-scripts. The artisan subprocess is the same OS user and only receives TENANT. SwitchTenant isolates storage_path (storage/tenant_{id}), the database, and APP_ROUTES_CACHE. TenantsCreate creates each tenant directory with mkdir(..., 0755) and no separate uid, so the shared application user can read and write sibling tenant trees, landlord storage, and the host .env. After install, PluginServiceProvider registers extra.laravel.providers from that tree into the shared app.

Impact: On a multitenant host this gives one customer tenant admin, or anyone that tenant grants manage-plugins, code execution as the shared PHP/queue user. That identity can read and write other tenants' storage/tenant_* files and host secrets such as .env (landlord database credentials and app keys). Tenant storage and database switching do not confine the child process. Process scripts in this codebase go through the Docker script executor; plugin setup does not. The install is a single authenticated API call with a crafted zip or repository, so it is scriptable.

Remediation: Run plugin composer and artisan setup in a tenant-scoped sandbox (separate uid, chroot, or container) that cannot read other tenants' storage or host secrets such as .env. Invoke composer with --no-scripts unless the package is on an explicit allowlist. Do not register extra.laravel.providers from an unsandboxed install into the shared application process.

);
}

$loader->addPsr4($namespace, $fullPath);

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: Tenant plugin autoloaders and service providers are registered on the process-global Composer ClassLoader and the long-lived Laravel container, and nothing on the tenant switch tears them down. After a tenant with manage-plugins installs a plugin, the next tenant served by the same Octane or Horizon worker still runs that plugin's booted providers, listeners, and included autoload files.

Impact: Multitenancy is the default deployment, with one Octane (FrankenPHP) server and Horizon worker pool for every tenant hostname. A tenant operator who can call POST /api/1.0/plugins/install (can:manage-plugins) supplies the plugin composer.json and PHP. PluginServiceProvider loads it when that tenant becomes current. forgetCurrent then switches the database, storage path, and decrypted app key for the next tenant but leaves the first plugin's provider booted. Listeners, observers, and autoload-file side effects from tenant A therefore run inside tenant B's request or job, with tenant B's connection and app key already in the container. A supervisor restart after install only clears the process until the next TenantResolved for tenant A loads the plugin again. That crosses the tenant isolation boundary the switch task is supposed to enforce.

Remediation: Do not load tenant plugin code into a PHP process that will later serve another tenant. Use a worker pool pinned to one tenant, or recycle the worker on tenant switch. Removing PSR-4 prefixes alone is insufficient: already-included autoload files, loaded classes, and listeners registered in provider boot() stay in the process. SwitchTenant::forgetCurrent, Octane RequestTerminated, and the next MadeTenantCurrentEvent need a real unload path if a shared worker remains, including forgetting booted providers and the listeners they registered.

. $fragment;
}

$token = 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: Plugin install lends the worker's GITHUB_TOKEN to any caller-chosen https://github.com URL when the request omits git_username and git_token. prepareGitUrl embeds that token in the clone URL, and git clone authenticates to GitHub as the platform identity. There is no org or repository allowlist; the API only requires an https:// prefix.

Impact: A manage-plugins operator on the internet-facing API, or a process manager whose manager cache flag lets IsManager simulate can:manage-plugins, can fetch private github.com repositories that the platform token can read without knowing the token. Repositories whose composer.json PSR-4 namespace starts with ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages\ stay under the tenant plugins directory and are then composer-installed and executed in the app. Other private repositories are deleted after validation, but the failure event sent to the operator includes the discovered PSR-4 namespaces, so the token was still used and a slice of the private tree was disclosed. Operator logs redact the token string; the credential value is not returned in the HTTP response. This is a tenant-to-platform credential boundary: the plugin operator is not the owner of GITHUB_TOKEN, and the new install path applies that identity to an arbitrary GitHub URL.

Remediation: Do not apply env('GITHUB_TOKEN') to caller-selected repositories. Require the request's own git token, or allowlist the owner/repo the platform token may clone. Pass that credential through GIT_ASKPASS or a credential helper so it is not placed in the clone URL or git remote config.

@henryjonathanquispe henryjonathanquispe changed the title FOUR-34294 Plugins PM4 FOUR-34294 Plugins PM4 Nov 12, 2026
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.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 config/plugin_manager.php Resolved
case 'view-settings':
return redirect()->route('settings.index');
case 'view-plugins':
return redirect()->route('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.

Admin landing never matches view-plugins

Low Severity

The new view-plugins redirect sits in a switch whose canAnyFirst list does not include view-plugins, so that case is unreachable. Users who only have that permission still hit the default AuthorizationException.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cfce9e8. Configure here.

@nolanpro

Copy link
Copy Markdown
Contributor

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

@henryjonathanquispe henryjonathanquispe changed the title FOUR-34294 Plugins PM4 FOUR-34294 Plugins PM4 Nov 13, 2026

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

There are 12 total unresolved issues (including 9 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.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 041e741. Configure here.

}
if (file_exists($zipPath)) {
unlink($zipPath);
}

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

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 041e741. 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.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 041e741. 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 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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 041e741. Configure here.

@nolanpro

Copy link
Copy Markdown
Contributor

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

. $fragment;
}

$token = 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: 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()) {

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

@nolanpro

Copy link
Copy Markdown
Contributor

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

@nolanpro

Copy link
Copy Markdown
Contributor

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

1 similar comment
@nolanpro

Copy link
Copy Markdown
Contributor

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

@nolanpro

Copy link
Copy Markdown
Contributor

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

@decisions-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
65 New issues
64 New Maintainability Issues (required ≤ 0)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube

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

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