Skip to content

Prevent ThreadContext header leak when sending response #68649

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

Merged
merged 14 commits into from
Apr 13, 2022

Conversation

pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Feb 8, 2021

We need to stash thread context in DefaultRestChannel before we call channel.sendResponse because when calling this method, our execution might be delayed and the thread be reused for another task - like sending another response. And it would see thread context from the initial “delayed” work.

This commit also expands the assertions on the empty thread context to make sure it does not contains response headers.

closes #68278

@pgomulka
Copy link
Contributor Author

pgomulka commented Apr 2, 2021

@elasticmachine update branch

@pgomulka pgomulka self-assigned this May 28, 2021
@pgomulka pgomulka changed the title Thread context response header leak Prevent Thread context header leak when sending response May 28, 2021
@pgomulka pgomulka changed the title Prevent Thread context header leak when sending response Prevent ThreadContext header leak when sending response Jun 21, 2021
@pgomulka
Copy link
Contributor Author

ok to test

@pgomulka
Copy link
Contributor Author

@elasticmachine update branch

@pgomulka
Copy link
Contributor Author

TODO - add those assertions back https://github.com/elastic/elasticsearch/pull/84751/files#r821480480

@pgomulka pgomulka marked this pull request as ready for review April 11, 2022 09:31
@pgomulka pgomulka added :Core/Infra/Core Core issues without another label v8.2.0 v7.17.3 v8.3.0 labels Apr 11, 2022
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Apr 11, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @pgomulka, I've created a changelog YAML for you.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Looks good assuming CI is happy. I left one small request.


public Netty4WriteThrottlingHandler() {}
public Netty4WriteThrottlingHandler(ThreadPool threadPool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather capture just the ThreadContext itself here, not the whole ThreadPool.

@pgomulka pgomulka requested a review from DaveCTurner April 11, 2022 14:36
@pgomulka pgomulka added the auto-backport Automatically create backport pull requests when merged label Apr 11, 2022
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@pgomulka pgomulka merged commit a9e220e into elastic:master Apr 13, 2022
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Apr 13, 2022
We need to stash thread context in DefaultRestChannel before we call channel.sendResponse because when calling this method, our execution might be delayed and the thread be reused for another task - like sending another response. And it would see thread context from the initial “delayed” work.

This commit also expands the assertions on the empty thread context to make sure it does not contains response headers.

closes elastic#68278
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.2
7.17 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 68649

pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Apr 13, 2022
We need to stash thread context in DefaultRestChannel before we call
channel.sendResponse because when calling this method, our execution
might be delayed and the thread be reused for another task - like
sending another response.
And it would see thread context from the initial “delayed” work.

This commit also expands the assertions on the empty thread context
to make sure it does not contains response headers.

closes elastic#68278
pgomulka added a commit that referenced this pull request Apr 13, 2022
…) (#85865)

We need to stash thread context in DefaultRestChannel before we call
channel.sendResponse because when calling this method, our execution
might be delayed and the thread be reused for another task - like
sending another response.
And it would see thread context from the initial “delayed” work.

This commit also expands the assertions on the empty thread context
to make sure it does not contains response headers.

closes #68278
pgomulka added a commit that referenced this pull request Apr 13, 2022
…) (#85860)

We need to stash thread context in DefaultRestChannel before we call
channel.sendResponse because when calling this method, our execution
might be delayed and the thread be reused for another task - like
sending another response.
And it would see thread context from the initial “delayed” work.

This commit also expands the assertions on the empty thread context
to make sure it does not contains response headers.

closes #68278
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Apr 13, 2022
…n/elasticsearch into datastream-reuse-pipeline-source

* 'datastream-reuse-pipeline-source' of github.com:weizijun/elasticsearch: (28 commits)
  Add JDK 19 to Java testing matrix
  [ML] add nlp config update serialization tests (elastic#85867)
  [ML] A text categorization aggregation that works like ML categorization (elastic#80867)
  [ML] Fix serialisation of text embedding updates (elastic#85863)
  TSDB: fix wrong initial value of tsidOrd in TimeSeriesIndexSearcher (elastic#85713)
  Enforce external id uniqueness during DesiredNode construction (elastic#84227)
  Fix Intellij integration (elastic#85866)
  Upgrade Azure SDK to version 12.14.4 (elastic#83884)
  [discovery-gce] Fix initialisation of transport in FIPS mode (elastic#85817)
  Remove unnecessary docs/changelog/85534.yaml
  Prevent ThreadContext header leak when sending response (elastic#68649)
  Add support for impact_areas to health impacts  (elastic#85830)
  Reduce port range re-use in tests (elastic#85777)
  Fix TranslogTests#testStats (elastic#85828)
  Remove hppc from cat allocation api (elastic#85842)
  Fix BuildTests serialization (elastic#85827)
  Use urgent priority for node shutdown cluster state update (elastic#85838)
  Remove Task classes from HLRC (elastic#85835)
  Remove unused migration classes (elastic#85834)
  Remove uses of Charset name parsing (elastic#85795)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >bug :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team v7.17.3 v8.2.0 v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

org.elasticsearch.upgrades.RecoveryIT fails during upgrade tests
4 participants