|
1 | | -# Disabled XSJS CSRF protection |
| 1 | +# CSRF protection disabled in HANA XS application |
2 | 2 |
|
3 | | -A web server that receives a request from a client without verifying that it was intentionally sent might be vulnerable to Cross Site Request Forgery (CSRF). An attacker can trick a client into making an unintended request to the web server that will be treated as an authentic request. This can be done via a URL, image load, XMLHttpRequest, etc. and can result in exposure of data or unintended code execution. |
| 3 | +This XS application is not protected against CSRF (cross-site request forgery) because it either disables the protection or fails to enable the protection explicitly. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +A web server that receives a request from a client without verifying that it was intentionally sent might be vulnerable to Cross Site Request Forgery (CSRF). An attacker can trick a client into making an unintended request to the web server that will be treated as an authentic request. This can be done via a URL, image load, `XMLHttpRequest`, etc. and can result in exposure of data or unintended code execution. |
4 | 8 |
|
5 | 9 | ## Recommendation |
6 | 10 |
|
7 | | -SAP’s recommendation is to use CSRF protection for any request that could be processed by a browser client by normal users. |
8 | | -- In `XS Advanced` CSRF protection is enabled by default and should not be disabled. |
9 | | -- In `XS Classic` CSRF protection should be enabled explicitly. |
| 11 | +SAP’s recommendation is to use CSRF protection for any request that could be processed by a browser client by normal users. |
| 12 | +- If `XS Advanced` is used, CSRF protection is configured with the `"csrfProtection"` property of `xs-app.json`. It is **enabled by default and should not be disabled.** |
| 13 | +- If `XS Classic` is used, CSRF protection is configured with the `"prevent_xsrf"` property of `.xsaccess`. It is **disabled by default and should be enabled explicitly.** |
10 | 14 |
|
11 | 15 | ## Example |
12 | 16 |
|
13 | | -The following `xs-app.json` fragment enables CSRF protection in XSJS. |
| 17 | +The following `xs-app.json` fragment disables CSRF protection of the application it configures. |
14 | 18 |
|
15 | 19 | ```json |
16 | 20 | "routes": [ |
17 | | - { |
18 | | - "source": "/bad/(.*)", |
19 | | - "destination": "srv_api", |
20 | | - "csrfProtection": true, |
21 | | - ... |
22 | | - } |
23 | | -] |
| 21 | + { |
| 22 | + "source": "/bad/(.*)", |
| 23 | + "destination": "srv_api", |
| 24 | + "csrfProtection": false, |
| 25 | + ... |
| 26 | + }, |
24 | 27 | ... |
25 | | - } |
26 | 28 | ] |
27 | 29 | ``` |
28 | 30 |
|
29 | 31 | ## References |
30 | 32 |
|
31 | | -* SAP: [Server-Side JavaScript Security Considerations](https://help.sap.com/docs/SAP_HANA_PLATFORM/d89d4595fae647eabc14002c0340a999/e8a6bc904c0c48a182288604f467e84a.html). |
32 | | -* OWASP: [Cross-Site Request Forgery (CSRF)](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)). |
33 | | -* Common Weakness Enumeration: [CWE-352](https://cwe.mitre.org/data/definitions/352.html). |
| 33 | +- SAP: [XS Advanced Application Router Configuration Syntax](https://help.sap.com/docs/SAP_HANA_PLATFORM/b3d0daf2a98e49ada00bf31b7ca7a42e/a9fc5c220d744180850996e2f5d34d6c.html?version=2.0.03#loioa9fc5c220d744180850996e2f5d34d6c__section_N101F7_N10016_N10001), relavant to XS Classic applications. |
| 34 | +- SAP: [Application-Access File Keyword Options, prevent_xsrf](https://help.sap.com/docs/SAP_HANA_PLATFORM/4505d0bdaf4948449b7f7379d24d0f0d/5f77e58ec01b46f6b64ee1e2afe3ead7.html#authenticationmethod), relevant to XS Advanced applications. |
| 35 | +- SAP: [Server-Side JavaScript Security Considerations](https://help.sap.com/docs/SAP_HANA_PLATFORM/d89d4595fae647eabc14002c0340a999/e8a6bc904c0c48a182288604f467e84a.html). |
| 36 | +- Common Weakness Enumeration: [CWE-352](https://cwe.mitre.org/data/definitions/352.html). |
| 37 | +- OWASP: [Cross-Site Request Forgery (CSRF)](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)). |
0 commit comments