From 257efe3f9aa00139beeff912d93a86598376d570 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 30 Aug 2023 12:11:33 -0400 Subject: [PATCH] [PM-3563] Prevent org name from injecting HTML into FD notes (#3219) * prevent org name from injecting HTML into FD notes * htmlencode --- src/Billing/Controllers/FreshdeskController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Billing/Controllers/FreshdeskController.cs b/src/Billing/Controllers/FreshdeskController.cs index c45407b53..1b6ddea42 100644 --- a/src/Billing/Controllers/FreshdeskController.cs +++ b/src/Billing/Controllers/FreshdeskController.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.Reflection; using System.Text; +using System.Web; using Bit.Billing.Models; using Bit.Core.Repositories; using Bit.Core.Settings; @@ -77,7 +78,9 @@ public class FreshdeskController : Controller foreach (var org in orgs) { - var orgNote = $"{org.Name} ({org.Seats.GetValueOrDefault()}): " + + // Prevent org names from injecting any additional HTML + var orgName = HttpUtility.HtmlEncode(org.Name); + var orgNote = $"{orgName} ({org.Seats.GetValueOrDefault()}): " + $"{_globalSettings.BaseServiceUri.Admin}/organizations/edit/{org.Id}"; note += $"
  • Org, {orgNote}
  • "; if (!customFields.Any(kvp => kvp.Key == _billingSettings.FreshDesk.OrgFieldName))