cinder/api-ref/source/v3
Gorka Eguileor dd6010a9f7 Reject unsafe delete attachment calls
Due to how the Linux SCSI kernel driver works there are some storage
systems, such as iSCSI with shared targets, where a normal user can
access other projects' volume data connected to the same compute host
using the attachments REST API.

This affects both single and multi-pathed connections.

To prevent users from doing this, unintentionally or maliciously,
cinder-api will now reject some delete attachment requests that are
deemed unsafe.

Cinder will process the delete attachment request normally in the
following cases:

- The request comes from an OpenStack service that is sending the
  service token that has one of the roles in `service_token_roles`.
- Attachment doesn't have an instance_uuid value
- The instance for the attachment doesn't exist in Nova
- According to Nova the volume is not connected to the instance
- Nova is not using this attachment record

There are 3 operations in the actions REST API endpoint that can be used
for an attack:

- `os-terminate_connection`: Terminate volume attachment
- `os-detach`: Detach a volume
- `os-force_detach`: Force detach a volume

In this endpoint we just won't allow most requests not coming from a
service. The rules we apply are the same as for attachment delete
explained earlier, but in this case we may not have the attachment id
and be more restrictive.  This should not be a problem for normal
operations because:

- Cinder backup doesn't use the REST API but RPC calls via RabbitMQ
- Glance doesn't use this interface

Checking whether it's a service or not is done at the cinder-api level
by checking that the service user that made the call has at least one of
the roles in the `service_token_roles` configuration. These roles are
retrieved from keystone by the keystone middleware using the value of
the "X-Service-Token" header.

If Cinder is configured with `service_token_roles_required = true` and
an attacker provides non-service valid credentials the service will
return a 401 error, otherwise it'll return 409 as if a normal user had
made the call without the service token.

Closes-Bug: #2004555
Change-Id: I612905a1bf4a1706cce913c0d8a6df7a240d599a
(cherry picked from commit 6df1839bdf)
Conflicts:
	cinder/exception.py
2023-05-10 19:52:39 +02:00
..
samples api-ref: Add docs for clusters 2022-08-31 10:02:20 +01:00
api-versions.inc Automate generation of API versions api-ref samples 2019-01-10 19:48:18 +05:30
attachments.inc Reject unsafe delete attachment calls 2023-05-10 19:52:39 +02:00
capabilities-v3.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30
clusters.inc api-ref: Add docs for clusters 2022-08-31 10:02:20 +01:00
consistencygroups-v3.inc cinder:api-ref replace mention of "policy.json" 2020-07-07 20:55:09 +05:30
default-types.inc Default type overrides 2020-09-16 14:05:31 +00:00
ext-backups-actions-v3.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30
ext-backups.inc api-ref: include links on backups list and details 2022-01-24 11:43:29 -03:00
group-replication.inc Update api-ref 2020-02-04 18:41:30 -05:00
group-snapshots.inc Update api-ref 2020-02-04 18:41:30 -05:00
group-type-specs.inc Update api-ref 2020-02-04 18:41:30 -05:00
group-types.inc Update api-ref 2020-02-04 18:41:30 -05:00
groups.inc [api-ref]Add replication_status(optional) to List groups with details response 2020-09-15 15:47:26 +08:00
hosts.inc [api-ref]Fix values of service-status in list-hosts 2019-08-23 09:41:37 +08:00
index.rst api-ref: Add docs for clusters 2022-08-31 10:02:20 +01:00
limits.inc Automate generation of qos specs api-ref samples 2019-09-27 17:43:40 +05:30
messages.inc Update api-ref 2020-02-04 18:41:30 -05:00
os-cgsnapshots-v3.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30
os-services.inc api-ref: Add docs for clusters 2022-08-31 10:02:20 +01:00
os-vol-pool-v3.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30
os-vol-transfer-v3.inc api-ref: Fix "id" parameter 2021-03-25 09:14:32 -04:00
parameters.yaml Remove multiatttach request parameter 2023-03-17 14:14:36 +00:00
qos-specs-v3-qos-specs.inc Automate generation of qos specs api-ref samples 2019-09-27 17:43:40 +05:30
quota-classes.inc Automate generation of quotas api-ref samples 2019-09-30 16:29:49 +05:30
quota-sets.inc Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
resource-filters.inc Expose volume & snapshot use_quota field 2021-08-26 19:04:12 +02:00
snapshot-manage.inc Cleanup api-ref sample files 2019-07-03 13:22:33 -05:00
valid-boolean-values.inc Include .inc files in doc8 linting 2019-02-19 11:33:05 -06:00
vol-transfer-v3.inc api-ref: Fix "name" parameter 2021-04-16 20:31:08 +00:00
volume-manage.inc Prohibit volume manage to an encrypted volume type 2022-03-21 11:48:01 -04:00
volume-type-access.inc Update api-ref 2020-02-04 18:41:30 -05:00
volumes-v3-extensions.inc Automate generation of API versions api-ref samples 2019-01-10 19:48:18 +05:30
volumes-v3-snapshots-actions.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30
volumes-v3-snapshots.inc Snapshot in-use volumes without force flag 2021-08-31 14:48:32 -04:00
volumes-v3-types.inc Add default types info in admin docs 2021-11-19 05:13:46 -05:00
volumes-v3-versions.inc Automate generation of API versions api-ref samples 2019-01-10 19:48:18 +05:30
volumes-v3-volumes-actions.inc Reject unsafe delete attachment calls 2023-05-10 19:52:39 +02:00
volumes-v3-volumes.inc Remove multiatttach request parameter 2023-03-17 14:14:36 +00:00
worker-cleanup.inc Improve/Clean api-ref parameters 2018-11-05 10:47:14 +05:30