SWR-004- The REST API verifies the access token for every request to secure endpoints
Internal ID | SWR_004 |
Title | The REST API verifies the access token for every request to secure endpoints |
Category | SECURITY REGULATORY |
Importance | CRITICAL |
System | User management (API backend) |
Editor(s) | Alejandro Carmena Magro , JD-017 |
Supervisor | Alfonso Medela , JD-005 |
Approval | |
Created at | 20 Jun 2024 |
Description​
The REST API must verify the access token for every request made to protected endpoints to ensure that only authenticated and authorized users can access these resources.
Access tokens are generated upon successful authentication and must be included in the header of each request to secure endpoints. The token contains encoded information that allows the server to verify the identity of the requester and their permissions. The verification process involves decoding the token, validating its signature, and checking its expiration date and associated permissions. If the token is missing, invalid, or expired, the API should deny access to the requested resource and return an appropriate error response.
The implementation should follow industry best practices for token-based authentication. This includes using secure algorithms for creating and validating tokens, keeping token lifespans short to minimize misuse, and ensuring strong error handling to prevent information leaks during verification.
Activities generated​
- Implementation of token verification middleware.
- Integration with the authentication service to validate tokens.
Implements user needs​
Guarantees the security of user data and operations by permitting access to sensitive endpoints only for authenticated and authorized users.
Regulatory requirements​
4.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​
- Fails to reject expired tokens, allowing users to access resources beyond their allowed time frame.
- Revoked or blacklisted tokens are still accepted, enabling previously authorized users to keep access even after their permissions have been revoked.
- An attacker forces the system to use a less secure algorithm for token verification, making it easier to forge tokens. If the API accepts tokens signed with weak algorithms, it becomes vulnerable to forgery.
Tested by software tests​
Implements risk control measures​
- Unauthorized use of services leading to higher operational costs, as heavy use of cloud resources or frequent API calls can result in substantial charges.
Acceptance criteria​
- The API denies access to any request with an invalid or missing access token.
- The API grants access to requests with a valid access token.
Constraints​
- The system should support various token formats as required by the authentication service.
Dependencies​
- Integration with the authentication service (e.g., OAuth 2.0 provider).
- Secure storage of secret keys used for token generation and verification.
Performance considerations​
Token verification should be optimized to ensure minimal impact on response times. Implement caching strategies where appropriate to reduce verification overhead.
Additional notes​
No additional information is required.
Revision history​
Version | Date | Author | Description |
---|---|---|---|