security: [BUG] TransportConfigUpdateAction causing a race condition during node bootstrap leading to 403/500 errors
What is the bug? Partial configuration is loaded/cached in security plugin objects/memory in case of a race condition during OpenSearch process bootstrap on a node. For e.g. this can lead to missing role mappings in-memory causing invalid 403s to the requests landing on the buggy node. Details: During a node bootstrap, initOnNodeStart is kicked-off after Rest layer is ready. However, a node joins the cluster and replica shard for security index is assigned after transport channel is ready and cluster manager is discovered. Hence, if a TransportConfigUpdateAction triggers an update for a particular config (let’s say securityconfig), DynamicConfigFactory object gets initialized and this condition is never true leading to partial config in memory.
How can one reproduce the bug? Steps to reproduce the behavior:
- Create a multi-node cluster. From a healthy node, execute something like below in a continuous loop
curl -XPATCH "http://localhost:9200/_plugins/_security/api/securityconfig" -H 'Content-Type: application/json' -d'
[{
"op": "replace", "path": "/config/dynamic/authc/basic_internal_auth_domain/transport_enabled", "value": "true"
}
]'
- Restart OS process on a different node, (you can enable debug logs on ConfigurationLoaderSecurity7 to check the config being pushed.
- Since step 1 is running in a continuous loop, chances are transport channel action initializes the object with Config Type only and hence, other configs will be skipped.
A temporary fix here is to either flush the cache using flush API OR send a dummy config update request.
What is the expected behavior? Do not partially initialize objects.
What is your host/environment?
- OS: Linux
- Version - All
- Plugins - Security plugin
Do you have any screenshots? NA
Do you have any additional context?
A fix here would be to check the state of DynamicConfigFactory here before calling reload.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (18 by maintainers)
Commits related to this issue
- Allow TransportConfigUpdateAction when security config initialization has completed (#3810) ### Description Introduces another variable on DynamicConfigFactory called `bgThreadComplete` that beha... — committed to opensearch-project/security by cwperks 3 years ago
- Allow TransportConfigUpdateAction when security config initialization has completed (#3810) Introduces another variable on DynamicConfigFactory called `bgThreadComplete` that behaves differently than... — committed to cwperks/security by cwperks 3 years ago
- Allow TransportConfigUpdateAction when security config initialization has completed (#3810) Introduces another variable on DynamicConfigFactory called `bgThreadComplete` that behaves differently than... — committed to dlin2028/security by cwperks 3 years ago
@cwperks I’ll see about getting this merged and backported