Skip to content

fix(net-policy): nested sensitive query parameters bypass redaction in redactSensitiveUrlLikeString #102932

Description

@aniruddhaadak80

Description

In packages/net-policy/src/redact-sensitive-url.ts, the fallback URL query parameter redactor in redactSensitiveUrlLikeString matches parameters using a regular expression:

  const redactedFallback = value
    .replace(/\/\/([^@/?#\s]+)@/g, "//***:***@")
    .replace(/([?&])([^=&]+)=([^&]*)/g, (match, prefix: string, key: string) =>
      isSensitiveUrlQueryParamName(key) ? `${prefix}${key}=***` : match,
    );

The regex /([?&])([^=&]+)=([^&]*)/g splits parameters by &. However, if a query parameter contains a nested URL as its value (e.g. ?redirect_url=https://example.com/login?token=secret), the regex matches ?redirect_url=https://example.com/login?token=secret.
Because redirect_url is not classified as a sensitive parameter name, the callback returns the entire matched substring untouched.

Impact

The nested parameter token=secret completely escapes redaction and is leaked into logs, creating a serious security issue when URLs are passed as arguments to redirect/auth paths.

Suggested Fix

Perform nested parameter parsing or recursively scan query parameter values for nested query structures to ensure all layers of parameter lists are redacted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions