Summary
The WWBN AVideo Gallery plugin up to version 26.0 uses unsanitized $_REQUEST['sections'] data directly in PHP's eval() function within the saveSort.json.php endpoint.
Because the endpoint is protected only by an admin session and lacks CSRF validation, attackers can abuse cross-site request forgery to execute arbitrary PHP code when an authenticated admin visits a malicious page.
Affected context
This vulnerability occurs in WWBN AVideo installations using the Gallery plugin up to and including version 26.0.
The affected endpoint is saveSort.json.php, which is intended to process sort ordering data for gallery sections and is gated behind User::isAdmin() checks.
The issue manifests when the application:
- Accepts section data from
$_REQUEST['sections']on the admin side, - Uses
eval()to process that data without sanitization or validation, - And relies on a session cookie explicitly configured with
SameSite=Nonewhile not enforcing CSRF tokens for this endpoint.
Exploit preconditions
- Attack surface: HTTP POST/GET requests to the
saveSort.json.phpendpoint of the Gallery plugin. - Required access: The victim must be an authenticated admin in the same browser session; the attacker can be unauthenticated.
- Trigger point: An admin user visiting or interacting with an attacker-controlled webpage (or embedded content) that silently issues crafted requests to
saveSort.json.php. - Why exploitation is possible:
- The endpoint accepts request data from
$_REQUEST['sections']and passes it directly into PHP'seval(), enabling execution of attacker-controlled PHP code. - The only logical gate is
User::isAdmin(), which is satisfied automatically when the victim admin is logged in. - No CSRF tokens or origin checks are enforced, and the
SameSite=Nonecookie configuration allows cross-site requests to carry the admin's session cookie.
Why this happens
The core flaw is the use of dynamic code evaluation (eval()) on untrusted input derived from the $_REQUEST['sections'] array. This maps directly to CWE-94: Improper Control of Generation of Code ('Code Injection').
Rather than treating incoming data as simple values (e.g., IDs or sort positions), the implementation treats that data as executable PHP code and evaluates it at runtime.
In combination with missing CSRF protections and permissive session cookie settings, this design allows attackers to inject and run arbitrary code through cross-site requests, even though the endpoint is intended to be restricted to administrators.
Potential impact
- Remote execution of arbitrary PHP code in the web server context.
- Full compromise of the AVideo instance, including modification or deletion of video content and configuration.
- Theft or manipulation of user data stored by the platform.
- Installation of web shells or backdoors for persistent access.
- Use of the compromised server to pivot into internal networks or stage further attacks.
General mitigation guidance
Effective mitigation centers on eliminating dynamic code evaluation and tightening cross-site protections:
- Replace
eval()with explicit, data-driven logic that operates on validated values (e.g., numeric IDs, whitelisted field names) instead of interpreted PHP code. - Treat all request parameters, including those on admin endpoints, as untrusted; apply strict validation, encoding, and whitelisting for expected formats.
- Enforce robust CSRF defenses on all state-changing endpoints, such as synchronizer tokens or double-submit cookies, and validate them server-side.
- Avoid designs that depend on executing code constructed from user-controlled or semi-trusted configuration data; prefer declarative data structures.
- Apply least-privilege principles to the application runtime so that, if code execution occurs, underlying system impact is reduced.
- Review session and cookie policies (including
SameSite) to support CSRF defenses rather than weaken them.
How teams detect issues like this
Detection can focus on both code patterns and runtime behavior:
- Static analysis and code scanning:
- Flag uses of
eval(),create_function(),assert()with string arguments, or other dynamic code execution primitives, especially when arguments are derived from$_GET,$_POST,$_REQUEST, or other external sources. - Identify admin endpoints or JSON handlers that process arrays or complex data structures and confirm they do not translate directly into code.
- Enforce policy checks that require CSRF protection on all state-changing routes and fail builds when unsafe use of
eval()is detected. - Manual code review:
- Inspect admin-only scripts (e.g.,
saveSort.json.php) for assumptions about trustworthiness of request data. - Verify that cookie configuration, CSRF validation, and origin/referrer checks are consistent with security expectations.
- Runtime and log-based monitoring:
- Monitor for anomalous requests to
saveSort.json.phpwith unexpected payloads or from untrusted origins. - Use application-level logging to detect unusual execution flows or errors originating from dynamically evaluated code.
- Automated code review tools can be configured with custom rules to highlight any use of dynamic evaluation functions and missing CSRF protections on sensitive endpoints.

