forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
security: patch request for CVE-2023-28155
GHSA-p8p7-x288-28g6 Ported from request/request#3444
- Loading branch information
Showing
3 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
diff --git a/lib/redirect.js b/lib/redirect.js | ||
index b9150e77c73d63367845c0aec15b5684d900943f..2864f9f2abc481ecf2b2dd96b1293f5b93393efd 100644 | ||
--- a/lib/redirect.js | ||
+++ b/lib/redirect.js | ||
@@ -14,6 +14,7 @@ function Redirect (request) { | ||
this.redirects = [] | ||
this.redirectsFollowed = 0 | ||
this.removeRefererHeader = false | ||
+ this.allowInsecureRedirect = false | ||
} | ||
|
||
Redirect.prototype.onRequest = function (options) { | ||
@@ -40,6 +41,9 @@ Redirect.prototype.onRequest = function (options) { | ||
if (options.followOriginalHttpMethod !== undefined) { | ||
self.followOriginalHttpMethod = options.followOriginalHttpMethod | ||
} | ||
+ if (options.allowInsecureRedirect !== undefined) { | ||
+ self.allowInsecureRedirect = options.allowInsecureRedirect | ||
+ } | ||
} | ||
|
||
Redirect.prototype.redirectTo = function (response) { | ||
@@ -108,7 +112,7 @@ Redirect.prototype.onResponse = function (response) { | ||
request.uri = url.parse(redirectTo) | ||
|
||
// handle the case where we change protocol from https to http or vice versa | ||
- if (request.uri.protocol !== uriPrev.protocol) { | ||
+ if (request.uri.protocol !== uriPrev.protocol && self.allowInsecureRedirect) { | ||
delete request.agent | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters