SWR-001- Users of the REST API can log in and receive an access token
Internal ID | SWR_001 |
Title | Users of the REST API can log in and receive an access token |
Category | SECURITY, REGULATORY |
Importance | CRITICAL |
System | REST API |
Editor(s) | Alejandro Carmena Magro, JD-017 |
Supervisor | Alfonso Medela , JD-005 |
Approval | |
Created at | 17 Jun 2024 |
Description​
The REST API provides an endpoint for user authentication. Users can log in by providing their credentials (username and password). Upon successful authentication, the API returns an access token (e.g. a JSON Web Token) that can be used for subsequent requests to authorize access to protected resources.
Activities generated​
- Development of the login endpoint.
- Implementation of secure password handling and storage.
- Generation and management of web access tokens.
Implements user needs​
This requirement ensures that users can securely log in to the system and obtain an access token, enabling them to perform authorized actions within the device UI. It addresses the critical need for secure user authentication in the system.
Regulatory requirements​
1.1: The device shall be compliant with MDR 2017/745, Annex I, point 17.2, 17.4, 18.8, 23.4(ab).
Causes failure modes​
- Incorrect handling of user credentials may lead to potential leaks and other security vulnerabilities.
- Failure to generate or validate access tokens could prevent users from accessing the system.
- Insufficient protections against brute force attacks (e.g., not implementing rate limiting and account lockout mechanisms), allowing attackers to guess passwords.
- Failure to properly handle token expiration, leading to users being logged out unexpectedly or able to use expired tokens.
- Insufficient encryption or lack of HTTPS, making the login process susceptible to MITM attacks.
- Lack of mechanisms to prevent replay attacks, where an attacker intercepts and reuses a valid token.
- Providing overly detailed error messages that could give attackers clues about the system's security mechanisms.
Tested by software tests​
- PLAN_001: User submits credentials to receive a token
- PLAN_002: Token expiration in user authentication process
- PLAN_003: Account lockout for user authentication
In addition to system-level tests, this requirement has also been verified through unit tests for each component of the login process and integration tests to ensure all components communicate successfully when a request is sent to the authentication endpoint.
Implements risk control measures​
- Tokens have a short expiration time to limit the window of vulnerability if a token is compromised. A refresh token mechanism is implemented to obtain new tokens securely.
- Implement token revocation mechanisms to invalidate tokens when necessary, such as during logout or after detecting suspicious activities.
- Implement rate limiting on login attempts to prevent brute force attacks.
- Account lockout mechanisms are in place to temporarily disable accounts after a certain number of failed login attempts.
- Implement secure error handling to ensure that error messages do not disclose sensitive information that could be useful to attackers.
- Implement logging and monitoring to detect and respond to suspicious activities in real-time.
Acceptance criteria​
- Users can successfully log in with valid credentials and receive an access token.
- The system rejects invalid login attempts with appropriate error messages.
- Access tokens are generated securely and have a configurable expiration time.
Constraints​
- The login process must comply with relevant security standards and regulations (e.g., GDPR)
Dependencies​
- User management system for validating credentials.
- Secure storage system (e.g., Database) for user passwords.
Performance considerations​
- The login endpoint must handle a high number of concurrent requests efficiently.
- Access token generation and validation should be optimized for performance.
Additional notes​
Future enhancements may include multi-factor authentication (MFA) as an additional layer of security, requiring users to provide a second form of verification in addition to their password.
Revision history​
Version | Date | Author | Description |
---|---|---|---|