Skip to content

fix: limit webRequest redirects across loader restarts to avoid crashes - #55654

Merged
jkleinsc merged 1 commit into
46-x-yfrom
trop/46-x-y-bp-fix-limit-webrequest-redirects-across-loader-restarts-to-avoid-crashes-1793986808503
Nov 6, 2026
Merged

jkleinsc merged 1 commit into
46-x-yfrom
trop/46-x-y-bp-fix-limit-webrequest-redirects-across-loader-restarts-to-avoid-crashes-1793986808503

Conversation

@trop

@trop trop Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Backport of #55623

See that PR for details.

Notes: Fixed renderer crashes caused by unbounded webRequest redirect loops.

Keep a per-request redirect count across target loader restarts.
Reject redirects beyond Chromium's limit with ERR_TOO_MANY_REDIRECTS.

Co-authored-by: yangzuohui <65477566+zuohuiyang@users.noreply.github.com>
@trop trop Bot added 46-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Nov 6, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. This is a small backport that adds a per-request redirect cap and a matching test. I reviewed it from a standalone clone, so I couldn't see the upstream code, and I found nothing to flag.

What was reviewed:

  • ContinueToBeforeRedirect in shell/browser/net/proxying_url_loader_factory.cc is reached by all three redirect paths: a network redirect, a redirect from the header client's override headers, and a redirectURL from onBeforeRequest. So the new counter, which lives on InProgressRequest, keeps counting when the target loader restarts.
  • On the 21st redirect, OnRequestError handles the failure cleanly. It reports to the target client, fires onErrorOccurred and removes the request. The early return stops anything from touching the deleted object.
  • The new spec puts no expect() calls inside listeners, which follows spec/CLAUDE.md. The onBeforeRequest handler is cleared by the existing afterEach in that describe block, and the 21 calls / 20 redirects it expects match the off-by-one in the check.
Extended reasoning...

The change adds a 7-line redirect counter in Electron's webRequest proxying URL loader, a header field and one new spec. No CODEOWNERS entry covers these files. It narrows the network-interception path instead of widening it, and touches no auth, IPC or renderer-input handling. I approved because the fix is small and self-contained and is a bot backport with a deterministic regression test. The timeline shows no open reviewer objections. The value of net::URLRequest::kMaxRedirects comes from upstream Chromium code that this checkout doesn't include, but the test's expected counts pin it to 20.

@jkleinsc
jkleinsc merged commit 40ac6da into 46-x-y Nov 6, 2026
91 checks passed
@jkleinsc
jkleinsc deleted the trop/46-x-y-bp-fix-limit-webrequest-redirects-across-loader-restarts-to-avoid-crashes-1793986808503 branch November 6, 2026 19:05
@release-clerk

release-clerk Bot commented Nov 6, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed renderer crashes caused by unbounded webRequest redirect loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants