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:

  1. 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"
  }
]'
  1. Restart OS process on a different node, (you can enable debug logs on ConfigurationLoaderSecurity7 to check the config being pushed.
  2. 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

Most upvoted comments

@cwperks I’ll see about getting this merged and backported