Skip to content

security: PyMongo errors can quote URI parts #701

Closed

Description

@uniqueg

PyMongo's own exceptions can quote parts of a malformed connection string, e.g., InvalidURI: Bad database name "...". FOCA creates its client in foca/database/register_mongodb.py and doesn't catch these errors, so they can reach a startup traceback. If the URI is broken in a way that puts a credential in the quoted part, that credential can appear in the logs.

The risk is limited: it takes a broken URI and access to the logs. It isn't new, and it is separate from the log line of new clients, which #691 fixed (that line runs only after the client was created).

To think through

Catching these errors and replacing their messages would also hide useful messages, e.g., about wrong options, which operators need when they fix a config. Options to weigh:

  • Replace the message only for errors from parsing the URI, not for those about options, and suppress the chain (raise ... from None).
  • Redact the known password of the URI in the message, where it can still be told apart in a broken URI.
  • Leave the behaviour and document it.

Acceptance criteria

  • A decision on one of these, with reasons.
  • If the behaviour changes: tests with malformed URIs holding credentials, and with wrong options, whose messages stay useful; docs updated.

Activity

  1. added
    priority: low
    status: triage
    type: security
    workload: hours
    on Nov 5, 2026
  2. added this to the v0.22.0 milestone on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: lowstatus: triagetype: securityworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions