8000
  • Skip to content

    Conversation

    @giancarloromeo
    Copy link
    Contributor
    @giancarloromeo giancarloromeo commented Nov 14, 2025

    Description

    Celery currently logs the full broker URL—including username and password— inside the DelayedDelivery consumer:

    Setting up delayed delivery for broker `amqp://user:password@host:5672` ...
    

    This leaks credentials in logs and violates standard security guidance (OWASP: no secrets in logs).

    Solution

    Kombu already provides maybe_sanitize_url() for this purpose, but it wasn’t used here.

    Sanitize broker URLs in Celery's delayed delivery debug logs by wrapping
    `connection.as_uri()` with `maybe_sanitize_url()` from Kombu. This prevents
    user:password credentials from being printed in logs, even at DEBUG level.
    
    This improves security and aligns Celery with common logging best practices
    (no secrets in logs). No functional behavior is changed.
    @giancarloromeo giancarloromeo marked this pull request as ready for review November 14, 2025 08:08
    @giancarloromeo giancarloromeo changed the title Sanitize broker URL in delayed delivery debug logs (avoid leaking credentials) Sanitize broker URL in delayed delivery logs (avoid leaking credentials) Nov 14, 2025
    Copy link
    Member
    @Nusnus Nusnus left a comment

    Choose a reason for hiding this comment

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

    Very important fix!! 🚨
    Thank you!

    Is it possible to add a test to avoid future regression?

    @Nusnus Nusnus added this to the 5.6.0 milestone Nov 14, 2025
    @codecov
    Copy link
    codecov bot commented Nov 14, 2025

    Codecov Report

    ✅ All modified and coverable lines are covered by tests.
    ✅ Project coverage is 78.68%. Comparing base (929412e) to head (cf6464d).
    ⚠️ Report is 1 commits behind head on main.

    Additional details and impacted files
    @@           Coverage Diff           @@
    ##             main    #9997   +/-   ##
    =======================================
      Coverage   78.68%   78.68%           
    =======================================
      Files         153      153           
      Lines       19313    19314    +1     
      Branches     2214     2214           
    =======================================
    + Hits        15197    15198    +1     
      Misses       3817     3817           
      Partials      299      299           
    Flag Coverage Δ
    unittests 78.66% <100.00%> (+<0.01%) ⬆️

    Flags with carried forward coverage won't be shown. Click here to find out more.

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    @Nusnus
    Copy link
    Member
    Nusnus commented Nov 14, 2025

    Is it possible to add a test to avoid future regression?

    We can do that in a separate PR

    @Nusnus Nusnus merged commit 30649db into celery:main Nov 14, 2025
    107 checks passed
    @giancarloromeo giancarloromeo deleted the fix/sanitize-delayed-delivery-broker-url branch November 14, 2025 11:34
    github-merge-queue bot pushed a commit to mozilla/experimenter that referenced this pull request Dec 2, 2025
    Bumps [celery](https://github.com/celery/celery) from 5.5.1 to 5.6.0.
    <details>
    <summary>Release notes</summary>
    <p><em>Sourced from <a
    href="https://github.com/celery/celery/releases">celery's
    releases</a>.</em></p>
    <blockquote>
    <h2>v5.6.0</h2>
    <p>Celery v5.6.0 is now available.</p>
    <h2>Key Highlights</h2>
    <p>See <a
    href="https://docs.celeryq.dev/en/stable/history/whatsnew-5.6.html">What's
    new in Celery 5.6</a> for a complete overview or read the main
    highlights below.</p>
    <h3>Python 3.9 Minimum Version</h3>
    <p>Celery 5.6.0 drops support for Python 3.8 (EOL). The minimum required
    Python version is now 3.9. Users still on Python 3.8 must upgrade their
    Python version before upgrading to Celery 5.6.0.</p>
    <p>Additionally, this release includes initial support for Python
    3.14.</p>
    <h3>SQS: Reverted to <code>pycurl</code> from <code>urllib3</code></h3>
    <p>The switch from <code>pycurl</code> to <code>urllib3</code> for the
    SQS transport (introduced in Celery 5.5.0 via Kombu) has been reverted
    due to critical issues affecting SQS users.</p>
    <p>Contributed by <a
    href="https://github.com/auvipy"><code>@​auvipy</code></a> in <a
    href="https://redirect.github.com/celery/celery/pull/9620">celery/celery#9620</a>.</p>
    <h3>Security Fix: Broker Credential Leak Prevention</h3>
    <p>Fixed a security issue where broker URLs containing passwords were
    being logged in plaintext by the delayed delivery mechanism. Broker
    credentials are now properly sanitized in all log output.</p>
    <p>Contributed by <a
    href="https://github.com/giancarloromeo"><code>@​giancarloromeo</code></a>
    in <a
    href="https://redirect.github.com/celery/celery/pull/9997">celery/celery#9997</a>.</p>
    <h3>Memory Leak Fixes</h3>
    <p>Two significant memory leaks have been fixed in this release:</p>
    <p><strong>Exception Handling Memory Leak</strong>: Fixed a critical
    memory leak in task exception handling that was particularly severe on
    Python 3.11+ due to enhanced traceback data. The fix properly breaks
    reference cycles in tracebacks to allow garbage collection.</p>
    <p>Contributed by <a
    href="https://github.com/jaiganeshs21"><code>@​jaiganeshs21</code></a>
    in <a
    href="https://redirect.github.com/celery/celery/pull/9799">celery/celery#9799</a>.</p>
    <p><strong>Pending Result Memory Leak</strong>: Fixed a memory leak
    where <code>AsyncResult</code> subscriptions were not being cleaned up
    when results were forgotten.</p>
    <p>Contributed by <a
    href="https://github.com/tsoos99dev"><code>@​tsoos99dev</code></a> in <a
    href="https://redirect.github.com/celery/celery/pull/9806">celery/celery#9806</a>.</p>
    <h3>ETA Task Memory Limit</h3>
    <p>New configuration option <code>worker_eta_task_limit</code> to
    prevent out-of-memory crashes when workers fetch large numbers of ETA or
    countdown tasks. Previously, workers could exhaust available memory when
    the broker contained many scheduled tasks.</p>
    <p>Example usage:</p>
    <pre lang="python"><code>app.conf.worker_eta_task_limit = 1000
    </code></pre>
    <p>Contributed by <a
    href="https://github.com/sashu2310"><code>@​sashu2310</code></a> in <a
    href="https://redirect.github.com/celery/celery/pull/9853">celery/celery#9853</a>.</p>
    <h3>Queue Type Selection for Auto-created Queues</h3>
    <!-- raw HTML omitted -->
    </blockquote>
    <p>... (truncated)</p>
    </details>
    <details>
    <summary>Changelog</summary>
    <p><em>Sourced from <a
    href="https://github.com/celery/celery/blob/main/Changelog.rst">celery's
    changelog</a>.</em></p>
    <blockquote>
    <h1>5.6.0</h1>
    <p>:release-date: 2025-11-30
    :release-by: Tomer Nosrati</p>
    <p>Celery v5.6.0 is now available.</p>
    <p>Key Highlights</p>
    <pre><code>
    See :ref:`whatsnew-5.6` for a complete overview or read the main
    highlights below.
    <h2>Python 3.9 Minimum Version</h2>
    <p>Celery 5.6.0 drops support for Python 3.8 (EOL). The minimum required
    Python
    version is now 3.9. Users still on Python 3.8 must upgrade their Python
    version
    before upgrading to Celery 5.6.0.</p>
    <p>Additionally, this release includes initial support for Python
    3.14.</p>
    <h2>SQS: Reverted to <code>pycurl</code> from <code>urllib3</code></h2>
    <p>The switch from <code>pycurl</code> to <code>urllib3</code> for the
    SQS transport (introduced in
    Celery 5.5.0 via Kombu) has been reverted due to critical issues
    affecting SQS
    users:</p>
    <ul>
    <li>Processing throughput dropped from ~100 tasks/sec to ~3/sec in some
    environments</li>
    <li><code>UnknownOperationException</code> errors causing container
    crash loops</li>
    <li>Silent message processing failures with no error logs</li>
    </ul>
    <p>Users of the SQS transport must ensure <code>pycurl</code> is
    installed. If you removed
    <code>pycurl</code> after upgrading to Celery 5.5.0, you will need to
    reinstall it.</p>
    <p>Contributed by <code>@auvipy
    &amp;lt;https://github.com/auvipy&amp;gt;</code>_ in
    <code>[#9620](celery/celery#9620)
    &amp;lt;https://github.com/celery/celery/pull/9620&amp;gt;</code>_.</p>
    <h2>Security Fix: Broker Credential Leak Prevention</h2>
    <p>Fixed a security issue where broker URLs containing passwords were
    being logged
    in plaintext by the delayed delivery mechanism. Broker credentials are
    now
    properly sanitized in all log output.</p>
    <p>Contributed by <code>@giancarloromeo
    &amp;lt;https://github.com/giancarloromeo&amp;gt;</code>_ in
    <code>[#9997](celery/celery#9997)
    &amp;lt;https://github.com/celery/celery/pull/9997&amp;gt;</code>_.</p>
    <p>Memory Leak Fixes
    &lt;/tr&gt;&lt;/table&gt;
    </code></pre></p>
    </blockquote>
    <p>... (truncated)</p>
    </details>
    <details>
    <summary>Commits</summary>
    <ul>
    <li><a
    href="https://github.com/celery/celery/commit/cca11164860a1bee6ad8626c27a683b482f741eb"><code>cca1116</code></a>
    Prepare for release: v5.6.0 (<a
    href="https://redirect.github.com/celery/celery/issues/10010">#10010</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/1133f22181bb22223d39c0060973695c6af55643"><code>1133f22</code></a>
    Bump mypy from 1.14.1 to 1.19.0 (<a
    href="https://redirect.github.com/celery/celery/issues/10008">#10008</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/0932d2c06e001903b90638f7c40a14f5407c9801"><code>0932d2c</code></a>
    [pre-commit.ci] pre-commit autoupdate (<a
    href="https://redirect.github.com/celery/celery/issues/10007">#10007</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/b446910f18860531b089d6c39f974265cc24a589"><code>b446910</code></a>
    Prepare for (pre) release: v5.6.0rc2 (<a
    href="https://redirect.github.com/celery/celery/issues/10005">#10005</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/3f0f0fe7ea6a67a696d0a750644b552559ae368e"><code>3f0f0fe</code></a>
    asynpool: Don't return from inside a finally block (<a
    href="https://redirect.github.com/celery/celery/issues/10000">#10000</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/95d05527c0e1fff5c1a38877ba87592983a7f993"><code>95d0552</code></a>
    Bump actions/checkout from 5 to 6 (<a
    href="https://redirect.github.com/celery/celery/issues/10003">#10003</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/f32b92f0e481601e9cc9f1212a4feced3f48e1a0"><code>f32b92f</code></a>
    Add Py39-314t to CI (<a
    href="https://redirect.github.com/celery/celery/issues/9999">#9999</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/63c1910221d9fb8c1931ff62c80c4c37232b2d58"><code>63c1910</code></a>
    Don't fail task on timeout during cold shutdown (<a
    href="https://redirect.github.com/celery/celery/issues/9678">#9678</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/30649dbd41308fc8eef79b2aae179a908eaa7a51"><code>30649db</code></a>
    Fix log leaking broker credentials (<a
    href="https://redirect.github.com/celery/celery/issues/9997">#9997</a>)</li>
    <li><a
    href="https://github.com/celery/celery/commit/929412e2d4d328e337be3f177ca99fff10ab9bdc"><code>929412e</code></a>
    Remove Python 4.0 version condition for pytest dependencies (<a
    href="https://redirect.github.com/celery/celery/issues/9993">#9993</a>)</li>
    <li>Additional commits viewable in <a
    href="https://github.com/celery/celery/compare/v5.5.1...v5.6.0">compare
    view</a></li>
    </ul>
    </details>
    <br />
    
    
    [![Dependabot compatibility
    score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=celery&package-manager=pip&previous-version=5.5.1&new-version=5.6.0)](https://docs.gi
    7F90
    thub.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
    
    Dependabot will resolve any conflicts with this PR as long as you don't
    alter it yourself. You can also trigger a rebase manually by commenting
    `@dependabot rebase`.
    
    [//]: # (dependabot-automerge-start)
    [//]: # (dependabot-automerge-end)
    
    ---
    
    <details>
    <summary>Dependabot commands and options</summary>
    <br />
    
    You can trigger Dependabot actions by commenting on this PR:
    - `@dependabot rebase` will rebase this PR
    - `@dependabot recreate` will recreate this PR, overwriting any edits
    that have been made to it
    - `@dependabot merge` will merge this PR after your CI passes on it
    - `@dependabot squash and merge` will squash and merge this PR after
    your CI passes on it
    - `@dependabot cancel merge` will cancel a previously requested merge
    and block automerging
    - `@dependabot reopen` will reopen this PR if it is closed
    - `@dependabot close` will close this PR and stop Dependabot recreating
    it. You can achieve the same result by closing it manually
    - `@dependabot show <dependency name> ignore conditions` will show all
    of the ignore conditions of the specified dependency
    - `@dependabot ignore this major version` will close this PR and stop
    Dependabot creating any more for this major version (unless you reopen
    the PR or upgrade to it yourself)
    - `@dependabot ignore this minor version` will close this PR and stop
    Dependabot creating any more for this minor version (unless you reopen
    the PR or upgrade to it yourself)
    - `@dependabot ignore this dependency` will close this PR and stop
    Dependabot creating any more for this dependency (unless you reopen the
    PR or upgrade to it yourself)
    
    
    </details>
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@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.

    2 participants

    0