
ssrinivas930743 (Community Member) asked a question.
C# Framework 4.8 CMS appilcation : I can't use HTML encoding /Decoding
Flaw ID: 88 Severity:
Type: system_web_dll.System.Web.UI.IValidator.set_ErrorMessage Source: proxyvote.ascx.cs (line 630)
CWE ID: 80 Exploitability: V.Likely Category: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
vldOtherName.ErrorMessage = HtmlHelper.SanitizeCmsHtml(DynamicProperty.GetDynamicPropertyValue(this.ProxyNameMandatoryErrorMessage,DTO.DTOEnums.VotingType.Proxy_Vote,null,null));
628
vldMemberNo.ErrorMessage = HtmlHelper.SanitizeCmsHtml(DynamicProperty.GetDynamicPropertyValue(this.ProxyMembershipNoMandatoryErrorMessage, DTO.DTOEnums.VotingType.Proxy_Vote, null, null)) ;
629
vldProxyAddress.ErrorMessage = HtmlHelper.SanitizeCmsHtml(DynamicProperty.GetDynamicPropertyValue(this.ProxyAddressMandatoryErrorMessage, DTO.DTOEnums.VotingType.Proxy_Vote, null, null));
630
vldAdditionalDetails.ErrorMessage = HtmlHelper.SanitizeCmsHtml(DynamicProperty.GetDynamicPropertyValue(this.ProxyAdditionalInstructionMandatoryErrorMessage, DTO.DTOEnums.VotingType.Proxy_Vote, null, null));
631
.png)
Hi @ssrinivas930743 (Community Member) — what you're seeing is almost certainly not a bug in your code path but a limitation of how the static scanner recognizes cleansers. Short version: Veracode's dataflow engine only "sees" a cleanse when the tainted data passes through a function on its supported cleansing functions list. Your HtmlHelper.SanitizeCmsHtml(...) is a custom wrapper, so the scanner doesn't know it neutralizes the input — it follows the taint straight to IValidator.ErrorMessage and flags CWE-80.
You have three good options:
One thing worth double-checking on the code itself: IValidator.ErrorMessage is rendered as HTML by the ASP.NET validator control, so the right encoding is HTML encoding (not sanitizing to allowed HTML). If SanitizeCmsHtml permits a safe subset of tags (which is typical for CMS body content), that's actually a weaker defense for this sink than a straight HttpUtility.HtmlEncode / AntiXssEncoder.HtmlEncode would be — error messages shouldn't contain markup at all. Switching this particular sink to AntiXssEncoder.HtmlEncode(...) would both close the finding automatically (it's on the supported list) and be a more appropriate fix for an error-message sink.
TL;DR: option 1 or 2 will clear the V.Likely finding without a mitigation workflow — and for this specific sink, I'd lean toward option 1 with AntiXssEncoder.HtmlEncode since error messages don't need rich HTML.