-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat: implement CAIP25 MultiChain API and NextJS playground integration #1201
base: main
Are you sure you want to change the base?
Conversation
{ | ||
type: 'caip-request', | ||
data: request, | ||
}, |
Check warning
Code scanning / CodeQL
Cross-window communication with unrestricted target origin Medium
Sensitive data
Sensitive data
Sensitive data
Sensitive data
Sensitive data
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 days ago
To fix the problem, we need to specify a target origin for the window.postMessage
calls. This ensures that the message is only sent to a trusted origin, reducing the risk of exposing sensitive data to malicious sites.
- Identify the trusted origin(s) that should receive the messages.
- Replace the wildcard target origin (
'*'
) with the specific trusted origin(s) in thewindow.postMessage
calls.
-
Copy modified line R187 -
Copy modified line R217
@@ -186,3 +186,3 @@ | ||
}, | ||
'*', | ||
'https://trusted-origin.com', | ||
); | ||
@@ -216,3 +216,3 @@ | ||
}, | ||
'*', | ||
'https://trusted-origin.com', | ||
); |
}); | ||
} | ||
|
||
#handleFallbackMessage(event: MessageEvent): void { |
Check warning
Code scanning / CodeQL
Missing origin verification in `postMessage` handler Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 days ago
To fix the problem, we need to add an origin check in the #handleFallbackMessage
function to ensure that only messages from trusted origins are processed. This involves comparing the event.origin
property to a list of allowed origins and only proceeding if the origin is trusted.
- Identify the trusted origins for the application.
- Modify the
#handleFallbackMessage
function to include a check for the origin of the incoming message. - If the origin is not trusted, the function should return early and not process the message.
-
Copy modified lines R231-R235
@@ -230,2 +230,7 @@ | ||
#handleFallbackMessage(event: MessageEvent): void { | ||
const trustedOrigins = ['https://www.example.com', 'https://another-trusted-origin.com']; | ||
if (!trustedOrigins.includes(event.origin)) { | ||
this.#logger?.warn('[ExtensionProvider] Untrusted origin:', event.origin); | ||
return; | ||
} | ||
if (event.data?.type !== 'caip-response') { |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is new author?A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package. Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights. What is an install script?Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts. Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
Description
This PR implements a new MultiChain API package that follows the CAIP25 specification to provide chain-agnostic wallet interactions. It also includes a Next.js playground for testing and demonstrating the API capabilities.
Key Features
@metamask/multichainapi
package implementing CAIP25 specMultiChain API Implementation
Next.js Playground Features
Implementation Details
Testing Instructions
yarn install yarn dev:core cd packages/playground-next yarn dev
Documentation
The playground serves as living documentation for the MultiChain API. Additional package documentation will be added in follow-up PRs.
Review Checklist