
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
exports-lock
Advanced tools
A library to protect integrity of packages in Node.js
JavaScript allows very flexible coding pattern, such as dynamically changing behavior by alternating the prototype chain of constructor. However, lacking of accessing control incurs vulnerability.
Can you imagine that you can change behavior of a package which is not in your hand? Current module mechanism offers NO PROTECTION for integrity of package. People can change behavior of your package once you put it in public. You cannot promise that package behaves as exactly as document saying, if somebody alternated your implementation silently.
Due to lack of convenient access control, or developers often don't care it. We exposes our code under public domain, and incurs possible malicious attacks. Now, it's pretty clear that to protect ourself, we should protect our code from maliciously changing.
I wrote this library to simply set all method/properties of public interface to not writable and not configurable. It can prevent unwanted change to your library.
Download from npm
npm install exports-lock
Lock your public interface
// entry point
const lock = require('exports-lock')
goodFunction: () => 'good function'
module.exports = {
goodFunction
}
lock(module.exports)
If a malicious library attempts to change your code,
// malicious library
const goodLib = require('goodLib')
goodLib.goodFunction = () => 'bad'
your code will not be affected.
// client code
const goodLib = require('goodLib')
const badLib = require('badLib')
console.log(goodLib.goodFunction()) // 'good function'
FAQs
A library to protect integrity of packages in Node.js
We found that exports-lock 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.