Secure Configuration

Prior to deploying SAP Commerce Cloud in production, ensure that the configuration is secure. Here you can find some tips on how to do so.

Review Installed Extensions

Review and disable unnecessary and risky extensions. Verify all loaded web modules and remove any that you do not need. Adjust extensioninfo.xml to remove the web module entry for extensions that do not require a web extension.

Tenant Settings

Make sure that the junit tenant is disabled in the production environment.

Secure Backoffice Extensions

Secure Backoffice extensions to remove them from internet access. Limit access to Backoffice applications only to the appropriate groups of users inside your organization. Deploy Backoffice applications within a secured network, and protect them from unauthorized access.

Application Server User

The SAP Commerce Cloud application server should not run as a root user. Check the <RUN_AS_USER> variable in hybris/bin/platform/tomcat/bin/wrapper.sh.

Database User Settings

Restrict the permissions of database users associated with the storefront. A proper configuration of SAP Commerce Cloud is defined as follows:

  • The front-end database user only has SELECT, INSERT, UPDATE, and DELETE rights.
  • The back-end database user additionally has CREATE, ALTER TABLE, and other rights required for application deployments, updates, or other operations.

Database connection details and JNDI

When using local.properties for database connection configuration, the database password and other information is stored in plain text. This is insecure. Instead, use JNDI for database configuration.

Do the following to use a JNDI data source:

  1. Define the data source for your application server. Check the instructions specified by the manufacturer of the application server.
  2. Configure SAP Commerce Cloud to use the JNDI data source
  3. Configure the name of the JNDI data source using the config property in local.properties.
    db.pool.fromJNDI=<JNDI datasource name>
  4. Call ant deploy and start the application server.

Parameters used during JNDI configuration are XMLENCODED, therefore you should encode all characters which are not allowed in XML but which are part of the configuration (passwords and URLs often contain characters which need to be escaped in XML).

Example: If a password contains an ampersand, encode it as &amp; to avoid an XML parse exception.

Sample SSL Certificates for Developer Environments

Sample SSL certificates are provided for developer environments and allow you to use localhost only. Those certificates should be disabled in production environments. You can disable them by setting empty values to the following properties in your local.properties file:

additional.javax.net.ssl.trustStore=
additional.javax.net.ssl.trustStorePassword=

For more information, see HTTPS Traffic Certificate.

FlexibleSearch

Flexible search enables searching by types and items using an SQL-based syntax. The execution of a flexible search statement takes place in two phases: pre-parsing into an SQL-compliant statement and running that statement on the database. During the pre-parsing phase, the flexible search framework resolves the search syntax into SQL-compliant syntax.

When using flexible search, never build a query by concatenating the query code and the data. To pass parameters, create a Map instance holding the parameters and pass the Map to the search( ... ) method, as follows:

final Map<String, Object> params = new HashMap<String, Object>();
  
String query =
"SELECT {" + PriceRowModel.PK + "} FROM {" + PriceRowModel._TYPECODE "} "+
"WHERE {" + PriceRowModel.PRODUCT      + "} = ?product AND "+
      "{" + PriceRowModel.NET          + "} = ?net AND "+
      "{" + PriceRowModel.CURRENCY     + "} = ?currency AND "+
      "{" + PriceRowModel.UNIT         + "} = ?unit AND "+
      "{" + PriceRowModel.UNIT_FACTOR  + "} = ?unitfactor AND "+
      "{" + PriceRowModel.UG           + "} = ?userpricegroup AND "+
      "{" + PriceRowModel.MIN_QUANTITY + "} = ?minquantity AND "+
      "{" + PriceRowModel.PRICE        + "} = ?price ";
  
params.put("product",             product);
params.put("net",                 priceCopy.isNet());
params.put("currency",            priceCopy.getCurrency());
params.put("unit",                priceCopy.getUnit());
params.put("unitfactor",          priceCopy.getUnitFactor());
params.put("userpricegroup",      priceCopy.getUserPriceGroup());
params.put("minquantity",         priceCopy.getMinQuantity());
params.put("price",               priceCopy.getPriceValue());
  
final SearchResult<PriceRowModel> searchResult = flexibleSearchService.search(query, params);
For more information, see FlexibleSearch.

Transparent Attribute Encryption (TAE)

TAE provides the option to encrypt sensitive data before persisting in the database with AES encryption. It's done by declaring a String-Attribute as encrypted by adding the modifier encrypted="true" in the items.xml of your extension.

<itemtype generate="true" code="MyProduct" jaloclass="org.training.jalo.MyProduct"
            extends="Product" autocreate="true">
    <attributes>
        <attribute qualifier="myEncryptedField" type="java.lang.String" >
        <modifiers read="true" write="true" optional="true" encrypted="true"/>
            <persistence type="property" />
        </attribute>
    </attributes>
</itemtype>

This attribute is automatically encrypted before persisting in the database and decrypted after loading. The corresponding database field looks like:

1:LFGjqOi4quc=K8p+AIJJBoIQTPBh7yaSojr97rHES7YaTkYO6SqBA/M=

The number before the colon ( : ) refers to the number of keys used in the encryption process, so that it can be used to decrypt the data. Since AES is a symmetric encryption the same key is used to both encrypt and decrypt messages. Encrypted data is safe as long as the secret-key is protected and uncompromised. You can find an AES key generator for 128 bits, 192 bits and 256 bits, key in the SAP Commerce Cloud Administration Console. More information on how to generate, change, and migrate Encryption Keys can be found in Transparent Attribute Encryption (TAE).

Configuration

By default, the SAP Commerce Cloud Platform ships with a 128-bit key, which can be found in: PLATFORMHOME/core/resources/security

The default symmetric key should be replaced with a new one using a generator provided by SAP Commerce Cloud.

The key's configuration is stored in the project.properties file and should be overwritten in the local.properties file.

  • symmetric.key.file.<KEY_NUMBER> is the property that points to the key file. All keys should be in the config/security folder.
  • symmetric.key.file.default property defines the currently used key.
  • symmetric.key.master.password is the password used to protect the key files.

Sample configuration:

symmetric.key.file.1=Generated-128-Bit-AES-Key.hybris
symmetric.key.file.2=Generated-192-Bit-AES-Key.hybris
symmetric.key.file.default=2
symmetric.key.master.password=ShItN7yqJYMvNfOODmS26DcwB5OXnOa3etCzqxRjFMZ811UUYc

It is recommended to create a longer password and use bigger key sizes, such as 256-bit. For this, unlimited jurisdiction policy files have to be downloaded from the Oracle site and installed in JAVA_HOME/lib/security.

Key Rotation

The keys should be changed at least once a year and then the existing values can be migrated to the new key. We suggest migrating all existing values. If not migrated, they are translated to the new key on the first reference. However, if a key has to be completely removed, then migration is necessary. At the beginning, all sensitive data is encrypted with the key that is specified by the setting symmetric.key.file.default (key id = 1).

project.properties/local.properties

# all keys have to be stored under: ${platform_config_dir}/security/
symmetric.key.file.1=before_migration_key.hybris
symmetric.key.file.default=1
symmetric.key.master.password=ShItN7yqJYMvNfOODmS26DcwB5OXnOa3etCzqxRjFMZ811UUYc

To make this encryption key unique for a specific SAP Commerce Cloud installation this one is protected by the symmetric.key.master.password.

During key rotation a new key is added and set as the default as shown in the sample configuration below.

project.properties/local.properties

We specify a new encryption key (id=2) and by setting symmetric.key.file.default=2 this key is used for all new encryption operations.

Encrypted attributes is only re-encrypted with the new key if the corresponding instance is loaded and restored. To encrypt all encrypted attributes with the new key, use the SAP Commerce Cloud Administration Console. See also the Encryption Keys Migration section below.

Encryption Keys Migration

Encryption key migration importance and frequency depend on your security policy. It may also become necessary as an emergency measure in the case where existing keys have become unsecure or were compromised.

  1. Open the SAP Commerce Cloud Administration Console.
  2. Go to the Maintenance tab and select the Encryption Keys option.
  3. The Encryption Keys page in the Generator tab displays. If you did not configure your migration key in project.properties or local.properties file, then instructions on how to do it would display. Otherwise you can see the fields below:
    • Encryption Keys: List of the configured encryption keys
    • Encrypted Attributes: All types with their encrypted attributes are listed. You see the total count of encrypted instance (#15) and how often every key is used (id=1, #15). Every selected row is encrypted with the new default key after clicking the Migrate button.

Figure: Encryption Keys page in the Migration tab.

Tips and Pitfalls

  • dontOptimize=true

    Because you are not able to search for encrypted values, it could be a good idea to add the modifier "dontOptimize=true" in your items.xml for the encrypted attribute.

  • DB Persistence Type

    Encrypting a string value increases its length, so be sure that you have chosen the right persistence type (VARCHAR, CLOB, TEXT) for storing your encrypted values.

  • java.security.InvalidKeyException: Illegal key size

    The Java Runtime Environment (JRE) must support the level of encryption required by the key length that you select. For example, you cannot use a 256-bit encryption key with a JRE that supports only 128-bit encryption. By default, the Platform is configured with restricted or limited strength ciphers. To use less restricted encryption algorithms, you must download and apply the unlimited jurisdiction policy files (local_policy.jar and US_export_policy.jar).

    Download for Java8: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.htmlInformation published on non-SAP site

  • Cluster Configuration

    To guarantee the integrity of your data, be sure that every node is using the same encryption key. A default key is included in <HYBRIS_BIN_DIR>/platform/ext/core/resources/security/default-128-bit-aes-key.hybris. Replace this keyfile with your own. Place your keyfile in <HYBRIS_CONFIG_DIR>/security/.

Output Encoding

Software vulnerabilities frequently stem from issues around data and instructions mix-ups. When data turns into processing instructions in a not properly controlled fashion, attackers get a chance to control the system via injected instructions, or manipulate data in a system by fooling data processing through the injections of processing instructions.

Secure input and output handling is a process where:

  • Input is validated
  • Data is sanitized
  • Output is encoded

Encoding prevents XSS in most cases, however there are contexts/situations where encoding is not sufficient.

  • Encoding means: Using replacement characters (i.e. a different representation) for characters that have a special meaning within the current syntax.
  • Sometimes the term escaping is used in this context. Escaping means: adding an escape character before a character to indicate to a parser that the character behind the escape character has no special meaning.

XSS Prevention Rules

The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts.

Data Type Context Code Sample Defense
String HTML Body <span>UNTRUSTED DATA</span>
String Safe HTML Attributes <input type="text" name="fname" value="UNTRUSTED DATA">
  • Aggressive HTML Entity EncodingInformation published on non-SAP site
  • Only place untrusted data into an allowlist of safe attributes (listed below).
  • Strictly validate unsafe attributes such as background, id, and name.
String GET Parameter <a href="/site/search?value=UNTRUSTED DATA">clickme</a>
String Untrusted URL in an SRC or HREF attribute <a href="UNTRUSTED URL">clickme</a> <iframe src="UNTRUSTED URL" />
String CSS Value <div style="width: UNTRUSTED DATA;">Selection</div>
String JavaScript Variable
<script>var currentValue='UNTRUSTED DATA';</script>
<script>someFunction('UNTRUSTED DATA');</script>
  • Ensure JavaScript variables are quoted
  • JavaScript Hex Encoding
  • JavaScript Unicode Encoding
  • Avoid backslash encoding (\" or \' or \\)
HTML HTML Body <div>UNTRUSTED HTML</div>
String DOM XSS <script>document.write("UNTRUSTED INPUT: " + document.location.hash);<script/>

Safe HTML Attributes include: align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width

Encoding Libraries

XSS Encoder

The security.core.server.csi-1.00.8.jar library encodes different kinds of content and helps prevent XSS attacks from malicious data being stored inside the Platform database. The library was added to the hybris ext/core/lib folder. The following methods are available to prevent XSS.

Context

Method

CSS

out = XSSEncoder.encodeCSS( val )

HTML/XML

out = XSSEncoder.encodeHTML( in ) and XSSEncoder.encodeXML( val )

JavaScript

out = XSSEncoder.encodeJavaScript( val )

URL

out = XSSEncoder.encodeURL( val )

  • Some rules apply for usage of XSSEncoder to prevent ClassCastExceptions due to duplication of XSS lib classes in the applications and frameworks.
  • Use com.sap.security.core.server.csi.XSSEncoder methods only as static methods of the class.
  • Avoid creating local variables of XSSEncoder class. Do not use at all new XSSEncoder () – creation constructors for this class.
  • Do not use XSSEncoder.class passed as a parameter of method or return value of a method.
  • Do not try to serialize XSSEncoder.class

For performance reasons, the encoding methods are available in different variants.

  1. encodeXXX, for example, encodeHTML(java.lang.CharSequence), which encodes only if necessary and only then an internal new CharacterSequence is created. In the other case, the original reference is returned. You should always use toString() to the returned object to ensure that you get a String class object
  2. writeEncodedXXX, for example, writeEncodedHTML(java.io.Writer, java.lang.CharSequence), so that in cases where you write to a stream you can pass this Writer to the encoded method. This is useful in cases where you work in a web-container, for example, in a Servlet where you have a PrintWriter. Here no extra copy is done and no extra memory is needed. If you have an own StringBuilder (or other Appendable) object, then you can use a StringWriter or CharArrayWriter to for this writeEncodedXXX method to append copy-free encoded values to your buffered object.

OWASP Java Encoder

The OWASP Java EncoderInformation published on non-SAP site is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage.

The general API pattern is to utilize the Java Encoder Project in your user interface code and wrap all variables added dynamically to HTML with a proper encoding function. The encoding pattern is "Encode.forContextName(untrustedData)", where "ContextName" is the name of the target context and "untrustedData" is untrusted output.

Links:

Input Validation

XSS Filter

XSS Filter is a generic cross-site scripting protection filter for the SAP Commerce Cloud Platform.

The filter is part of the platform global classpath. Therefore there is no need to add any library to your platform web application.

Configuring XSS Filter

XSS is configured by specific properties included in platform/project.properties.

########################### WEB-SECURITY SETTINGS ######################################                                                                                                                    
#                                                                                                                                                                                                           
# Here web related security settings can be found.                                                                                                                                                          
#                                                                                                                                                                                                           
########################################################################################                                                                                                                    
# enable globally                                                                                                                                                                                           
xss.filter.enabled=true
  
# define action on violation matching globally                                                                                                                                                              
# STRIP .. strips all text occurrences which match the patterns below but allow                                                                                                                             
#          processing the request (default)                                                                                                                                                                 
# REJECT.. if any pattern matches the whole request gets rejected with the  BAD REQUEST                                                                                                                     
#          error code                                                                                                                                                                                       
xss.filter.action=STRIP
  
# our default rules                                                                                                                                                                                         
xss.filter.rule.script_fragments=(?i)<script>(.*?)</script>
xss.filter.rule.src=(?ims)[\\s\r\n]+src[\\s\r\n]*=[\\s\r\n]*'(.*?)'
xss.filter.rule.lonely_script_tags=(?i)</script>
xss.filter.rule.lonely_script_tags2=(?ims)<script(.*?)>
xss.filter.rule.eval=(?ims)eval\\((.*?)\\)
xss.filter.rule.expression=(?ims)expression\\((.*?)\\)
xss.filter.rule.javascript=(?i)javascript:
xss.filter.rule.vbscript=(?i)vbscript:
xss.filter.rule.onload=(?ims)onload(.*?)=

The filter can be disabled / enabled globally with xss.filter.enabled parameter. By default, the filter is enabled and SAP recommends that it remains enabled.

xss.filter.enabled=true

The filter can be disabled if there is an application firewall in front of the SAP Commerce Cloud instance or if there is another solution dealing with malicious input.

The filter can be disabled/enabled per extension by adding the extension name as a prefix to the parameter:

hac.xss.filter.enabled=false

Actions on Match

The default reaction on matching any rule is that each occurrence of these text fragments are stripped and the request proceeds.

xss.filter.action=STRIP

There is also possibility to change that setting to reject the request with the error code BAD REQUEST:

xss.filter.action=REJECT

Action can be set also for a specific extension by adding extension name as a prefix to the parameter:

hac.xss.filter.action=REJECT

Rules

Rules are globally defined as properties. A rule property must start with xss.filter.rule in its name, followed by a specific rule id, which is used for information purposes only.

xss.filter.rule.script_fragments=(?i)<script>(.*?)</script>
xss.filter.rule.src=(?ims)[\\s\r\n]+src[\\s\r\n]*=[\\s\r\n]*'(.*?)'
xss.filter.rule.lonely_script_tags=(?i)</script>
xss.filter.rule.lonely_script_tags2=(?ims)<script(.*?)>
xss.filter.rule.eval=(?ims)eval\\((.*?)\\)
xss.filter.rule.expression=(?ims)expression\\((.*?)\\)
xss.filter.rule.javascript=(?i)javascript:
xss.filter.rule.vbscript=(?i)vbscript:
xss.filter.rule.onload=(?ims)onload(.*?)= 

Rules can be overridden per extension. Make sure to match the exact rule id and add the extension name as a prefix to the parameter:

hac.xss.filter.rule.vbscript=

Configuration in web.xml

To enable the filter, change web.xml files for each web application. Make sure that the filter:

  1. Matches all requests
  2. Comes first in the overall filter chain
<filter>
   <filter-name>XSSFilter</filter-name>
   <filter-class>de.hybris.platform.servicelayer.web.XSSFilter</filter-class>
</filter>
  
<filter-mapping>
   <filter-name>XSSFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

Servlet 3.0

In Servlet 3.0 containers (from Tomcat 7), there may be servlets making use of asynchronous processing. In this case, configure the filter to support it by adding <async-supported>true</async-supported>:
 <filter>
   <filter-name>XSSFilter</filter-name>
   <filter-class>de.hybris.platform.servicelayer.web.XSSFilter</filter-class>
   <async-supported>true</async-supported>
</filter>

OWASP Java HTML Sanitizer

The OWASP Java HTML Sanitizer is a fast and easy way to configure HTML Sanitizer written in Java, which lets you include HTML authored by third-parties in your web application while protecting against XSS.

The existing dependencies are on guava and JSR 305. The other jars are only needed by the test suite. The JSR 305 dependency is a compile-only dependency, only needed for annotations.

In this sanitizer, you can use prepackaged policies or define your own and then use them for sanitization.

The example below shows usage of the FORMATTING policy and sanitization of untrustedHTML. You can use prepackaged policies from Sanitizers.javaInformation published on non-SAP site

PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String safeHTML = policy.sanitize(untrustedHTML);

or configure your own policy as shown in HtmlPolicyBuilderTest.javaInformation published on non-SAP site

PolicyFactory policy = new HtmlPolicyBuilder()
   .allowElements("a")
   .allowUrlProtocols("https")
   .allowAttributes("href").onElements("a")
   .requireRelNofollowOnLinks()
   .build();
String safeHTML = policy.sanitize(untrustedHTML);

or you can write custom policies to do things like changing h1s to divs with a certain class

PolicyFactory policy = new HtmlPolicyBuilder()
   .allowElements("p")
   .allowElements(
       new ElementPolicy() {
         public String apply(String elementName, List<String> attrs) {
           attrs.add("class");
           attrs.add("header-" + elementName);
           return "div";
         }
       }, "h1", "h2", "h3", "h4", "h5", "h6"))
   .build();
String safeHTML = policy.sanitize(untrustedHTML);

More examples can be found hereInformation published on non-SAP site.

jsoup

jsoup is a Java library for working with HTML. It provides an API for extracting and manipulating data, using jquery-like methods.

jsoup implements the WHATWG HTML5Information published on non-SAP site specification and parses HTML to the same DOM as modern browsers do.
  • scrape and parseInformation published on non-SAP site HTML from a URL, file, or string
  • findInformation published on non-SAP site and extract data, using DOM traversal or CSS selectors
  • manipulateInformation published on non-SAP site the HTML elements, attributes, and text
  • cleanInformation published on non-SAP site user-submitted content against a safe allowlist, to prevent XSS attacks
  • outputInformation published on non-SAP site tidy HTML

In order to sanitize HTML, use the jsoup HTML CleanerInformation published on non-SAP site with a configuration specified by a WhitelistInformation published on non-SAP site.

String unsafe =
  "<p><a href='http://example.com/' onclick='stealCookies()'>Link</a></p>";
String safe = Jsoup.clean(unsafe, Whitelist.basic());
// now: <p><a href="http://example.com/" rel="nofollow">Link</a></p>

OWASP JSON Sanitizer

The sanitizer takes JSON like content and interprets it as JS eval would. Specifically, it deals with these non-standard constructs.

'...'        Single quoted strings are converted to JSON strings.
\xAB         Hex escapes are converted to JSON unicode escapes.
\012         Octal escapes are converted to JSON unicode escapes.
0xAB         Hex integer literals are converted to JSON decimal numbers.
012          Octal integer literals are converted to JSON decimal numbers.
+.5          Decimal numbers are coerced to JSON's stricter format.
[0,,2]       Elisions in arrays are filled with null.
[1,2,3,]     Trailing commas are removed.
{foo:"bar"}  Unquoted property names are quoted.
//comments   JS style line and block comments are removed.
(...)        Grouping parentheses are removed.

The sanitizer fixes missing punctuation, end quotes, and mismatched or missing close brackets. If an input contains only white-space, then the valid JSON string null is substituted.

The output is well-formed JSON as defined by RFC 4627Information published on non-SAP site. The output satisfies additional properties:
  1. The output does not contain the substring (case-insensitively) "</script" so it can be embedded inside an HTML script element without further encoding.
  2. The output does not contain the substring "]]>" so it can be embedded inside an XML CDATA section without further encoding.
  3. The output is a valid Javascript expression, so it can be parsed by Javascript's eval builtin (after being wrapped in parentheses) or by JSON.parse. Specifically, the output does not contain any string literals with embedded JS newlines (U+2028 Paragraph separator or U+2029 Line separator).
  4. The output contains only valid Unicode scalar valuesInformation published on non-SAP site (no isolated UTF-16 surrogatesInformation published on non-SAP site) that are allowed in XML unescapedInformation published on non-SAP site.
This can be attached at either end of a data-pipeline.

Applied to JSON-like content from others, it produces well-formed JSON that should satisfy any parser you use.

Applied to your output before you send, it coerces minor mistakes in encoding and make it easier to embed your JSON in HTML and XML.

Once you've got the JSON sanitizer JAR on your classpath,

import com.google.json.JsonSanitizer;

you can use it like

String wellFormedJson = JsonSanitizer.sanitize(myJsonLikeString);

Now wellFormedJson is a string of well-formed JSON that is safe to pass to JavaScript?'s eval operator and which can be easily embedded in XML or HTML.

CSRF Protection

SAP Commerce Cloud provides a CSRF protection mechanism, that is enabled by default.

This solution is based on Spring CSRF protection introduced in Spring 3.1.

To confirm that CSRF protection is enabled, check that:

  • CSRFHandlerInterceptor bean is activated (in spring-mvc-config.xml, in the <mvc:interceptors> tag

    <!-- CSRF Handler Interceptor -->
    <bean name="csrfHandlerInterceptor" class="de.hybris.platform.yacceleratorstorefront.util.CSRFHandlerInterceptor">
        <property name="csrfAllowedUrlPatterns" ref="csrfAllowedUrlPatternsList"/>
    </bean>
    <mvc:interceptors>
        ...
        <ref bean="csrfHandlerInterceptor" />...
  • CSRFRequestDataValueProcessor alias to requestDataValueProcessor is not commented

    <bean name="crfRequestDataValueProcessor" class="de.hybris.platform.yacceleratorstorefront.util.CSRFRequestDataValueProcessor"/>

More information about CSRF and CSRF mitigation can be found at:

Clickjacking Protection

SAP Commerce Cloud provides a Clickjacking protection mechanism, which is based on the XSS filter. This general feature injects X-Frame-Options header to all requests of web application that are using the XSS filter. The possible header values are:

  • DENY - blocks any site (regardless of the domain) from framing the content.
  • SAMEORIGIN - blocks all sites from framing the content, except sites within the same domain.

The header value can be configured in platform/project.properties.

# ----------------------------------------------------------------
# inject static http response headers 
# (again this can be done globally or per extension )
# ----------------------------------------------------------------
#
# setting 'X-Frame-Options=SAMEORIGIN' to prevent clickjacking attacks
xss.filter.header.X-Frame-Options=SAMEORIGIN

Same as for XSS filter, rule can be override per extension by adding extension name as a prefix to the parameter:

hac.xss.filter.header.X-Frame-Options=DENY

JMX Settings

JMX is a managed property, and you do not have to separately configure it.

Login and password configuration

To configure a login/password, edit the local.properties and add the following parameters to JVM startup arguments:

tomcat.generaloptions=...
-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access

Then add the following files in $CATALINA_HOME/conf:

  • jmxremote.access - the access control file defines the permitted access for each role.
  • jmxremote.password - the password file.

Password Files

Only the owner should have read and write permissions on this file (it contains the passwords in clear text). For security reasons, the system checks that the file is only readable by the owner and exits with an error if it is not.

Property names are roles, and the associated value is the role's password.

On Solaris, Linux, or Mac OS X operating systems, you can set the file permissions for the password file by running the following command. chmod 600 jmxremote.password

For instructions on how to set file permissions on Windows platforms, see Java JMX: Additional Security Information For Microsoft WindowsInformation published on non-SAP site.

Access Files

The access file defines the roles and their access levels. Two primary roles are defined by default:

  • monitorRole - grants read-only access
  • controlRole - grants read-write access

An access control entry consists of a role name and an associated access level. The role name cannot contain spaces or tabs and must correspond to an entry in the password file. The access level can be either read-only or readwrite.

A role should have only one entry in the access file. A role without an entry, has no access. For a role with multiple entries, the last entry takes precedence.

SSL Client Authentication

SSL client authentication should be used on production environment. To enable it, set the Java VM system property:

com.sun.management.jmxremote.ssl.need.client.auth=true

Information on how to generate a certificate and configure SSL on the client system can be found in Java JMX: Using SSLInformation published on non-SAP site.

Tomcat

The Tomcat instance should be hardened.

HTTP Header Security Filter

There are a number of HTTP headers that can be added to the response to improve the security of the connection. With Tomcat comes the HTTP Header Security Filter, which provides a mechanism for adding those headers. Security-related headers with more complex requirements, like CORS, are implemented as separate Filters.

SAP recommends that you set:

  • blockContentTypeSniffingEnabled - this option sets X-Content-Type-Options header

More information can be found in the Apache Tomcat 8 Configuration documentationInformation published on non-SAP site.

Browser Cache

The browser has a capability to temporarily store some of the pages browsed. These cached files are stored in a folder, like the Temporary Internet Files folder in the case of Internet Explorer. If sensitive information is cached, attacker can access the same machine and searches through the Temporary Internet Files or use back button (if there is open session in client browser).

Making Sure a Web Page Is Not Cached Across All Browsers

The response header sent from the server has some cache control directives that can be set, to prevent page from being cached.

The correct minimum set of headers that work across most clients (and proxies):

Cache-Control : no-cache, no-store 
Pragma: no-cache
Expires: 0

Implementation Notes

Apache HTTP Server

Apache uses optional modules to include headers, including both Expires and Cache-Control. Both modules are available in the 1.2 or greater distribution.

The modules need to be built into Apache; although they are included in the distribution, they are not turned on by default. To find out if the modules are enabled in your server, find the httpd binary and run httpd -l; this should print a list of the available modules (note that this only lists compiled-in modules; on later versions of Apache, use httpd -M to include dynamically loaded modules as well). The modules we’re looking for are expires_module and headers_module.

If they aren’t available, recompile Apache to include them. This can be done either by uncommenting the appropriate lines in the Configuration file, or using the -enable-module=expires and -enable-module=headers arguments to configure (1.3 or greater). Consult the INSTALL file found with the Apache distribution.

Once appropriate modules are enabled, use mod_expires to specify when representations should expire, either in .htaccess files or in the server’s access.conf file. See the module documentationInformation published on non-SAP site for more information.

To apply Cache-Control headers, use the mod_headers module, which allows to specify arbitrary HTTP headers for a resource. See the mod_headers documentationInformation published on non-SAP site. Below are recommended settings:

mod_expires

LoadModule expires_module modules/mod_expires.so
<Location />
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
</Location> 

Cache should be disabled only on pages, where it is connected with security requirements (pages where sensitive information is present). In that case change:

mod_headers

<LocationMatch /PAGE_THAT_SHOULD_NOT_BE_CACHED/>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</LocationMatch>

to valid LocationMatch value.

mod_headers

<LocationMatch /media/>
    Header set Cache-Control "max-age=2592000"
</LocationMatch>
    
<LocationMatch /ui_/>
    Header set Cache-Control "max-age=2592000"
</LocationMatch>
 
<LocationMatch /PAGE_THAT_SHOULD_NOT_BE_CACHED/>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</LocationMatch>

Apache 2’s configuration is very similar to that of 1.3; see the 2.2 mod_expiresInformation published on non-SAP site and mod_headersInformation published on non-SAP site documentation for more information.

Basic Authentication for POP3 Protocol in Microsoft Exchange Online

Effective October 1, 2022, Basic Authentication in Exchange Online is disabled for a number of protocols including POP3. To avoid exceptions, disable POP before SMTP authentication using the following property:

mail.pop3.beforesmtp=false

For more information, see Deprecation of Basic authentication in Exchange OnlineInformation published on non-SAP site.