Skip to content

[SPARK-54293][SQL] Make ThriftHttpCLIService SNI host check configurable#55308

Closed
yadavay-amzn wants to merge 4 commits into
apache:masterfrom
yadavay-amzn:fix/SPARK-54293-sni-host-check
Closed

[SPARK-54293][SQL] Make ThriftHttpCLIService SNI host check configurable#55308
yadavay-amzn wants to merge 4 commits into
apache:masterfrom
yadavay-amzn:fix/SPARK-54293-sni-host-check

Conversation

@yadavay-amzn

@yadavay-amzn yadavay-amzn commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Make the SNI host check in ThriftHttpCLIService configurable via spark.sql.hive.thriftServer.http.sniHostCheckEnabled, following the same pattern as SPARK-56528 which made it configurable for the Spark UI.

Why are the changes needed?

SPARK-45522 (Jetty 10+ upgrade) silently enabled SNI host checking, which causes HTTPS connection failures when the certificate CN does not match the hostname. This was made configurable in the Spark UI server (SPARK-56528) but ThriftHttpCLIService had no way to disable it.

This PR adds the same configurability: default true (preserving the current SPARK-45522 behavior), with the option to set false to restore pre-SPARK-45522 behavior.

Does this PR introduce any user-facing change?

A new internal configuration spark.sql.hive.thriftServer.http.sniHostCheckEnabled (default: true) is added. Users who need to disable SNI host checking can set it to false.

How was this patch tested?

Added ThriftHttpCLIServiceSuite with 3 tests:

  • SNI host check enabled by default
  • SNI host check disabled when configured
  • Jetty 10+ default behavior verification

Was this patch authored or co-authored using generative AI tooling?

Yes

@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-54293-sni-host-check branch 2 times, most recently from 1a3a880 to 1f7e24c Compare April 27, 2026 22:35
@yadavay-amzn

Copy link
Copy Markdown
Contributor Author

@LuciferYang Could you take a look when you get a chance? Thanks!

Arrays.toString(sslContextFactoryServer.getExcludeProtocols()));
sslContextFactoryServer.setKeyStorePath(keyStorePath);
sslContextFactoryServer.setKeyStorePassword(keyStorePassword);
// SPARK-54293: Disable SNI host check, which defaults to true since Jetty 10.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also cc @pan3793

@pan3793

pan3793 commented May 5, 2026

Copy link
Copy Markdown
Member

can we follow SPARK-56528 (#55396) to make it configurable?

yadavay-amzn added a commit to yadavay-amzn/spark that referenced this pull request May 6, 2026
Address review feedback from @pan3793 (PR apache#55308): follow the pattern
established in SPARK-56528 and make the SNI host check configurable
rather than unconditionally disabled.

Introduces spark.sql.hive.thriftServer.http.sniHostCheckEnabled
(default: false, preserving the behavior from the first commit on
this branch). Operators who want stricter host checking for security
can opt in by setting the flag to true.
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-54293-sni-host-check branch 2 times, most recently from 63c708a to 2a05403 Compare May 11, 2026 07:05
yadavay-amzn added a commit to yadavay-amzn/spark that referenced this pull request May 11, 2026
Address review feedback from @pan3793 (PR apache#55308): follow the pattern
established in SPARK-56528 and make the SNI host check configurable
rather than unconditionally disabled.

Introduces spark.sql.hive.thriftServer.http.sniHostCheckEnabled
(default: false, preserving the behavior from the first commit on
this branch). Operators who want stricter host checking for security
can opt in by setting the flag to true.
@yadavay-amzn

Copy link
Copy Markdown
Contributor Author

Done — updated to follow the SPARK-56528 pattern. Added spark.sql.hive.thriftServer.http.sniHostCheckEnabled (default: false) so it's configurable rather than unconditionally disabled.

"connector. Since SPARK-45522 (Jetty 10+), Spark has disabled SNI host check to " +
"preserve backward compatibility. Set to true to enforce SNI host checking for " +
"stricter security. See SPARK-54293.")
.version("4.2.0")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code change lgtm, this requires a PMC member to justify whether to include this in 4.2 as a late-arriving feature.

yadavay-amzn added a commit to yadavay-amzn/spark that referenced this pull request May 11, 2026
Address review feedback from @pan3793 (PR apache#55308): follow the pattern
established in SPARK-56528 and make the SNI host check configurable
rather than unconditionally disabled.

Introduces spark.sql.hive.thriftServer.http.sniHostCheckEnabled
(default: false, preserving the behavior from the first commit on
this branch). Operators who want stricter host checking for security
can opt in by setting the flag to true.
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-54293-sni-host-check branch from 2a05403 to b648511 Compare May 11, 2026 18:04
@yadavay-amzn

Copy link
Copy Markdown
Contributor Author

Updated .version("4.2.0") to .version("5.0.0") — happy for this to land in the next release rather than 4.2.

@yadavay-amzn

yadavay-amzn commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@pan3793 Gentle reminder, could you please take a look when you get a chance and see if this PR is ready to merge?
Previous CI failure was unrelated, I've rebased to re-trigger it. Please let me know if there is anything else needed.
Thanks!

Disable SNI host check in ThriftHttpCLIService's Jetty SSL connector,
consistent with the fix applied to JettyUtils.scala in SPARK-45522.

Since Jetty 10, SniHostCheck defaults to true. This was fixed in the
Spark UI server but not in ThriftHttpCLIService, which also creates a
Jetty server with SSL support.

Note: RestSubmissionServer (also mentioned in the JIRA) does not have
SSL support, so it does not need this fix.
yadavay-amzn added a commit to yadavay-amzn/spark that referenced this pull request May 18, 2026
Address review feedback from @pan3793 (PR apache#55308): follow the pattern
established in SPARK-56528 and make the SNI host check configurable
rather than unconditionally disabled.

Introduces spark.sql.hive.thriftServer.http.sniHostCheckEnabled
(default: false, preserving the behavior from the first commit on
this branch). Operators who want stricter host checking for security
can opt in by setting the flag to true.
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-54293-sni-host-check branch from b648511 to 8b88fe0 Compare May 18, 2026 16:52
Comment on lines +131 to +132
"stricter security. See SPARK-54293.")
.version("5.0.0")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as default value does not change the current behavior, we can deliver this in 4.3.0. and it's not necessary to mention which JIRA ticket added the config in doc.

Suggested change
"stricter security. See SPARK-54293.")
.version("5.0.0")
"stricter security.")
.version("4.3.0")

Address review feedback from @pan3793 (PR apache#55308): follow the pattern
established in SPARK-56528 and make the SNI host check configurable
rather than unconditionally disabled.

Introduces spark.sql.hive.thriftServer.http.sniHostCheckEnabled
(default: false, preserving the behavior from the first commit on
this branch). Operators who want stricter host checking for security
can opt in by setting the flag to true.
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-54293-sni-host-check branch from 8b88fe0 to 49892b4 Compare May 18, 2026 17:25
@yadavay-amzn

yadavay-amzn commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Done, removed JIRA references from the doc string and updated version to 4.3.0. Thanks @pan3793!

Comment thread sql/catalyst/src/main/scala/org/apache/spark/sql/internal/StaticSQLConf.scala Outdated
@pan3793

pan3793 commented May 18, 2026

Copy link
Copy Markdown
Member

PR title needs to be updated.

@yadavay-amzn yadavay-amzn changed the title [SPARK-54293][SQL] Disable SNI host check in ThriftHttpCLIService [SPARK-54293][SQL] Make ThriftHttpCLIService SNI host check configurable May 18, 2026
@yadavay-amzn

Copy link
Copy Markdown
Contributor Author

@pan3793 Sorry for not applying the recommended change as is earlier, I used the apply suggestion button this time to do so.
Also changed the code comments to reflect the default behavior, updated PR title as well. Thanks!

@pan3793 pan3793 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, will leave this open for another one day before merging.

@pan3793 pan3793 closed this in fa1373e May 21, 2026
pan3793 pushed a commit that referenced this pull request May 21, 2026
### What changes were proposed in this pull request?

Make the SNI host check in `ThriftHttpCLIService` configurable via `spark.sql.hive.thriftServer.http.sniHostCheckEnabled`, following the same pattern as SPARK-56528 which made it configurable for the Spark UI.

### Why are the changes needed?

SPARK-45522 (Jetty 10+ upgrade) silently enabled SNI host checking, which causes HTTPS connection failures when the certificate CN does not match the hostname. This was made configurable in the Spark UI server (SPARK-56528) but `ThriftHttpCLIService` had no way to disable it.

This PR adds the same configurability: default `true` (preserving the current SPARK-45522 behavior), with the option to set `false` to restore pre-SPARK-45522 behavior.

### Does this PR introduce _any_ user-facing change?

A new internal configuration `spark.sql.hive.thriftServer.http.sniHostCheckEnabled` (default: `true`) is added. Users who need to disable SNI host checking can set it to `false`.

### How was this patch tested?

Added `ThriftHttpCLIServiceSuite` with 3 tests:
- SNI host check enabled by default
- SNI host check disabled when configured
- Jetty 10+ default behavior verification

### Was this patch authored or co-authored using generative AI tooling?

Yes

Closes #55308 from yadavay-amzn/fix/SPARK-54293-sni-host-check.

Authored-by: Anupam Yadav <anupamya@amazon.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
(cherry picked from commit fa1373e)
Signed-off-by: Cheng Pan <chengpan@apache.org>
@pan3793

pan3793 commented May 21, 2026

Copy link
Copy Markdown
Member

thanks, merged to master/4.x

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants