← Back to Pull requests

Mask URL-encoded connection password in task SDK #74618

Open
Rishavbhattarai opened this pull request with 54 lines diff across 5 files
View on GitHub
Rishavbhattarai Rishavbhattarai commented on Oct 12, 2026 22:22 UTC
Author

Connections supplied as URIs (e.g. AIRFLOW_CONN_AZURE_DEFAULT) carry the password percent-encoded. The task SDK only masked the decoded password, so a secret containing special characters leaked in its encoded form (e.g. via printenv in a BashOperator). The core Connection model already masks quote(password); the task SDK paths did not.

  • Mask quote(password, safe="") in _mask_connection_secrets, _amask_connection_secrets and handle_get_connection.

  • Use safe="" in the core model too, to match Connection.get_uri (default quote leaves / unencoded).

  • Add a regression test.
  • closes: #38144

    ---

    ##### Was generative AI tooling used to co-author this PR?

  • [X] Yes (Claude Code)
  • Generated-by: Claude Code following the guidelines

    Diff: 54 lines (+51 / -3) across 5 files Reviewer: ashb Review duration: 73592m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.45) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 54 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.61 · 4 substantive comment(s)
    0.61
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    68%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.240
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    5 items
    boring-cyborg[bot] boring-cyborg[bot] commented on Oct 12, 2026 22:22 UTC
    Bot

    Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
    Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.

  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.

  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.

  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.

  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.

  • Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).

  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.

  • Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

    Rishavbhattarai Rishavbhattarai commented on Oct 13, 2026 06:18 UTC
    Author

    Thanks for the review.

  • Added regression tests for _amask_connection_secrets and handle_get_connection. I checked that all three tests (sync, async, handler) fail without the fix.

  • On quote_plus: Airflow itself only encodes the password with quote(..., safe="") (Connection.get_uri in both core and the SDK), so a space becomes %20, never +. Parsing uses unquote, not unquote_plus, so a literal + in a URI is already the decoded password and is masked as-is. I didn't find a path that emits the quote_plus form.
  • 🤖 Generated with Claude Code

    Rishavbhattarai Rishavbhattarai commented on Nov 18, 2026 07:50 UTC
    Author

    @amoghrajesh could you take a look when you have a moment? I addressed the review from @developer-rpai: the async masking path and handle_get_connection now have regression tests, and all three fail without the fix. The CI workflows are still waiting on approval since this is my first PR here. Happy to change anything.

    developer-rpai developer-rpai commented on Nov 20, 2026 07:19 UTC
    Contributor

    Thanks @Rishavbhattarai, the async and handle_get_connection tests cover what I was after, and the quote_plus answer makes sense since get_uri only ever uses quote with safe="". LGTM from my side.

    Reviewers
    Assignees
    Rishavbhattarai Rishavbhattarai
    Labels
    risk: low confidence: 68.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 68.4% · Lower = rushed or shallow review
    68.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.2% · Safe to merge
    14.2%
    Repository