Sanitize output

REST API output sanitization removes or encodes data returned by requests, thus reducing security risks. Output sanitization is enabled by default. You can disable it or configure the feature using site parameters.

You can configure HTML sanitization for the values of fields of various entities in the ALM project customization interface. You can select:

  • Do nothing - return the value as it is stored in the database.
  • Text encoding - values are HTML encoded. Used especially with text fields.
  • HTML sanitization - value is sanitized according to a predefined whitelist for allowed HTML content in the following manner:

Data to be sanitized must be inside the <html> and <body> tags of a valid HTML document. Otherwise, a tag might be sanitized even though it is allowed by the whitelist.

If data cannot be stored as a valid HTML document, you can prevent unwanted sanitizing by configuring the specific field for no sanitation. Consider the security implications before doing this.

HTML sanitization

There is a default HTML sanitization whitelist. You can override the defaults by configuring HTML sanitization at the level of protocols, tags, and attributes using a custom HTML sanitizer whitelist. See Output sanitization whitelist.

The tags and attributes specified in the whitelist are returned without change.

Tags that are not in the whitelist are HTML encoded. For example, if tag <abc> is in the field value, but tag abc is not in the whitelist, the returned value is &lt;abc&gt;.

Attributes not in the whitelist are removed, even if they are attributes of a tag that is in the whitelist. For example:
The field value contains <img src="http://mypage.com/1.jpg" onClick="alert('a');" />. The img tag and the src attribute of img are in the whitelist, but the onClick attribute is not. onClick is stripped and the return value is <img src="http://mypage.com/1.jpg" />.

Attributes that reference a protocol that is not in the whitelist are removed, even if the attributes and tag are in the whitelist. For example:
The field value contains <img src="ftp://mypage.com/1.jpg" />. The img tag and the src attribute of img are in the whitelist, but the ftp protocol is not. src is stripped and the return value is <img />.

The default whitelist allows <img src=””…/> http / https protocols. For more strict sanitization, provide a custom whitelist.

Output sanitization whitelist

To specify which tags, attributes, and protocols are returned as-is when using HTML sanitization, create a custom whitelist file named sanitizer-whitelist.xml. Place the file in directory: %ALM_INSTALL_DIR%/Micro Focus/ALM/webapps/qcbin/WEB-INF/classes/. On Windows platforms the default path is C:\ProgramData\Micro Focus\ALM\webapps\qcbin\WEB-INF\classes\. On Linux platforms the default path is /var/opt/Micro Focus/ALM/webapps/qcbin/WEB-INF/classes/. The whitelist takes effect when the ALM service is restarted.

In a cluster environment, put the whitelist on each node.

The whitelist contains three collections.

  • The tags collection contains the tags that are returned unchanged. The contents of the element for a tag may change if there are attributes or protocols that are not themselves whitelisted.
  • The attributes collection contains lists of the attributes allowed for each specified tag.
  • The protocols collection contains lists of the protocols allowed for each specified tag-attribute pair.