Skip to content

HIVE-29653: Fix SAML bearer token authentication bypass in HiveServer2#6534

Open
saihemanth-cloudera wants to merge 3 commits into
apache:masterfrom
saihemanth-cloudera:HIVE-29653
Open

HIVE-29653: Fix SAML bearer token authentication bypass in HiveServer2#6534
saihemanth-cloudera wants to merge 3 commits into
apache:masterfrom
saihemanth-cloudera:HIVE-29653

Conversation

@saihemanth-cloudera

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Hardens SAML callback token handling in HiveServer2 HTTP mode and adds related tests.

Why are the changes needed?

Corrects token validation behavior in the SAML HTTP authentication path.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added few unit tests

@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens HiveServer2’s SAML HTTP bearer-token authentication flow to prevent validation bypasses, and adds test coverage to ensure invalid/forged tokens are rejected.

Changes:

  • Decode the SAML bearer token before parsing it for relay-state/client-identifier validation in HS2 HTTP mode.
  • Fix signature verification logic so that valid signatures are accepted and invalid signatures are rejected.
  • Improve token parsing robustness by allowing = padding in the signature field, and add focused unit tests for token validation/parsing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpServlet.java Decodes bearer token prior to parsing so relay-state/client-identifier validation cannot be bypassed.
service/src/java/org/apache/hive/service/auth/saml/HiveSamlAuthTokenGenerator.java Corrects signature comparison logic and improves parsing to handle Base64 padding in values.
itests/hive-unit/src/test/java/org/apache/hive/service/auth/saml/TestHttpSamlAuthentication.java Adds unit tests covering valid round-trip, forged signatures, malformed structure, expiry, and parsing edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpServlet.java Outdated
@dengzhhu653

Copy link
Copy Markdown
Member

+1. Leave the Copilot's comment to you if we need to address them.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants