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

Allowlist tracestate header on remote server port #112649

Merged

Conversation

n1v0lg
Copy link
Contributor

@n1v0lg n1v0lg commented Sep 9, 2024

The tracestate header is an HTTP header used for distributed tracing; it's a valid header to persist in cross cluster requests and should therefore be allowlisted in the remote server port header check.

Note: due to implementation details, tracestate today may be set on the fulfilling cluster (instead of arriving across the wire) before the header check. Not allowing the header therefore can lead to failures to connect clusters (#112552).

This PR allowlists the header to allow tracing with RCS 2.0.

As a separate follow up, we may furthermore change behavior around sending the header from the query cluster to the fulfilling cluster (which we don't today). This is pending further discussion.

Closes: #112552

@n1v0lg n1v0lg added >bug :Security/Security Security issues without another label labels Sep 9, 2024
@n1v0lg n1v0lg self-assigned this Sep 9, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@n1v0lg n1v0lg added v8.15.2 auto-backport Automatically create backport pull requests when merged labels Sep 9, 2024
import java.util.function.Consumer;

@SuppressForbidden(reason = "Uses an HTTP server for testing")
public class ConsumingTestServer extends ExternalResource {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is largely a duplicate of https://github.com/elastic/elasticsearch/blob/main/test/external-modules/apm-integration/src/javaRestTest/java/org/elasticsearch/test/apmintegration/RecordingApmServer.java -- due to module structure, I could not simply rely on that class though. I can pull this test util class further up where both APM and RCS 2.0 testing have access to it; it's quite trivial though and might need more clean up to make it a generic test util, so opting for test code duplication here.

public static TestRule clusterRule = RuleChain.outerRule(mockApmServer).around(fulfillingCluster).around(queryCluster);

@SuppressWarnings("unchecked")
public void testTracingCrossCluster() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: even though the PR is a fix for the tracestate header I'm not asserting anything specific around tracestate here; the purpose of this test is to exercise and ensure that tracing works with RCS 2.0 end to end without honing in any too many specific details.

(Without the prod code fix in this PR, this test fails with a header check failure, as expected).

@n1v0lg n1v0lg marked this pull request as ready for review September 9, 2024 09:23
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Sep 9, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM

@n1v0lg
Copy link
Contributor Author

n1v0lg commented Sep 10, 2024

@elasticmachine update branch

@n1v0lg n1v0lg added the auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Sep 10, 2024
@n1v0lg
Copy link
Contributor Author

n1v0lg commented Sep 10, 2024

@elasticmachine update branch

@elasticsearchmachine elasticsearchmachine merged commit c2de4b7 into elastic:main Sep 10, 2024
19 of 20 checks passed
@n1v0lg n1v0lg deleted the rcs-allowlist-tracestate-header branch September 10, 2024 13:12
n1v0lg added a commit to n1v0lg/elasticsearch that referenced this pull request Sep 10, 2024
The [`tracestate`
header](https://www.elastic.co/guide/en/apm/agent/rum-js/current/distributed-tracing-guide.html#enable-tracestate)
is an HTTP header used for distributed tracing; it's a valid header to
persist in cross cluster requests and should therefore be allowlisted in
the remote server port header check.

Note: due to implementation details, `tracestate` today may be set on
the fulfilling cluster (instead of arriving across the wire) _before_
the header check. Not allowing the header therefore can lead to failures
to connect clusters
(elastic#112552).

This PR allowlists the header to allow tracing with RCS 2.0.

As a separate follow up, we may furthermore change behavior around
sending the header from the query cluster to the fulfilling cluster
(which we don't today). This is pending further discussion.  

Closes: elastic#112552
elasticsearchmachine pushed a commit that referenced this pull request Sep 11, 2024
The [`tracestate`
header](https://www.elastic.co/guide/en/apm/agent/rum-js/current/distributed-tracing-guide.html#enable-tracestate)
is an HTTP header used for distributed tracing; it's a valid header to
persist in cross cluster requests and should therefore be allowlisted in
the remote server port header check.

Note: due to implementation details, `tracestate` today may be set on
the fulfilling cluster (instead of arriving across the wire) _before_
the header check. Not allowing the header therefore can lead to failures
to connect clusters
(#112552).

This PR allowlists the header to allow tracing with RCS 2.0.

As a separate follow up, we may furthermore change behavior around
sending the header from the query cluster to the fulfilling cluster
(which we don't today). This is pending further discussion.  

Closes: #112552

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
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 auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug :Security/Security Security issues without another label Team:Security Meta label for security team v8.15.2 v8.16.0
Projects
None yet
4 participants