AI meta-generation AJAX endpoint lacks ACL check and HTTP error handling #99

Closed
opened 2026-06-29 14:19:19 +00:00 by jmiller · 2 comments
Owner

Problem

MokoOG::onAjaxMokoog() (plg_system_mokoog/src/Extension/MokoOG.php:848-941) gates on isClient('administrator') + Session::checkToken() + ai_enabled, but performs no authorise() capability check. Any authenticated back-end user — including low-privilege ones — can trigger outbound paid AI API calls and burn credits.

Secondary issues in callAiApi() (lines 901-941)

  • No HTTP status check$response->code is never inspected; a 4xx/5xx body is json_decode'd and trim(... ?? '') returns '', so auth/rate-limit/quota failures surface as a silent blank result with no diagnostic.
  • No timeout on HttpFactory::getHttp() — a hung provider blocks the admin request indefinitely.

Fix

  • Add $user->authorise('core.edit', 'com_content') (or a dedicated mokoog.ai action — see access.xml issue #95) before generating.
  • Check $response->code and surface a meaningful error / log non-200 responses.
  • Pass a timeout to the HTTP client.

Severity

Security / cost-control (credit abuse) + reliability.

## Problem `MokoOG::onAjaxMokoog()` (`plg_system_mokoog/src/Extension/MokoOG.php:848-941`) gates on `isClient('administrator')` + `Session::checkToken()` + `ai_enabled`, but performs **no `authorise()` capability check**. Any authenticated back-end user — including low-privilege ones — can trigger outbound **paid** AI API calls and burn credits. ### Secondary issues in `callAiApi()` (lines 901-941) - **No HTTP status check** — `$response->code` is never inspected; a 4xx/5xx body is `json_decode`'d and `trim(... ?? '')` returns `''`, so auth/rate-limit/quota failures surface as a silent blank result with no diagnostic. - **No timeout** on `HttpFactory::getHttp()` — a hung provider blocks the admin request indefinitely. ## Fix - Add `$user->authorise('core.edit', 'com_content')` (or a dedicated `mokoog.ai` action — see access.xml issue #95) before generating. - Check `$response->code` and surface a meaningful error / log non-200 responses. - Pass a timeout to the HTTP client. ## Severity Security / cost-control (credit abuse) + reliability.
jmiller added the securityproduction-readiness labels 2026-06-29 14:19:19 +00:00
Author
Owner

Branch created: feature/99-ai-meta-generation-ajax-endpoint-lacks-a

git fetch origin
git checkout feature/99-ai-meta-generation-ajax-endpoint-lacks-a
Branch created: [`feature/99-ai-meta-generation-ajax-endpoint-lacks-a`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteOpenGraph/src/branch/feature/99-ai-meta-generation-ajax-endpoint-lacks-a) ```bash git fetch origin git checkout feature/99-ai-meta-generation-ajax-endpoint-lacks-a ```
Author
Owner

Fixed in PR #109 (merged to dev). onAjaxMokoog now requires core.edit/core.create on com_content before generating; callAiApi enforces a 20s timeout and throws on non-200 HTTP status instead of returning a silent empty string. Closing.

Fixed in PR #109 (merged to `dev`). `onAjaxMokoog` now requires `core.edit`/`core.create` on `com_content` before generating; `callAiApi` enforces a 20s timeout and throws on non-200 HTTP status instead of returning a silent empty string. Closing.
Sign in to join this conversation.
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteOpenGraph#99