Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[edited] Calls to Kibana internal APIs require an internal product header #152287

Closed
TinaHeiligers opened this issue Feb 27, 2023 · 12 comments
Closed
Assignees
Labels
Feature:http Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@TinaHeiligers
Copy link
Contributor

TinaHeiligers commented Feb 27, 2023

Kibana's HTTP service is restricting access to all internal API's for serverless in #151940.
We'll enforce this through config with a server.restrictInternalApis: <boolean> that defaults to false in any other mode.

Calling all plugin authors!

Requests to internal APIs will throw if a request doesn't include the x-elastic-internal-product: Kibana header and we need your help!

If you're using core's browser-side HTTP service (e.g. core.http.fetch('....')), you don't need to do anything, you may stop reading and move on with your day 😄

If your plugin and services use any custom way of making browser-side calls (e.g. axios), you'll need to add the header to requests made to Kibana APIs.

We've already handled bfetch:

See implementation
//src/plugins/bfetch/public/plugin.ts
private fetchStreaming =
  (
    version: string,
    basePath: string,
    getIsCompressionDisabled: () => boolean
  ): BfetchPublicSetup['fetchStreaming'] =>
  (params) =>
    fetchStreamingStatic({
      ...params,
      url: `${basePath}/${removeLeadingSlash(params.url)}`,
      headers: {
        'Content-Type': 'application/json',
        'kbn-version': version,
        [INTERNAL_ACCESS_REQUEST]: 'Kibana', <--- HERE
        ...(params.headers || {}),
      },
      getIsCompressionDisabled,
    });

The restriction is only applied to internal APIs. However, we recommend implementing the header now to all APIs, especially if you plan to change them to internal.

Calling all stack consumers of Kibana APIs!

Stack components consuming internal Kibana APIs need to ensure requests to those contain the x-elastic-product-origin header. The header is required for calls to internal Kibana APIs. We recommend sending the header with any call to Kibana APIs.

Target dates (everyone):

May 23, 2023
Acknowledge awareness of the change.

June 1, 2023
Audit: Identify usage of internal Kibana APIs that are missing the product origin header:

July 3, 2023 (provisional)
Enable protection by default in Serverless

Stack components

Team Acknowledged (target: May 23, 2023) Audit (target: June 1, 2023) Work to be done (N/A if not applicable) Issue link (if applicable)
#platform-deployment-management ✅ (deadline extended to June 4, as agreed) N/A N/A
#synthetics-user_experience-uptime N/A N/A
#security-integration-asset-management N/A N/A
#apm-ui N/A N/A
#ent-search-application N/A N/A N/A
#stack-monitoring N/A N/A
#fleet N/A N/A
@TinaHeiligers TinaHeiligers added Feature:http Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Feb 27, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@TinaHeiligers TinaHeiligers self-assigned this May 18, 2023
@TinaHeiligers TinaHeiligers changed the title Browser-side code not using Core's http service need to send the correct header. [edited] Calls to Kibana internal APIs require an internal product header May 24, 2023
@TinaHeiligers
Copy link
Contributor Author

@elastic/enterprise-search @apm we're past the acknowledgment due date. Are you aware of the restrictions?

@jimczi
Copy link

jimczi commented May 24, 2023

Thanks for the ping @TinaHeiligers , we're aware of the restriction and we'll apply the new header where appropriate.

@apm
Copy link

apm commented May 24, 2023

@TinaHeiligers @apm is my username. I don't have anything to do with the package.

@afharo
Copy link
Member

afharo commented May 25, 2023

cc @elastic/apm

@miltonhultgren
Copy link
Contributor

miltonhultgren commented May 25, 2023

@TinaHeiligers Sorry, this fell through the cracks!

The Stack Monitoring plugin code uses core.http.fetch and does not call any /internal APIs.

@TinaHeiligers
Copy link
Contributor Author

@miltonhultgren, you're all set then. Nothing for your team todo.

@gbamparop
Copy link
Contributor

@apm we're past the acknowledgment due date. Are you aware of the restrictions?

We're using core's APIs and it seems that the headers are being correctly set, I have updated the description accordingly cc @sqren

For future reference the team's tag is elastic/apm-ui

@TinaHeiligers
Copy link
Contributor Author

Thanks @gbamparop!

@juliaElastic
Copy link
Contributor

Hi, I had a check in Fleet plugin, and we are only using core.http to query kibana, we are not calling /internal APIs with fetch/axios.

@yuliacech
Copy link
Contributor

Hi @TinaHeiligers, I did an audit for the Deployment Management team plugins and haven't found any custom API calls. I don't think any work is needed on our side.

@TinaHeiligers
Copy link
Contributor Author

All teams have reported back with their Audit results and are compliant. Nothing more to track here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:http Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

9 participants