Mastodon
m7mdharon

Reflected XSS and Server-Side Template Injection Found in HubSpot CMS

Nov 29th, 2025
465
10
Never
Not a member of gistpad yet? Sign Up, it unlocks many cool features!
None 8.98 KB | Cybersecurity | 1 0
  1. Title: Reflected XSS + Server-Side Template Injection in HubSpot CMS Affecting Thousands of Websites
  2. Author: Mohamed Haroun
  3. Discovery Date: January 2018
  4. Impact: More than 10,000 websites affected
  5.  
  6. ----------------------------------------------------------------------------------------------
  7.  
  8. Back in early 2018, while performing a routine security assessment, I discovered one of my favorite bugs ever. The vulnerability affected HubSpot CMS, a popular platform used by thousands of companies to host landing pages, marketing content, and call-to-action (CTA) widgets.
  9.  
  10. During my testing, I noticed the path:
  11. /_hcms/
  12.  
  13. This indicated that the page was being rendered by HubSpot’s backend services. After digging deeper, I focused on a specific endpoint:
  14.  
  15. /_hcms/cta
  16.  
  17. This endpoint included a parameter named:
  18.  
  19. referrerUrl
  20.  
  21. The parameter was not properly sanitized, which opened the door for two serious vulnerabilities:
  22.  
  23. 1. Server-Side Template Injection (SSTI) - Partly
  24. 2. Reflected Cross-Site Scripting (XSS)
  25.  
  26. ---
  27.  
  28. Server-Side Template Injection (SSTI)
  29.  
  30. Server-Side Template Injection happens when user-controlled input is placed inside a server-side template without proper sanitization. If interpreted as executable code, an attacker may run their own logic on the server.
  31.  
  32. To test this, I simply passed:
  33.  
  34. ?referrerUrl={{7*7}}
  35.  
  36. The server responded with:
  37.  
  38. 49
  39.  
  40. This confirmed that the input was being evaluated. I tried pushing the limits using template loops like:
  41.  
  42. %for c in [1,2,3]%{{c,c,c}}% endfor %
  43.  
  44. However, the server blocked some payloads and returned errors such as:
  45.  
  46. Malformed escape pair at index...
  47. Illegal character in query at index...
  48.  
  49. Even though full template execution was restricted, the evaluation behavior confirmed the presence of template parsing — a strong indicator of SSTI.
  50.  
  51. ---
  52.  
  53. Reflected XSS via Template Injection
  54.  
  55. With help from Frans Rosén, I was able to break out of the template and achieve XSS.
  56.  
  57. Working payload:
  58.  
  59. {%25+macro+field(x)+%25}[http://www.com](http://www.com) {{x}} <b>ok</b>{%25+endmacro+%25}{{ field(1)|urlize }}
  60.  
  61. Example:
  62.  
  63.  
  64. This proved that:
  65.  
  66. * The template executed macros
  67. * User input controlled the output
  68.  
  69. From there, generating JavaScript execution was possible.
  70.  
  71. ---
  72.  
  73. Final XSS Payload
  74.  
  75. {%25+macro+field()+%25}moc.okok//:ptth//)niamod.tnemucod(trela:tpircsavaj=daolno+gvshttp://http:""//{%25+endmacro+%25}{{+field(1)%7curlize%7creverse%7curlize%7creverse%7curlize%7creverse+}}
  76.  
  77. This payload achieved full reflected XSS on HubSpot-powered websites.
  78.  
  79. ---
  80.  
  81. Affected Websites
  82.  
  83. Some confirmed affected websites:
  84.  
  85. blog.bugcrowd.com
  86. cashflows.com
  87. pages.bugcrowd.com
  88.  
  89. However, based on HubSpot’s customer base, the total exposure exceeded 10,000+ websites.
  90.  
  91. ---
  92.  
  93. Timeline
  94.  
  95. 22 January 2018 — Report submitted
  96. 22 January 2018 — HubSpot Security set priority to P2
  97. 23 January 2018 — Issue resolved
  98. Reward: 20 points
  99.  
  100. HubSpot’s security team responded quickly and professionally.
  101.  
  102. ---
  103.  
  104. Why This Bug Was Special
  105.  
  106. This bug was one of my favorites for many reasons:
  107.  
  108. * It started with a small overlooked parameter in a CMS path
  109. * It escalated from SSTI partly to full XSS
  110. * It impacted massive infrastructure at scale
  111. * It reinforced the importance of sanitizing template inputs
RAW Gist Data Copied