Escape XML

This article is based on the ServiceNow support article. See the original article on the ServiceNow support site: ServiceNow HI: Client Generated Scripts Sandbox

Cross-site scripting occurs when an attacker injects malicious JavaScript into an entry point and the platform/application fails to escape the malicious JavaScript before transmitting it to the victim's browser for execution. The glide.ui.escape_text property, when enabled, escapes the XML values at parser level before transmitting it to client's browser. 

Escaping here means the following:

&  --> &

<  --> &lt;

>  --> &gt;

"  --> &quot;

'  --> &#x27;

/  --> &#x2F;


Example: <script>alert('XSS Attack');</script>

Escaping: &lt;script&gt;alert(&#39;XSS Attack&#39;);&lt;/script&gt;

Escape XML
Property Nameglide.ui.escape_text
Configuration TypeSystem Properties (/sys_properties_list.do)
Purpose

Escaping ensures that browsers do not parse the malicious JavaScript embedded in untrusted data as JavaScript and execute it. A malicious user may try XSS attack to either hijack other users' session or redirect the user to a malicious website. ServiceNow has an implementation in place to secure cookies, but escaping it relies on this property to be set to true.

RequirementMandatory 
Recommended ValueTrue 
Default BehaviorSet to true  
Revertible behaviorN/A
Role requiredSecurity_admin
Release Version2011 June 
Functional Impact(Medium) This remediation would enforce XML encoding to occur on the UI at the XML parser level thus rendering back encoded results to the user. This can have a functionality impact based on the instance user interaction with the resulted data. 
Security Risk(High) Input validation has to occur on the application to defend against cross-site scripting attacks which would allow foreign scripts to execute on user session in the logged in browser's context. This can be leveraged by attackers to steal session information and sensitive data.
Workaround

After property set to true, Service Now stops rendering HTML tags written in description of catalog item or HTML tags in help text of catalog item variable. You may not be able to use HTML formatting for some fields.

However, some customers require glide.ui.escape_text property to be turned off. When this is the case, all JEXL expressions would be prefixed with an output encoder as shown below:

$⁠{JS:expression}

$⁠{HTML:expression}

or

$⁠{JS,HTML:expression}

ReferencesXMLUtilJS 

What's here


Related content

ServiceNow HI: Escape XML




Last modified on Jun 29, 2020