keystone/keystone/api
Colleen Murphy 54590544fb Fix security issues with EC2 credentials
This change addresses several issues in the creation and use of EC2/S3
credentials with keystone tokens.

1. Disable altering credential owner attributes or metadata

Without this patch, an authenticated user can create an EC2 credential
for themself for a project they have a role on, then update the
credential to target a user and project completely unrelated to them. In
the worst case, this could be the admin user and a project the admin
user has a role assignment on. A token granted for an altered credential
like this would allow the user to masquerade as the victim user. This
patch ensures that when updating a credential, the new form of the
credential is one the acting user has access to: if the system admin
user is changing the credential, the new user ID or project ID could be
anything, but regular users may only change the credential to be one
that they still own.

Relatedly, when a user uses an application credential or a trust to
create an EC2 credential, keystone automatically adds the trust ID or
application credential ID as metadata in the EC2 access blob so that it
knows how the token can be scoped when it is used. Without this patch, a
user who has created a credential in this way can update the access blob
to remove or alter this metadata and escalate their privileges to be
fully authorized for the trustor's, application credential creator's, or
OAuth1 access token authorizor's privileges on the project. This patch
fixes the issue by simply disallowing updates to keystone-controlled
metadata in the credential.

2. Respect token roles when creating EC2 credentials

Without this patch, a trustee, an application credential user, or an
OAuth1 access token holder could create an EC2 credential or an
application credential using any roles the trustor, application
credential creator, or access token authorizor had on the project,
regardless of whether the creator had delegated only a limited subset of
roles. This was because the trust_id attribute of the EC2 access blob
was ignored, and no metadata for the application credential or access
token was recorded either. This change ensures that the access
delegation resource is recorded in the metadata of the EC2 credential
when created and passed to the token provider when used for
authentication so that the token provider can look up the correct roles
for the request.

Conflicts (six removal in  e2d83ae9, pep8 fixes in e2d83ae9, test helper
in 52da4d0e12):
      keystone/api/credentials.py
      keystone/tests/unit/test_v3_application_credential.py
      keystone/tests/unit/test_v3_credential.py

Depends-on: https://review.opendev.org/726526

Change-Id: I39d0d705839fbe31ac518ac9a82959e108cb7c1d
Closes-bug: #1872733
Closes-bug: #1872755
Closes-bug: #1872735
(cherry picked from commit 37e9907a17)
(cherry picked from commit 2f2736ebb2)
2020-05-09 12:55:00 -07:00
..
_shared Fix security issues with EC2 credentials 2020-05-09 12:55:00 -07:00
__init__.py Revert "Add API for /v3/access_rules_config" 2019-05-28 08:38:39 -07:00
auth.py Merge "Add remote_id definition in _perform_auth" 2019-09-20 18:25:39 +00:00
credentials.py Fix security issues with EC2 credentials 2020-05-09 12:55:00 -07:00
discovery.py Update API version for access rules 2019-09-14 03:14:45 -07:00
domains.py Allow an explicit_domain_id parameter when creating a domain 2019-04-09 16:29:52 +00:00
ec2tokens.py Make collection_key and member_key raise if unset 2018-10-12 11:18:41 -07:00
endpoints.py Convert auth to flask native dispatching 2018-10-09 23:23:03 -07:00
groups.py Add domain scope support for group policies 2019-03-27 17:15:00 +01:00
limits.py Allow domain users to access the limit API 2019-09-24 19:14:17 -07:00
os_ep_filter.py Allow to filter endpoint groups by name 2019-07-18 08:57:50 +02:00
os_federation.py Raise METHOD NOT ALLOWED instead of 500 error on protocol CRUD 2019-03-28 22:07:01 +00:00
os_inherit.py Add build_target arguement to enforcer 2018-09-28 15:50:44 -05:00
os_oauth1.py Fix oauthlib update errors 2019-09-05 11:48:41 -07:00
os_revoke.py Move json_home "extension" rel functions 2018-08-16 20:49:01 +00:00
os_simple_cert.py Fix missing print format and missing ws between words 2019-08-06 08:29:34 +08:00
policy.py Convert policy API to flask 2018-08-31 07:14:32 +00:00
projects.py Add default roles and scope checking to project tags 2019-09-19 02:48:39 +00:00
regions.py Convert regions API to flask native dispatching 2018-08-13 20:05:57 +00:00
registered_limits.py Add hint back 2018-09-20 14:58:43 +08:00
role_assignments.py Fix validation of role assignment subtree list 2019-09-17 23:12:47 -07:00
role_inferences.py Convert role_inferences API to flask native dispatching 2018-08-13 20:06:35 +00:00
roles.py Merge "Add hint back" 2018-10-03 21:51:14 +00:00
s3tokens.py Convert S3 and EC2 auth to flask native dispatching 2018-10-11 15:27:46 -07:00
services.py Convert services api to flask native dispatching 2018-08-13 20:06:11 +00:00
system.py Add build_target arguement to enforcer 2018-09-28 15:50:44 -05:00
trusts.py Add missing ws between words in log messages 2019-09-23 11:48:00 +08:00
users.py Fix security issues with EC2 credentials 2020-05-09 12:55:00 -07:00