Skip to content

FOUR-34533 Severe Vulnerability - Unauthenticated Access to Protected REST API Endpoints from Public Web Entry - #9203

Open
devmiguelangel wants to merge 4 commits into
developfrom
FOUR-34533
Open

devmiguelangel wants to merge 4 commits into
developfrom
FOUR-34533

Conversation

@devmiguelangel

@devmiguelangel devmiguelangel commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

Anonymous Web Entry pages were issuing a Passport API cookie (laravel_token) for the shared anonymous system user. Every auth:api endpoint accepted that cookie, so an anonymous visitor could use the API as that account and reach data belonging to other anonymous submissions, plus resources that only require "is authenticated".

To check: open an anonymous Web Entry in a private window and look at the cookies. Before this change a laravel_token is present; after it, there is none. Calling core auth:api endpoints (requests, tasks, screens) with an anonymous session now returns 401.

Solution

  • Added Middleware\CreateFreshApiToken (extends Passport's), used in the web group in bootstrap/app.php. It never issues the API cookie to the anonymous identity and expires a stale one.
  • ProcessMakerAuthenticate: the anonymous identity gets 401 on auth:api routes that don't list the anon guard. This also covers cookies issued before the fix and every package route behind auth.
  • New AnonymousUser::isAnonymousIdentity() shared by both checks; LoginController::keepAlive uses it too.
  • Routes that allow anon (auth:web,anon, auth:api,anon, i.e. Web Entry) and regular users' cookies are unchanged.
  • Tests: tests/Feature/Auth/AnonymousApiTokenTest.php.
image

How to Test

  • ./vendor/bin/phpunit tests/Feature/Auth/AnonymousApiTokenTest.php
  • Also run tests/Feature/Auth, AuthTest, Api/ProcessRequestsTest, Api/TasksTest, Api/ScreenTest, TaskControllerTest.
  • Manual: anonymous Web Entry start → submit → intermediate task works; no laravel_token cookie; /api/1.0/requests|tasks|screens return 401; a logged-in user still gets the cookie and the app works.

Related Tickets & Packages

FOUR-34533
https://github.com/ProcessMaker/package-webentry/pull/307
https://github.com/ProcessMaker/package-collections/pull/507

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:package-webentry:FOUR-34533
ci:package-collections:FOUR-34533

ci:deploy

.

@cursor

cursor Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes authentication middleware and Passport cookie issuance for a shared system account, which is security-critical and could affect Web Entry vs. normal API access if guards are misconfigured.

Overview
Stops the shared anonymous Web Entry account from receiving or using the Passport laravel_token cookie on general auth:api routes, closing a path where anonymous visitors could act as _pm4_anon_user against core API endpoints.

A custom CreateFreshApiToken middleware (wired in bootstrap/app.php instead of Passport’s default) skips issuing fresh API cookies for anonymous identities and clears any existing Passport cookie on web responses. LoginController::keepAlive applies the same rule when refreshing the cookie on POST.

ProcessMakerAuthenticate now returns 401 when the resolved user is the anonymous system account on routes that use auth:api without also allowing the anon guard; Web Entry routes that declare auth:api,anon remain allowed. Shared detection lives in new AnonymousUser::isAnonymousIdentity() (covers both AnonymousUser and a plain User loaded by Passport).

Feature tests in AnonymousApiTokenTest assert 401 on requests/tasks/screens (including destructive calls) for anonymous cookies, while normal users still get the cookie on web pages and can call the API.

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

@devmiguelangel devmiguelangel changed the title fix(auth): do not issue API token to the anonymous Web Entry user [FOUR-34533] FOUR-34533 Severe Vulnerability - Unauthenticated Access to Protected REST API Endpoints from Public Web Entry Nov 26, 2026
@devmiguelangel devmiguelangel self-assigned this Nov 26, 2026
@cursor
cursor Bot requested review from danloa and nolanpro November 26, 2026 18:31
@devmiguelangel
devmiguelangel requested review from pmPaulis and removed request for danloa and nolanpro November 26, 2026 18:39
@nolanpro

Copy link
Copy Markdown
Contributor

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

1 similar comment
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-c02f0e872e.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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants