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.
Another CommonJs transform ESModule lib.
English | 简体中文
import cjs2esm from 'cjs-esm'
// or
// const cjs2esm = require('cjs-esm').default
const { code, map } = cjs2esm(`const fs = require('fs')`)
✅ Nested scope(function-scope) 🚧-🐞
function load(path) {
require(path);
}
↓
function load(path) {
import/*🚧-🐞*/(path).then(m => m.default || m);
}
❌ Dynamic require id
✅ require statement
// Top-level scope
const foo = require('foo').default
↓
import foo from 'foo';
const foo = require('foo')
↓
import * as foo from 'foo';
const foo = require('foo').bar
↓
import * as __CJS_import__0__ from 'foo'; const { bar: foo } = __CJS_import__0__;
// Non top-level scope
const foo = [{ bar: require('foo').bar }]
↓
import * as __CJS_import__0__ from 'foo'; const foo = [{ bar: __CJS_import__0__.bar }]
✅ exports statement
module.exports = fn() { };
↓
const __CJS__export_default__ = module.exports = fn() { };
export { __CJS__export_default__ as default }
exports.foo = 'foo';
↓
const __CJS__export_foo__ = (module.exports == null ? {} : module.exports).foo;
export { __CJS__export_foo__ as foo }
FAQs
Another CommonJs transform ESModule lib.
The npm package cjs-esm receives a total of 1 weekly downloads. As such, cjs-esm popularity was classified as not popular.
We found that cjs-esm 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.