Skip to content

Commit 0a062cf

Browse files
committed
Update
1 parent 42de1ca commit 0a062cf

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

javascript/frameworks/cap/src/bad-authn-authz/DefaultUserIsPrivileged/DefaultUserIsPrivileged.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The user whose request cannot be verified as authenticated is represented as `cd
88

99
It may be tempting to overwrite the `cds.User.default` as `cds.User.Privileged`, for ease of development. However, this may slip through production undeleted since the assignment to `cds.User.default` can be hard to detect because it may take various forms; e.g. the programmer may choose to store `cds.User` to a variable `v` and access `cds.User.default` by `v.default`.
1010

11-
A safer and more elegant solution is to set up a development profile and opt in to use a non-production strategy such as basic, dummy, or mocked during its use. This can be done in `package.json` of the CAP application at its project root:
11+
A safer and more elegant solution is to set up a development profile and opt in to use a non-production strategy such as `"basic"`, `"dummy"`, or `"mocked"` during its use. This can be done in `package.json` of the CAP application at its project root:
1212

1313
``` json
1414
{
@@ -45,6 +45,6 @@ cds.serve("all").in(app);
4545
## References
4646

4747
- SAP CAPire Documentation: [cds.User.default](https://cap.cloud.sap/docs/node.js/authentication#default-user).
48+
- SAP CAPire Documentation: [cds.User.Privileged](https://cap.cloud.sap/docs/node.js/authentication#privileged-user).
4849
- SAP CAPire Documentation: [Authentication Strategies](https://cap.cloud.sap/docs/node.js/authentication#strategies).
49-
- Common Weakness Enumeration: [CWE-862](https://cwe.mitre.org/data/definitions/862.html).
50-
- Common Weakness Enumeration: [CWE-306](https://cwe.mitre.org/data/definitions/306.html).
50+
- Common Weakness Enumeration: [CWE-250](https://cwe.mitre.org/data/definitions/250.html).
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Non-Production Authentication Strategy Used without Profiles
2+
3+
Using a non-production authentication strategy without setting up a distinct profile for development may pose allow unintended authentication and/or authorization if the application is deployed into production.
4+
5+
## Recommendation
6+
7+
### Isolate the use of development-level strategies to a development profile
8+
9+
Use separate profiles for development and deployment and select one as needed. In this way, properties including authentication strategies can be substituted by changing a single command line option: `--profile`. For example, having the following section in the application's `package.json` states that the `"dummy"` authentication strategy must be used while `"xsuaa"`, a production-grade strategy, should be used when deployed:
10+
11+
``` json
12+
{
13+
"requires": {
14+
"[dev]": {
15+
"auth": "dummy"
16+
},
17+
"[deploy]": {
18+
"auth": "xsuaa"
19+
}
20+
}
21+
}
22+
```
23+
24+
The application can be now run in different modes depending on the `--profile` command line option:
25+
26+
``` shell
27+
$ cds serve --profile dev # Runs the application in development profile with strategy "dummy"
28+
$ cds serve --profile deploy # Runs the application in development profile with strategy "xsuaa"
29+
```
30+
31+
## Example
32+
33+
The following CAP application states that it uses `"basic"` authentication strategy along with mocked credentials. Using the pair of username and password, an attacker can gain access to certain assets by signing in to the application.
34+
35+
``` json
36+
{
37+
"cds": {
38+
"requires": {
39+
"auth": {
40+
"kind": "basic",
41+
"users": {
42+
"JohnDoe": {
43+
"password": "JohnDoesPassword",
44+
"roles": ["JohnDoesRole"],
45+
"attr": {}
46+
},
47+
"JaneDoe": {
48+
"password": "JaneDoesPassword",
49+
"roles": ["JaneDoesRole"],
50+
"attr": {}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
```
58+
59+
## References
60+
61+
- Common Weakness Enumeration: [CWE-288](https://cwe.mitre.org/data/definitions/288.html).
62+
- Common Weakness Enumeration: [CWE-798](https://cwe.mitre.org/data/definitions/798.html).
63+
- SAP CAPire Documentation: [Authentication Strategies](https://cap.cloud.sap/docs/node.js/authentication#strategies).

0 commit comments

Comments
 (0)