Skip to content

fix(dbapi): require TLS when Authorization header is passed over HTTP - #653

Open
Shahzeb-DataEngineer wants to merge 1 commit into
trinodb:masterfrom
Shahzeb-DataEngineer:fix/auth-header-over-http
Open

Shahzeb-DataEngineer wants to merge 1 commit into
trinodb:masterfrom
Shahzeb-DataEngineer:fix/auth-header-over-http

Conversation

@Shahzeb-DataEngineer

Copy link
Copy Markdown

Description

The TLS-required check in Connection.__init__ only looked at the auth object, so credentials supplied as an Authorization header via http_headers or via http_session.headers were sent in cleartext over HTTP before the server could reject them. This extends the check to those header paths (case-insensitive), still honouring the allow_insecure_auth opt-out.

Test plan

  • New unit tests in tests/unit/test_dbapi.py: Authorization header via http_session, via http_headers, lowercase authorization key, plus no-error cases for HTTPS, allow_insecure_auth=True, and a session with only a non-auth header.
  • pytest tests/unit/test_dbapi.py -k auth: 10 passed. Full file: 43 passed; the 5 failures (test_token_retrieved_once_* x3, test_cursor_close_* x2) are pre-existing on pristine main (verified via git stash).
  • flake8 trino/dbapi.py tests/unit/test_dbapi.py clean.

Related Issue

closes #642

The TLS-required check in Connection.__init__ only looked at the auth
object, so credentials supplied as an Authorization header via
http_headers or http_session.headers were sent in cleartext over HTTP
before the server could reject them. Extend the check to those header
paths (case-insensitive), still honouring allow_insecure_auth.

Add unit tests for both header paths plus the HTTPS, opt-out and
no-header cases.

Closes trinodb#642

Signed-off-by: Shahzeb Ali <126076773+Shahzeb-DataEngineer@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 04:54
@cla-bot

cla-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

TLS-required check for authentication does not cover Authorization headers passed via http_session / http_headers

2 participants