-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge keyring version #322
Conversation
…t into feat/merge-all
throw new Error("origin unmatched"); | ||
} | ||
|
||
window.location.replace(origin); |
Check warning
Code scanning / CodeQL
Client-side URL redirect Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 days ago
To fix the problem, we need to ensure that the origin
parameter is validated against a list of authorized URLs before performing the redirect. This can be achieved by maintaining a list of trusted URLs and checking if the origin
parameter matches any of these URLs. If it does not match, the redirect should not be performed.
- Create a list of authorized URLs.
- Check if the
origin
parameter is in the list of authorized URLs before performing the redirect. - If the
origin
parameter is not in the list, do not perform the redirect and show an appropriate error message.
-
Copy modified lines R77-R82 -
Copy modified lines R96-R97
@@ -76,2 +76,8 @@ | ||
|
||
const authorizedUrls = [ | ||
"https://trusted-site1.com", | ||
"https://trusted-site2.com", | ||
// Add more trusted URLs here | ||
]; | ||
|
||
export const BlocklistPage: FunctionComponent = () => { | ||
@@ -89,5 +95,4 @@ | ||
// Validate url | ||
const url = new URL(origin); | ||
if (redirectUrl.origin !== url.origin) { | ||
throw new Error("origin unmatched"); | ||
if (!authorizedUrls.includes(origin)) { | ||
throw new Error("Unauthorized origin"); | ||
} |
throw new Error("origin unmatched"); | ||
} | ||
|
||
window.location.replace(origin); |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 days ago
To fix the problem, we need to ensure that the origin
value is properly sanitized before it is used in the URL redirection. One way to achieve this is by using a library like DOMPurify
to sanitize the origin
value. This will help prevent any malicious scripts from being executed.
- Install the
DOMPurify
library. - Import
DOMPurify
in the file. - Use
DOMPurify
to sanitize theorigin
value before using it in the URL redirection.
-
Copy modified line R7 -
Copy modified line R80
@@ -6,2 +6,3 @@ | ||
import { AppThemeProvider } from "../../theme"; | ||
import DOMPurify from "dompurify"; | ||
|
||
@@ -78,3 +79,3 @@ | ||
const origin = | ||
new URLSearchParams(window.location.search).get("origin") || ""; | ||
DOMPurify.sanitize(new URLSearchParams(window.location.search).get("origin") || ""); | ||
|
-
Copy modified lines R104-R105
@@ -103,3 +103,4 @@ | ||
"web3-utils": "4.11.1", | ||
"webextension-polyfill": "^0.10.0" | ||
"webextension-polyfill": "^0.10.0", | ||
"dompurify": "^3.2.4" | ||
}, |
Package | Version | Security advisories |
dompurify (npm) | 3.2.4 | None |
|
||
const isNeg = res.startsWith("-"); | ||
return { | ||
text: isNeg ? res.replace("-", "-") : "+" + res, |
Check warning
Code scanning / CodeQL
Replacement of a substring with itself Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 days ago
To fix the problem, we need to replace the substring "-"
with the correct transformation. The intention seems to be to format the string res
to include a "+" sign for positive values and retain the "-" sign for negative values. Therefore, we should ensure that the "+" sign is added correctly for positive values and the "-" sign is retained for negative values without unnecessary replacement.
- Identify the line with the problematic replacement:
res.replace("-", "-")
. - Replace this line with a conditional check to prepend a "+" sign for positive values and retain the "-" sign for negative values without using the replace method.
-
Copy modified line R991
@@ -990,3 +990,3 @@ | ||
return { | ||
text: isNeg ? res.replace("-", "-") : "+" + res, | ||
text: isNeg ? res : "+" + res, | ||
isNeg, |
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
transactions: transactions, |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
const split = chainId | ||
.split(ChainIdHelper.VersionFormatRegExp) |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
const isChecksumAddress = !!hexAddress.match( | ||
/([A-F].*[a-f])|([a-f].*[A-F])/ | ||
); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
…ing or encoding Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
No description provided.