You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- ICM misconfiguration via parameter `icm/HTTP/file_access_<nr>` allows to create an alias from which you browse the entire filesystem via a URL. Authentication can be setup via profile parameter `icm/HTTP/auth_<nr>`.
18
19
19
20
20
21
# Mitigation
@@ -23,5 +24,8 @@ This process can lead to access to sensitive files covering both business and se
23
24
- Control and maintain `SPTH`
24
25
- OS Commands: Requires different mitigation approach through authorization object for `S_LOG_COM` and `S_C_FUNCT`
25
26
- Best practices for OS User Security from SAP
27
+
- Setup authentication for ICM if needed (`icm/HTTP/auth_<nr>`)
26
28
27
29
# References
30
+
-[SAP Help docs for `icm/HTTP/auth_<nr>`](https://help.sap.com/docs/ABAP_PLATFORM_NEW/bd78479f4da741a59f5e2a418bd37908/483edf38c10272d2e10000000a42189c.html)
31
+
-[SAP Help docs for `icm/HTTP/file_access_<nr>`](https://help.sap.com/docs/ABAP_PLATFORM_NEW/683d6a1797a34730a6e005d1e8de6f22/483e1b4e252f72d0e10000000a42189c.html)
Copy file name to clipboardExpand all lines: content/SAP_ABAP_Platform/known_attack_vectors/os_command_execution.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,19 @@ title: "OS Command execution"
3
3
---
4
4
5
5
# Description
6
-
There are various ways to execute os commands via ABAP. When OS commands are executed, `S_LOG_COM` or `S_C_FUNCT` is being checked, depending on the function used to execute OS commands. The execution itself is done through the ABAP kernel and using the OS level authorizations of the user `<SID>adm` or `SAPService<SID>` (Windows).
6
+
There are various ways to execute os commands via ABAP. When OS commands are executed, `S_LOG_COM` or `S_C_FUNCT` is being checked in some of the below cases, depending on the function used to execute OS commands. The execution itself is done through the ABAP kernel and using the OS level authorizations of the user `<SID>adm` or `SAPService<SID>` (Windows).
7
7
8
8
9
9
# Risk
10
-
If an attacker can execute OS commands he elevates his privileges effective to `<SID>adm` or `SAPService<SID>` (Windows) on OS level. Depending on the OS command and technique used, the limitation may exists to restrict the access to single OS commands.
11
-
If an attacker can execute arbitrary OS commands, then this leads to a full compromise of the system.
10
+
If an attacker can execute arbitrary OS commands, then this leads to a full compromise of the system because of a.o. the implicit trust relation between the OS user and the Database. This effectively means you can go from the OS user to the Database without providing a password. In SAP Hana DB for example you can use the `hdbsql` executable on the OS with the `-U DEFAULT` flag to execute SQL queries (insert, update, select, etc) directly in the SAP Schema without having to provide any additonal authentication details.
12
11
13
12
Examples:
14
-
-Exfitrate private SSH keys
15
-
- Overwrite SAP kernel binaries
13
+
-Exfiltrate private SSH keys
14
+
- Overwrite SAP kernel binaries or ACL files
16
15
- Inject code into custom scripts
16
+
- Extract the secure store
17
+
- Via the DB trust relation extract password hashes, create SAP users with SAP_ALL directly in the DB
18
+
- Delete log/trace files
17
19
18
20
In certain cases user input filtering can be bypassed and in those cases the attack can lead to a full compromise of the system. If the execution is limited to a single command, then the business impact depends on the command or the allowed user input of e.g. the parameter.
19
21
@@ -29,6 +31,19 @@ In certain cases user input filtering can be bypassed and in those cases the att
29
31
- Custom Code/ Third Party Code (ABAP `CALL 'SYSTEM'`)
30
32
- Vulnerable Components (e.g. SAP RFC Gateway)
31
33
- Schedule Background Jobs as user `DDIC`
34
+
- Instance profile (executed upon (re)starting SAP): `Execute_XX = <your_command_to_execute_here>` (XX = number like 01)
35
+
- SAP Kernel call from ABAP coding:
36
+
```abap
37
+
CALL 'ThWpInfo' ID 'OPCODE' FIELD (Linux only)
38
+
REPORT ZTEST.
39
+
DATA OPCODEXEC TYPE X VALUE 9.
40
+
CALL 'ThWpInfo' ID 'OPCODE' FIELD OPCODEXEC
41
+
ID 'SERVER' FIELD ''
42
+
ID 'PROG' FIELD 'mkdir '
43
+
ID 'ARGC' FIELD 1
44
+
ID 'ARG1' FIELD '/tmp/blablabla'.
45
+
WAIT UP TO '0.9' SECONDS.
46
+
```
32
47
33
48
# Mitigation
34
49
- Requires different mitigation approach through authorization object for `S_LOG_COM` and `S_C_FUNCT`
Copy file name to clipboardExpand all lines: content/SAP_ABAP_Platform/known_attack_vectors/password_hashes.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,15 @@ These Tables are:
13
13
- VUSER001
14
14
- VUSR02_PWD
15
15
- USR_TOTP
16
+
- EDIDC (Idocs from CUA)
16
17
17
18
There are various ways to access the content of those tables with the consequence of disclosing the hashes. SAP development implemented different hash algorithms throughout the years. The below list shows a breif overview of the used algorithms, starting from the weakest first:
18
19
19
-
-BCODE -> outdated an highly insecure
20
-
-PASSCODE -> outdated and insecure
21
-
-PWDSALTEDHASH -> currently recommended version
20
+
Algorithm | comment
21
+
----------|---------
22
+
BCODE | outdated an highly insecure
23
+
PASSCODE | outdated and insecure
24
+
PWDSALTEDHASH | currently recommended version
22
25
23
26
A detailed explanation is available [here](https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/).
24
27
@@ -29,9 +32,15 @@ Older SAP password hash algorithms (such as those based on weak cryptographic fu
29
32
30
33
# Options
31
34
- Extraction of hashes using Transaction (SE16, SE16N, DBA_COCKPIT, etc)
32
-
- Extraction of hashes via OS Command (special case, access underlying database and tables mentioned above (SQL-Query with Select statement) -> should refer to HDBSQL / SQL-Access OS Command <Option>
33
-
- Cracking hashes (Hashcat, John the Ripper)
34
-
35
+
- Extraction of hashes via OS Command (special case, access underlying database and tables mentioned above (SQL-Query with Select statement) ([more information here](/SAP_ABAP_Platform/known_attack_vectors/os_command_execution/#))
36
+
- Cracking hashes (e.g. with Hashcat, John the Ripper)
37
+
- Supported hashtypes from Hashcat (by 26th September 2025):
38
+
- SAP CODVN B (BCODE)
39
+
- SAP CODVN B (BCODE) from RFC_READ_TABLE
40
+
- SAP CODVN F/G (PASSCODE)
41
+
- SAP CODVN F/G (PASSCODE) from RFC_READ_TABLE
42
+
- SAP CODVN H (PWDSALTEDHASH) iSSHA-1
43
+
- SAP CODVN H (PWDSALTEDHASH) isSHA512
35
44
36
45
# Mitigation
37
46
- Use at least PWDSALTEDHASH for all your current hashes
@@ -52,3 +61,6 @@ Older SAP password hash algorithms (such as those based on weak cryptographic fu
0 commit comments