Skip to content

Commit e3da47a

Browse files
authored
Update A2
1 parent 3e805b3 commit e3da47a

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed

2019/en/src/0xa2-broken-authentitcation.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,68 @@ A2:2019 Broken Authentication
44
| Threat agents/Attack vectors | Security Weakness | Impacts |
55
| - | - | - |
66
| API Specific : Exploitability **3** | Prevalence **2** : Detectability **2** | Technical **3** : Business Specific |
7-
| Keys are the most popular API authentication mechanism but managing them correctly is not an easy task. Attackers have automatic tools to search for API keys on public repositories or mobile applications. | When authentication is based simply on keys, once the attacker gets access to valid tokens they can perform legitimate API requests. Although access can be logged and monitored, the ability to investigate and identify malicious activity is not a simple task. | The impact greatly depends on access tokens grants and can range from the exposure of sensitive data for a single user to full data access or even control over multiple systems and services. |
7+
| Authentication in APIs is a complex and confusing mechanism. Software and security engineers might have misconceptions about what are the boundaries of authentication and how to implement it right. On top of that, the authentication mechanism is an easy target for attackers, since it’s exposed to everyone. These two points, makes the authentication component a fertile ground for many exploits. | There are two sub issues: 1. Lack of protection mechanisms: APIs endpoints that are responsible for authentication must be treated differently from regular endpoints and implement extra layers of protection. 2. Misimplementation of the mechanism: The mechanism is used \ implemented without considering the attack vectors, or it’s the wrong use case (e.g.: an authentication mechanism designed for IoT clients might not be the right choice for web applications) | Attackers can gain control to other users’ accounts in the system, read their personal data and perform sensitive actions on their behalf like money transactions and sending personal messages. |
88

99
## Is the API Vulnerable?
1010

11-
The API is vulnerable if:
11+
Authentication endpoints and flows are assets that need to be protected.
1212

13-
* Authentication only relies on access tokens.
14-
* The same access token is valid for multiple APIs or API versions.
15-
* Access tokens are tracked together with the source code on a version control
16-
system or hard-coded in the client.
13+
“Forgot password / reset passwords” should be treated the same way as authentication mechanisms.
14+
15+
An API is vulnerable if:
16+
* Permits [credential stuffing][1] where the attacker has a list of valid usernames and passwords.
17+
* Permits attackers to perform a brute force attack on the same user, without presenting captcha \ account lockout mechanism
18+
* Permits weak passwords
19+
* Sends sensitive authentication details, such as auth tokens and password in the URL.
20+
* Doesn’t validate the authenticity of tokens
21+
* Accepts unsigned / weakly signed JWT tokens ("alg":"none") / doesn’t validate their expiration date
22+
* Uses plain text, encrypted, or weakly hashed passwords
23+
* Uses weak encryption keys / API keys
1724

1825

1926
## Example Attack Scenarios
2027

2128
## Scenario #1
2229

23-
A mobile application adds smartphone-controlled geolocation, remote start/stop
24-
and lock/unlock capabilities to a vehicle with a compatible remote start unit.
25-
By reverse engineering the mobile application an attacker finds hard-coded admin
26-
credentials which can be used in place of a user's username and password to
27-
communicate with the server endpoint for a target user's account. With these
28-
credentials the attacker can learn the ___location of a target as well as gain
29-
unauthorized control over the car.
30+
[Credential stuffing][1], the use of [lists of known passwords][2], is a common attack.
31+
If an application does not implement automated threat or credential stuffing
32+
protections, the application can be used as a password oracle to determine if
33+
the credentials are valid.
3034

3135
## Scenario #2
3236

33-
A company uses private repositories on a web-based hosting service for version
34-
control. Access tokens to their internal APIs as well as cloud services are
35-
tracked together with the source code and an attacker targeting this company
36-
gains control over the private repository. Using the exposed access tokens the
37-
attacker not only gets access to sensitive data but also control over some
38-
services.
37+
An attacker starts the password recovery workflow by issuing a POST request to
38+
`/api/system/verification-codes` and by providing the username in the request
39+
body. Next an SMS token with 6 digits is sent to the victim’s phone. Because the
40+
API does not implement a rate limiting policy the attacker can test all possible
41+
combinations using a multi-thread script, against the
42+
`/api/system/verification-codes/{smsToken}` endpoint to discover the right token
43+
within a few minutes.
3944

4045
## How To Prevent
4146

42-
* APIs that have access to sensitive data should use an additional form of
43-
authentication in addition to API keys.
44-
* API keys should have restrictions both for the applications (e.g. mobile app,
45-
IP address) and the set of APIs they are valid for.
46-
* API keys should be stored on a secure ___location such as a vault.
47-
* A Configuration Management (CM) tool should be used and a clear configuration
48-
management process should be defined.
47+
* Make sure you know all the possible flows to authenticate to the API (mobile/web/deep links that implement one-click authentication/etc)
48+
* Ask your engineers what flows you missed.
49+
* Read about your authentication mechanisms. Make sure you understand what and how they are used. OAuth is not authentication, and neither API keys .
50+
* Don't reinvent the wheel in authentication, token generation, password storage. Use the standards.
51+
* Credential recovery / forget password endpoints should be treated as login endpoints in terms of brute force, rate limiting and lockout protections.
52+
* Use the [OWASP Authentication Cheatsheet][3]
53+
* Where possible, implement multi-factor authentication.
54+
* Implement anti brute force mechanisms to mitigate credential stuffing, dictionary attack and brute force attacks on your authentication endpoints. This mechanism should be stricter than the regular rate limiting mechanism on your API.
55+
* Implement [account lockout][4] / captcha mechanism to prevent brute force against specific users.
56+
Implement weak-password checks.
57+
* API keys should not be used for user authentication, but for [client app / project authentication][5].
4958

5059
## References
5160

5261
### OWASP
5362

54-
* [OWASP Key Management Cheat Sheet][1]
55-
56-
### External
63+
* [OWASP Authentication Cheatsheet][3]
64+
* [Credential Stuffing][1]
5765

58-
* [CWE-798: Use of Hard-coded Credentials][2]
5966

60-
[1]: https://www.owasp.org/index.php/Key_Management_Cheat_Sheet
61-
[2]: https://cwe.mitre.org/data/definitions/798.html
67+
[1]: https://www.owasp.org/index.php/Credential_stuffing
68+
[2]: https://github.com/danielmiessler/SecLists
69+
[3]: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
70+
[4]: https://www.owasp.org/index.php/Testing_for_Weak_lock_out_mechanism_(OTG-AUTHN-003)
71+
[5]: https://cloud.google.com/endpoints/docs/openapi/when-why-api-key

0 commit comments

Comments
 (0)