elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.28k stars 24.86k forks source link

Only run the authz check on non-wildcard names #93085

Open albertzaharovits opened 1 year ago

albertzaharovits commented 1 year ago

Description

Whenever we get into a detailed analysis of Security's authz of index requests the following implementation quirk comes up. Most recently it did during the review of https://github.com/elastic/elasticsearch/pull/92625.

Authorization happens in (at least) 2 steps: 1) rewrite the request to:

Step 2) is wholy redundant if ignore_unavailable is true, as all the resource names in the rewritten request to be authorized are guaranteed to be authorized. Even if ignore_unavailable is false, in step 2), only the non-wildcard names from the original request need to be checked, because the ones expanded from wildcards are guaranteed to be authorized.

Corollary

It should be possible to incorporate step 2) into step 1). In this case, if ignore_unavailable is false, non-wildcard names from the original request should reject the request with the un-authorized error during the rewrite step (which also replaces wildcards and silently drops non-wildcard names if ignore_unavailable is true).

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-security (Team:Security)