Skip links
Vahagn Vardanian

Vahagn Vardanian

Co-founder and CTO of RedRays

BSP Page Directive & , 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

PoC

Detailed vulnerability information added to RedRays Security Platform. Contact [email protected] for details.

URL

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

TAGS

#

More to explorer

Special offer for SAP Security Udemy course!

$ 9.99

Join “SAP Security Core Concepts and Security Administration” which is part of the Blackhat course series.