-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kibana_root_context
- Loading branch information
Showing
158 changed files
with
2,530 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
id: kibDevDocsSecurityIntro | ||
slug: /kibana-dev-docs/key-concepts/security-intro | ||
title: Security | ||
description: Maintaining Kibana's security posture | ||
date: 2023-07-11 | ||
tags: ['kibana', 'dev', 'contributor', 'security'] | ||
--- | ||
|
||
Security is everyone's responsibility. This is inclusive of design, product, and engineering. The purpose of this guide is to give a high-level overview of security constructs and expectations. | ||
|
||
This guide covers the following topics: | ||
|
||
* [API authorization](#api-authorization) | ||
* [The `kibana_system` user](#the-kibana_system-user) | ||
|
||
## API authorization | ||
Kibana API routes do not have any authorization checks applied by default. This means that your APIs are accessible to anyone with valid credentials, regardless of their permissions. This includes users with no roles assigned. | ||
This on its own is insufficient, and care must be taken to ensure that only authorized users can invoke your endpoints. | ||
|
||
### Adding API authorization | ||
Kibana leverages <DocLink id="kibDevDocsSavedObjectsIntro" text="Saved Objects" /> for a majority of its persistence. The Saved Objects Service performs its own authorization checks, so if your API route is primarily a CRUD interface to Saved Objects, then your authorization needs are already met. | ||
This is also true for derivatives of the Saved Objects Service, such as the Alerting and Cases services. | ||
|
||
If your endpoint is not a CRUD interface to Saved Objects, then your route should include `access` tags to ensure that only authorized users can invoke your endpoint. This is **especially** important if your route does any of the following: | ||
1. Performs non-insignificant processing, causing load on the Kibana server. | ||
2. Calls Elasticsearch using the internal `kibana_system` user. | ||
3. Calls a third-party service. | ||
4. Returns any non-public information to the caller, such as system configuration or state. | ||
|
||
More information on adding `access` tags to your routes can be found temporarily in the [legacy documentation](https://www.elastic.co/guide/en/kibana/current/development-security.html#development-plugin-feature-registration) | ||
|
||
### Why not add `access` tags to all routes by default? | ||
Each authorization check that we perform involves a round-trip to Elasticsearch, so they are not as cheap as we'd like. Therefore, we want to keep the number of authorization checks we perform within a single route to a minimum. | ||
Adding an `access` tag to routes that leverage the Saved Objects Service would be redundant in most cases, since the Saved Objects Service will be performing authorization anyway. | ||
|
||
|
||
## The `kibana_system` user | ||
|
||
The Kibana server authenticates to Elasticsearch using the `elastic/kibana` [service account](https://www.elastic.co/guide/en/elasticsearch/reference/current/service-accounts.html#service-accounts-explanation). This service account has privileges that are equivilent to the `kibana_system` reserved role, whose descriptor is managed in the Elasticsearch repository ([source link](https://github.com/elastic/elasticsearch/blob/430cde6909eae12e1a90ac2bff29b71cbf4af18b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java#L58)). | ||
The vast majority of features will not require changes to the `kibana_system` user privileges. Changes to these privileges must be carefully considered, as we do not want the `kibana_system` account to have access to user data. | ||
|
||
### Guiding principals | ||
|
||
Consider these guidelines when reviewing changes to the `kibana_system` role descriptor. | ||
|
||
#### 1. Kibana should only access system and hidden indices | ||
|
||
- System indices are managed entirely by the stack, and should never be accessed by end users. | ||
- Hidden indices are _typically_ managed by the stack, but _may_ be accessed by end users. | ||
- Data indices are those which an end user could conceivably create on their own. As a general rule, users can create indices of any pattern so long as it does not begin with a \``.`\` (dot). Users can also create hidden indices, so it is important that documentation exists for any stack-managed hidden indices to reduce the chance of conflict with user-managed indices. | ||
|
||
Therefore, Kibana should not have access to non-system indices which do not begin with a \``.`\` (dot). | ||
|
||
Kibana should also not have the ability to modify system/hidden indices for which it is not the owner. | ||
|
||
##### Examples | ||
| Index Type | Allowed Permissions | Examples | | ||
|-------|--------|----- | ||
| User-defined data index | none | `my-data`, `kibana-metrics` | | ||
| System index not owned by Kibana | `read` | `.security` | | ||
| System indices owned by Kibana | `all` | `.kibana*`, '.fleet*' | | ||
|
||
#### Decision tree | ||
<DocWhimsical id="kibana-system-privilege-decision-tree-VTTGaTtjs9SnpbRNSg2Ptp" title="Decision tree" /> | ||
|
||
##### Exceptions for telemetry | ||
Exceptions to this rule have been made in the past to aid in telemetry collection. This is not something we want to support long-term, but there aren't viable alternatives at the moment without a significant redesign. | ||
|
||
##### Exceptions for Fleet package lifecycle management | ||
Fleet maintains the lifecycle of certain packages. These packages need to be upgraded during stack upgrades, and therefore have to happen in an automated fashion. The `kibana_system` user has elevated privileges to a set of **data incides** to facilitate this. | ||
|
||
If the set of indices managed by Fleet changes, we should ensure that they update [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html) to make note of index naming collisions. | ||
|
||
|
||
#### 2. Kibana should not have the ability to manage security constructs. | ||
|
||
This includes: | ||
- Users | ||
- Roles | ||
- Role Mappings | ||
|
||
### Rationale | ||
|
||
These guidelines exist for two primary reasons. | ||
|
||
#### Reduce impact of account compromise | ||
Compromised `kibana_system` credentials can severely impact an installation. We want to make sure that this doesn't become catastrophic. More privileges == more potential damage. We shouldn't add privileges unnecessarily. We should remove privileges as soon as they aren't needed anymore. | ||
|
||
Credentials can be compromised in a number of ways: | ||
1. Insecure storage (e.g. `kibana.yml`, a post-it note, etc.). | ||
2. Kibana server host compromise. | ||
3. Kibana server runtime compromise (e.g. RCE). | ||
|
||
#### Reduce impact of developer error | ||
Kibana allows engineers to call ES using different sets of credentials: | ||
1. `kibana_system` credentials. | ||
2. End-user credentials. | ||
|
||
An authorization bypass could occur if an engineer accidentally uses the `kibana_system` credentials when they intended to use end-user credentials. See [Broken Access Control](https://owasp.org/Top10/A01_2021-Broken_Access_Control/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const CONTEXT_DEFAULT_SIZE_SETTING = 'context:defaultSize'; | ||
export const CONTEXT_STEP_SETTING = 'context:step'; | ||
export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields'; | ||
export const DEFAULT_COLUMNS_SETTING = 'defaultColumns'; | ||
export const DOC_HIDE_TIME_COLUMN_SETTING = 'doc_table:hideTimeColumn'; | ||
export const DOC_TABLE_LEGACY = 'doc_table:legacy'; | ||
export const ENABLE_SQL = 'discover:enableSql'; | ||
export const FIELDS_LIMIT_SETTING = 'fields:popularLimit'; | ||
export const HIDE_ANNOUNCEMENTS = 'hideAnnouncements'; | ||
export const MAX_DOC_FIELDS_DISPLAYED = 'discover:maxDocFieldsDisplayed'; | ||
export const MODIFY_COLUMNS_ON_SWITCH = 'discover:modifyColumnsOnSwitch'; | ||
export const ROW_HEIGHT_OPTION = 'discover:rowHeightOption'; | ||
export const SAMPLE_ROWS_PER_PAGE_SETTING = 'discover:sampleRowsPerPage'; | ||
export const SAMPLE_SIZE_SETTING = 'discover:sampleSize'; | ||
export const SEARCH_EMBEDDABLE_TYPE = 'search'; | ||
export const SEARCH_FIELDS_FROM_SOURCE = 'discover:searchFieldsFromSource'; | ||
export const SEARCH_ON_PAGE_LOAD_SETTING = 'discover:searchOnPageLoad'; | ||
export const SHOW_FIELD_STATISTICS = 'discover:showFieldStatistics'; | ||
export const SHOW_MULTIFIELDS = 'discover:showMultiFields'; | ||
export const SORT_DEFAULT_ORDER_SETTING = 'discover:sort:defaultOrder'; | ||
export const TRUNCATE_MAX_HEIGHT = 'truncate:maxHeight'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './constants'; | ||
export * from './hooks'; | ||
export * from './utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import dedent from 'dedent'; | ||
import getopts from 'getopts'; | ||
import { ToolingLog } from '@kbn/tooling-log'; | ||
import { getTimeReporter } from '@kbn/ci-stats-reporter'; | ||
|
||
import { Cluster } from '../cluster'; | ||
import { DOCKER_IMG, DOCKER_REPO, DOCKER_TAG } from '../utils'; | ||
import { Command } from './types'; | ||
|
||
export const docker: Command = { | ||
description: 'Run an Elasticsearch Docker image', | ||
usage: 'es docker [<args>]', | ||
help: (defaults: Record<string, any> = {}) => { | ||
const { password } = defaults; | ||
|
||
return dedent` | ||
Options: | ||
--tag Image tag of ES to run from ${DOCKER_REPO} [default: ${DOCKER_TAG}] | ||
--image Full path to image of ES to run, has precedence over tag. [default: ${DOCKER_IMG}] | ||
--password Sets password for elastic user [default: ${password}] | ||
-E Additional key=value settings to pass to Elasticsearch | ||
-D Override Docker command | ||
Examples: | ||
es docker --tag master-SNAPSHOT-amd64 | ||
es docker --image docker.elastic.co/repo:tag | ||
es docker -D 'start es01' | ||
`; | ||
}, | ||
run: async (defaults = {}) => { | ||
const runStartTime = Date.now(); | ||
const log = new ToolingLog({ | ||
level: 'info', | ||
writeTo: process.stdout, | ||
}); | ||
const reportTime = getTimeReporter(log, 'scripts/es docker'); | ||
|
||
const argv = process.argv.slice(2); | ||
const options = getopts(argv, { | ||
alias: { | ||
esArgs: 'E', | ||
dockerCmd: 'D', | ||
}, | ||
|
||
string: ['tag', 'image', 'D'], | ||
|
||
default: defaults, | ||
}); | ||
|
||
const cluster = new Cluster(); | ||
await cluster.runDocker({ | ||
reportTime, | ||
startTime: runStartTime, | ||
...options, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.