The vulnerability exists in OpenStack Keystone because of a missing authorization check when creating and using EC2-type credentials with an application credential. The root cause is twofold:
-
Credential Creation: The POST /v3/credentials endpoint, handled by the CredentialResource.post function, failed to validate that the project_id in the request body for a new EC2 credential was the same as the project_id of the application credential used to authenticate the request. This allowed an attacker with an application credential for Project A to create an EC2 credential associated with Project B.
-
Token Exchange: When the specially crafted EC2 credential was used to get a token via the POST /v3/ec2tokens endpoint, the EC2_S3_Resource.handle_authenticate function would issue a token. This function also lacked a check to ensure the project of the EC2 credential and the application credential matched. As a result, it would issue a token scoped to Project B, even though the original authentication was based on an application credential for Project A.
The patch addresses both of these issues by adding the necessary validation checks in both CredentialResource.post and EC2_S3_Resource.handle_authenticate, thus preventing the creation of mismatched credentials and the issuance of improperly scoped tokens.