PraisonAI claw: authentication middleware guards only the /api/ prefix while the same handlers are served unprefixed
Description
One-screen summary
What is wrong. AuthEnforcementMiddleware at src/praisonaiui/server.py:2849 tests path.startswith("/api/") at :2872, while the same request handlers are also mounted unprefixed at :3164-3181 — /agents (:3164), /sessions (:3170-3171), /run (:3176) and /teams (:3181).
Who can exploit it. An unauthenticated client that can reach the port, on a deployment that sets AUTH_ENFORCE=true and follows the guidance that it protects a publicly exposed instance.
What happens. The client reads the deployment's configuration through /agents and /teams, lists and creates sessions through /sessions, and executes the configured agents through /run, which returns the model's reply, without any credential.
What to change. Apply the middleware to every mount of these handlers rather than to a path prefix — attach it as a dependency on the routers themselves, or mount the authenticated and unauthenticated route sets from one registration point — and add a regression test asserting 401 on the unprefixed /sessions, /run, /agents and /teams with AUTH_ENFORCE=true.
The two mounts and the unauthenticated responses are under ## Proof of Concept below.
Details
praisonai claw serves the PraisonAIUI application through praisonaiui.server.create_app() (src/praisonai-bot/praisonai_bot/integration/host_app.py:259-265, reached from src/praisonai-bot/praisonai_bot/claw/default_app.py and src/praisonai/praisonai/integration/__init__.py). That application's AuthEnforcementMiddleware enforces authentication only on paths under /api/, while the same request handlers are also mounted at the root.
AuthEnforcementMiddlewareis defined atsrc/praisonaiui/server.py:2849and testspath.startswith("/api/")at:2872inpraisonaiuiHEAD; the releasedaiui==0.3.153(class at:2834, test at:2857) andaiui==0.3.154(class at:2849, test at:2872) both carry the same test.- The same handlers are registered unprefixed at
:3164-3181:/sessions(:3170-3171),/run(:3176),/agents(:3164),/teams(:3181). docs/features/deployment.md:73,229states that all/api/*routes require a valid Bearer token and thatAUTH_ENFORCE=trueis the control for public exposure.
Proof of Concept
$ pip install aiui==0.3.154
$ AUTH_ENFORCE=true uvicorn praisonaiui.server:create_app --factory --port 8010 &
$ curl -s -o /dev/null -w '%{http_code}\n' localhost:8010/api/config # 401
$ curl -s -o /dev/null -w '%{http_code}\n' localhost:8010/api/sessions # 401
$ curl -s -o /dev/null -w '%{http_code}\n' localhost:8010/sessions # 200
$ curl -s -X POST localhost:8010/sessions -H 'content-type: application/json' -d '{}' # creates a session
$ curl -s -X POST localhost:8010/run -H 'content-type: application/json' \
-d '{"session_id":"<id>","message":"say hi"}' # runs the agent, returns its replyAll of the last three succeed with no Authorization header, on the release that is current at the time of this report. GET /api/config and GET /api/sessions return 401 on the same server with the same setting, so the middleware is active and its scope is the defect.
Impact
An unauthenticated client that can reach the port reads the deployment's configuration through /agents and /teams, lists and creates sessions through /sessions, and executes the configured agents through /run, which returns the model's reply. The deployment guidance says AUTH_ENFORCE=true protects a publicly exposed instance; it does not, because the handlers are mounted twice and only one mount is checked.
Remediation
Apply the middleware to every mount of these handlers rather than to a path prefix — for example, attach it as a dependency on the routers themselves, or mount the authenticated and unauthenticated route sets from one registration point so a second prefix cannot bypass the check. A regression test that asserts 401 on the unprefixed /sessions, /run, /agents and /teams with AUTH_ENFORCE=true covers the class.
Disclosure Notes
Reported to MervinPraison/PraisonAIUI first as MervinPraison/PraisonAIUI#355 on 2026-11-11; Private Vulnerability Reporting is disabled on that repository, so that report carries no technical specifics per its SECURITY.md. This report carries the detail because the same application, and the same defect, ships from this repository. No public disclosure has been made.