GHSA-65p8-9433-jpcp YesWiki: Authenticated (Admin) Server-Side Template Injection to Remote Code Execution via Bazar Semantic Templates
SummaryYesWiki Bazar contains a stored Server-Side Template Injection (`SSTI`) vulnerability in the semantic template feature that can be escalated to confirmed Remote Code Execution (`RCE`). An authenticated administrator can place arbitrary Twig expressions into the `Semantic template (Twig)` field (`bn_sem_template`), and that content is later executed server-side when public semantic endpoints are requested.This was first confirmed through a harmless proof payload where `{{ 7 * 7 }}` was rendered as `49` through the public JSON-LD endpoint. The finding was then further validated locally by storing a Twig payload that invoked a system-level callable, resulting in command execution and an interactive shell on the test machine.Because the payload is stored in the form configuration and later triggered through a public endpoint, this issue is both persistent and remotely triggerable after an administrator plants the malicious template.DetailsThe vulnerable behavior is in the Bazar semantic rendering flow.The administrator-editable fields:`bn_sem_template``bn_sem_reverse_template`allow Twig template content to be stored inside a form definition. That content is later rendered by the backend semantic transformer through `TemplateEngine::renderFromStringNoEscape()`, which passes the user-controlled string into Twig for execution.Relevant sink:The rendering helper evaluates the supplied string as a live Twig template:This is unsafe because administrator-controlled semantic template text is executed as server-side Twig code rather than treated as inert data. In the validated environment, Twig expressions were first confirmed to execute through a harmless arithmetic payload and were then escalated to operating-system-level command execution by invoking a callable through Twig.The public trigger path used during validation was:The attack chain is:An administrator stores malicious Twig code in the semantic template field.YesWiki saves that payload in the form configuration.A later request to the public semantic endpoint causes the backend to render and execute the stored Twig.Because the Twig environment is not adequately constrained, the stored payload can escalate from template execution to system command execution.PoCThe following steps reproduce the issue on the locally validated YesWiki instance.Stage 1: Confirm Server-Side Template ExecutionLog in to YesWiki as an administrator.Open Bazar form management.Edit form ID `2` (`Agenda` in the validated instance).Locate the field labeled `Semantic template (Twig)`.Replace its content with the following harmless payload:Save the form.Trigger the public semantic endpoint:Observe that the server returns evaluated Twig output instead of the literal string `{{ 7 * 7 }}`.Confirmed response:Key execution proof:Stage 2: Confirm Remote Code ExecutionAfter confirming SSTI with the harmless payload above, a second locally controlled payload was stored in the same semantic template field to test whether Twig execution could be escalated to command execution. When the public semantic endpoint was requested, the payload executed on the server and established an interactive shell back to the test listener.Observed local evidence included:an inbound connection to the attacker's listeneran interactive shell prompt on the YesWiki hostsuccessful command execution from the shell inside the YesWiki project directoryObserved shell output:This confirms that the issue is not limited to template evaluation or data disclosure. In the validated local environment, the stored Twig payload reached full operating-system-level command execution.ImpactAn authenticated administrator can inject arbitrary Twig expressions into Bazar semantic templates, and those expressions are executed server-side when public semantic endpoints are requested.In the validated environment, this leads to confirmed Remote Code Execution. An attacker with administrator access can:execute arbitrary Twig expressions on the serverstore a persistent payload in form configurationhave that payload triggered later by unauthenticated requests to public semantic endpointsexecute operating-system commands on the hostgain interactive shell access to the underlying serverpivot from application-level administration to full server compromiseThis breaks the expected trust boundary between application administration and host-level execution. In practical terms, YesWiki administrator privileges become sufficient to obtain command execution on the server in affected deployments.
CVSS v4.0 score: 7.1