Skip to content
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

Rocky/web wallet #774

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Rocky/web wallet #774

wants to merge 4 commits into from

Conversation

tomiir
Copy link
Contributor

@tomiir tomiir commented Nov 18, 2024

No description provided.

Copy link

vercel bot commented Nov 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

18 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-react-ethersv5 ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
appkit-react-wagmi-example ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
appkit-solana ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
chain-abstraction-demo ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
decentralized-relay-app ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
decentralized-relay-wallet ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
malicious-dapp-verify-simulation ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-auth-dapp ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-auth-wallet ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-dapp-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-dapp-v2-cosmos-provider ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-dapp-v2-with-ethers ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-dapp-v2-with-web3js ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
react-wallet-v2 ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:48pm
smart-sessions-demo ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
svelte-web3modal ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
vue-dapp-auth ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm
vue-web-examples ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:48pm

Comment on lines +101 to +105
accounts: namespaceToUpdate.accounts.concat(
`${namespaceToUpdate.chains?.[0]}:${baseAddress}${Math.floor(
Math.random() * (9 - 1 + 1) + 0
)}`
) // generates random number between 0 and 9

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to replace the use of Math.random() with a cryptographically secure random number generator. In the browser environment, we can use window.crypto.getRandomValues to generate a secure random number. This change will ensure that the generated account addresses are not predictable and thus more secure.

Suggested changeset 1
advanced/wallets/reown-web-wallet/src/pages/session.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/advanced/wallets/reown-web-wallet/src/pages/session.tsx b/advanced/wallets/reown-web-wallet/src/pages/session.tsx
--- a/advanced/wallets/reown-web-wallet/src/pages/session.tsx
+++ b/advanced/wallets/reown-web-wallet/src/pages/session.tsx
@@ -102,3 +102,3 @@
               `${namespaceToUpdate.chains?.[0]}:${baseAddress}${Math.floor(
-                Math.random() * (9 - 1 + 1) + 0
+                window.crypto.getRandomValues(new Uint32Array(1))[0] / (0xFFFFFFFF + 1) * (9 - 1 + 1) + 0
               )}`
EOF
@@ -102,3 +102,3 @@
`${namespaceToUpdate.chains?.[0]}:${baseAddress}${Math.floor(
Math.random() * (9 - 1 + 1) + 0
window.crypto.getRandomValues(new Uint32Array(1))[0] / (0xFFFFFFFF + 1) * (9 - 1 + 1) + 0
)}`
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

const redirect = router.query.redirect as string
if (redirect) {
window.location.assign(redirect)

Check warning

Code scanning / CodeQL

Client-side URL redirect Medium

Untrusted URL redirection depends on a
user-provided value
.

Copilot Autofix AI 14 days ago

To fix the problem, we need to ensure that the redirect parameter is validated against a list of authorized URLs before performing the redirection. This can be achieved by maintaining a list of trusted URLs and checking if the redirect parameter matches any of these URLs before redirecting.

  1. Create a list of authorized URLs.
  2. Check if the redirect parameter is in the list of authorized URLs.
  3. Only perform the redirection if the redirect parameter is authorized.
Suggested changeset 1
advanced/wallets/reown-web-wallet/src/pages/request.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/advanced/wallets/reown-web-wallet/src/pages/request.tsx b/advanced/wallets/reown-web-wallet/src/pages/request.tsx
--- a/advanced/wallets/reown-web-wallet/src/pages/request.tsx
+++ b/advanced/wallets/reown-web-wallet/src/pages/request.tsx
@@ -55,3 +55,8 @@
         const redirect = router.query.redirect as string
-        if (redirect) {
+        const authorizedUrls = [
+          'https://trusted-site1.com',
+          'https://trusted-site2.com',
+          // Add more trusted URLs here
+        ]
+        if (redirect && authorizedUrls.includes(redirect)) {
           window.location.assign(redirect)
EOF
@@ -55,3 +55,8 @@
const redirect = router.query.redirect as string
if (redirect) {
const authorizedUrls = [
'https://trusted-site1.com',
'https://trusted-site2.com',
// Add more trusted URLs here
]
if (redirect && authorizedUrls.includes(redirect)) {
window.location.assign(redirect)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

const redirect = router.query.redirect as string
if (redirect) {
window.location.assign(redirect)

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.

Copilot Autofix AI 14 days ago

To fix the problem, we need to ensure that the redirect parameter is properly sanitized or validated before being used in window.location.assign. The best way to do this is to use a whitelist of allowed URLs or to ensure that the URL is safe by using a library that can parse and validate URLs.

In this case, we will use a simple whitelist approach to ensure that only allowed URLs can be used for redirection. We will define a list of allowed domains and check if the redirect URL belongs to one of these domains before performing the redirection.

Suggested changeset 1
advanced/wallets/reown-web-wallet/src/pages/request.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/advanced/wallets/reown-web-wallet/src/pages/request.tsx b/advanced/wallets/reown-web-wallet/src/pages/request.tsx
--- a/advanced/wallets/reown-web-wallet/src/pages/request.tsx
+++ b/advanced/wallets/reown-web-wallet/src/pages/request.tsx
@@ -55,4 +55,14 @@
         const redirect = router.query.redirect as string
+        const allowedDomains = ['example.com', 'another-example.com']; // Add allowed domains here
         if (redirect) {
-          window.location.assign(redirect)
+          try {
+            const url = new URL(redirect);
+            if (allowedDomains.includes(url.hostname)) {
+              window.location.assign(redirect);
+            } else {
+              console.warn('Redirect URL is not allowed:', redirect);
+            }
+          } catch (e) {
+            console.error('Invalid redirect URL:', redirect);
+          }
         }
EOF
@@ -55,4 +55,14 @@
const redirect = router.query.redirect as string
const allowedDomains = ['example.com', 'another-example.com']; // Add allowed domains here
if (redirect) {
window.location.assign(redirect)
try {
const url = new URL(redirect);
if (allowedDomains.includes(url.hostname)) {
window.location.assign(redirect);
} else {
console.warn('Redirect URL is not allowed:', redirect);
}
} catch (e) {
console.error('Invalid redirect URL:', redirect);
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants