Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
coi-serviceworker
Advanced tools
Cross-origin isolation (COOP and COEP) through a service worker for situations in which you can't control the headers (e.g. GH pages).
coi-serviceworker.js
(or coi-serviceworker.min.js
).<script src="coi-serviceworker.js"></script>
This script will reload the page on the user's first load to magically add the required COOP and COEP headers in a serice worker.
Rules:
You can install this package from npm:
npm i --save coi-serviceworker
You will still have to tell your bundler to put the file alongside your bundle. Something like this will do the trick:
cp node_modules/coi-serviceworker/coi-serviceworker.js dist/
You can customize the behavior by defining a variable coi
in the global scope (i.e. on the window
object):
window.coi = {
// // A function that is run to decide whether to register the SW or not.
// You could for instance make this return a value based on whether you actually need to be cross origin isolated or not.
shouldRegister: () => true,
// If this function returns true, any existing service worker will be deregistered (and nothing else will happen).
shouldDeregister: () => false,
// Override this if you want to prompt the user and do reload at your own leisure. Maybe show the user a message saying:
// "Click OK to refresh the page to enable <...>"
doReload: () => window.location.reload(),
// Set to true if you don't want coi to log anything to the console.
quiet: false
}
Library and idea based on @stefnotch's blog post.
MIT
Carp or Koi (1926) by Ohara Koson. Original from the Los Angeles County Museum of Art. Public Domain CC0 image.
FAQs
Cross-Origin Isolation through a service worker
The npm package coi-serviceworker receives a total of 263 weekly downloads. As such, coi-serviceworker popularity was classified as not popular.
We found that coi-serviceworker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.