Skip to content

Redact credentials from upstream proxy success messages #22

Description

@MatousMarik

Problem

Two tools echo the upstream proxy URL back verbatim:

// src/tools/upstream.ts:25
message: `Global upstream set to ${proxy_url}`,
// src/tools/upstream.ts:71
message: `Upstream for '${hostname}' set to ${proxy_url}`,

Upstream URLs routinely carry credentials — both tool descriptions advertise
socks5://user:pass@host:port. MCP tool results are persisted in the client
transcript, so each call writes the upstream password into the conversation log
a second time, on top of the call arguments.

proxy_mobile_setup also accepts upstream_proxy_url but reports only
upstream_set: <boolean>, so it is already fine.

Acceptance criteria

  • Both success messages redact the password while keeping scheme, username,
    host, port and path visible:
    Global upstream set to http://groups-RESIDENTIAL,country-US:***@proxy.apify.com:8000
  • The username is deliberately preserved. For several providers the username
    field is configuration rather than a secret — with Apify Proxy it encodes
    proxy group, country and sticky-session id — and it is what makes the
    confirmation message worth printing. Only the password is replaced.
  • A URL with no password is unchanged.
  • A URL that fails to parse is reported as <unparseable url> or similar, never
    echoed verbatim as a fallback.
  • Redaction lives in a pure exported function in src/utils.ts, covered in
    test/unit/utils.test.ts, with cases for: user+password, username only,
    no userinfo, empty password (user:@host), percent-encoded credentials,
    a socks5:// URL, a pac+http:// URL, and an unparseable string.
  • Add no runtime dependency. new URL() handles every scheme in use here,
    including socks5://, pac+http://, and usernames containing commas.

Verification

npm run build && npm run test:unit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions