Skip links

BSP Page Directive <%@page forceEncode="html"%> & <%html=%>, SAP security note 887168

Description

XSS attacks typically happen because of code that has roughly the following format:

<%@page language=”abap”%>
<html><body><form>
  <% data: x type string.
     x = request->get_form_field( ‘x’ ).
  %>
  <input type=text name=x value=”<%=x%>”>
  <input type=submit>
</form></body></html>

What we see here is that input is taken from the incoming HTTP request, not validated by the application, and then directly used in the rendered HTTP response. This allows a XSS attack whereby a HTTP request can be constructed that has also JavaScript inside some formfields, that are then rendered back to the user’s browser, and possibly executed there.

The simplest form of protection is to HTML encode all strings before rendering them.

One solution that is already supported, is that the developer can manually do an HTML encode on all strings.
  <% data: x type string.
     x = request->get_form_field( ‘x’ ).
     x = cl_http_utility=>html_encode( x ).
  %>
To make life easier for the developer, the BSP compiler has always also supported a build-in HTML encoding. This could be achieved by changing the print statement.

  <input type=text name=x value=”<%html=x%>”>

However, this writing form “<%html=…%>” must be used for each and every print statement and not be forgotten.

Note: while adding the feature described below, we observed and fixed a problem with the “<%html=…%>” sequence which would make it fail after the second and subsequent uses on a page. For this problem, Note Assisted corrections are supplied over all releases and service pack.s

Available fix and Supported packages

  • SAP_BASIS | 620 | 640
  • SAP_BASIS | 700 | 700
  • SAP_BASIS | 710 | 710
  • SAP_BASIS 640 | SAPKB64015 |
  • SAP_BASIS 620 | SAPKB62056 |
  • SAP_BASIS 700 | SAPKB70006 |
  • SAP_BASIS 620 | SAPKB62057 |

Affected component

    BC-BSP
    Business Server Pages

CVSS

Score: 0

Exploit

Exploit is not available.
For detailed information please contact the mail [email protected]

URL

https://launchpad.support.sap.com/#/notes/887168

TAGS

#