Guestbook AJAX rendering allows stored XSS in administrator sessions
Description
Guestbook stores fields submitted by visitors and later inserts those values into HTML strings in its AJAX pagination and Admin moderation views. The strings are appended to the DOM as HTML, so markup in a stored message is interpreted by the browser.
Affected versions
The public AJAX rendering path affects Guestbook versions through 0.5.1. The Admin moderation path, which raises the impact to administrator-session execution, affects 0.5.0 and 0.5.1.
Details
The documented Guestbook form saves visitor-controlled author and message values to messages.yaml. Pagination responses return the stored records as JSON. The public Load more handler and the Admin Load all handler concatenate record fields into HTML strings and pass them to jQuery DOM insertion methods. The initial server-rendered rows use Twig escaping, but that protection does not apply to the AJAX paths. The Admin view automatically requests and inserts all records when opened.
Impact
An unauthenticated visitor can store markup that executes when another visitor loads a later page of entries. On sites using moderation, the same stored value is automatically rendered in the authenticated Admin moderation page, crossing from anonymous input into an administrator's session.
Patches
Upgrade to Guestbook 0.5.2 when it is released. The fix inserts visitor fields as text, rather than parsed HTML, in both AJAX views.
Credits
Reported by @AlpetGexha.