Skip to content

[7.17] Fixes bulk re-encryption for encrypted objects located in all spaces (#217625)#218182

Merged
jeramysoucy merged 3 commits into
elastic:7.17from
jeramysoucy:backport/7.17/pr-217625
Apr 15, 2025
Merged

[7.17] Fixes bulk re-encryption for encrypted objects located in all spaces (#217625)#218182
jeramysoucy merged 3 commits into
elastic:7.17from
jeramysoucy:backport/7.17/pr-217625

Conversation

@jeramysoucy
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 7.17:

Questions ?

Please refer to the Backport tool documentation

…lastic#217625)

Closes elastic#215534

## Summary

The Encrypted Saved Objects Key Rotation service makes use of the Saved
Objects Bulk Update API to re-encrypt objects. Bulk update supports an
optional 'namespace' parameter, per-object, defining the space to access
a specific object. This allows objects outside of the current space to
be affected in the update operation. The Key Rotation service leverages
this optional parameter for each object to ensure that the re-encryption
operation is not limited to the current space.

However, should a multi-namespace encrypted object reside in all spaces,
the only value in the object's namespaces property is the
`ALL_NAMESPACES_STRING` constant '*'. As this is not a valid single
namespace, the Bulk Update operation will skip updating the object.

PR resolves the issue by only providing a object namespace for objects
that do not reside in all spaces. Objects that reside in all spaces can
be accessed from the current space without the need for an override.

This PR also updates unit tests to account for this case.

### Testing
- [x] Set the encrypted saved objects encryption key to a known value
(either in kibana.yml or kibana.dev.yml). For example:
```
xpack.encryptedSavedObjects:
  encryptionKey: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
```
- [x] Start ES & Kibana
- [x] You will need to set up a Fleet agent policy and create a
synthetics location and monitor. The UI will guide you through this when
you navigate to Observability -> Synthetics
- [x] Create a synthetics parameter, Observability -> Synthetics ->
Settings, Global Parameters tab. Use anything for a value, but be sure
to check the `Share across spaces` option.
- [x] Update the kibana config to change the encryption key, and use the
old key as a decryption-only key
```
xpack.encryptedSavedObjects:
  encryptionKey: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
  keyRotation:
    decryptionOnlyKeys: ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
```
- [x] Wait for Kibana to restart
- [x] Call the key rotation HTTP API as a privileged user (I just used
the `elastic` superuser account)

`[you_kibana_endpoint]/api/encrypted_saved_objects/_rotate_key?type=synthetics-param`
- [x] Verify that 1 out of 1 objects were processed with 0 failures.
- [x] Repeat these steps from Main and note that 0 of 1 objects
succeeded, and there is 1 failure

### Release Note
Fixes an issue where the Saved Objects Rotate Encryption Key API would
not affect sharable encrypted object types that exist in all spaces.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 1176625)

# Conflicts:
#	x-pack/platform/plugins/shared/encrypted_saved_objects/tsconfig.json
#	x-pack/plugins/encrypted_saved_objects/server/crypto/encryption_key_rotation_service.ts
@jeramysoucy jeramysoucy added the backport This PR is a backport of another PR label Apr 14, 2025
@jeramysoucy jeramysoucy enabled auto-merge (squash) April 14, 2025 22:05
@jeramysoucy jeramysoucy requested a review from a team April 14, 2025 22:18
Copy link
Copy Markdown
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backport LGTM!

@jeramysoucy jeramysoucy merged commit 7493ca9 into elastic:7.17 Apr 15, 2025
87 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants