
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
This module creates a dynamic handler for matching and authorizing routes.
In order, to perform an authorization for a given user, you must have access to the user, model, url, and method.
+-------------------------+
| Request |
| |
+----------+--------------+
|
|
+----------+--------------+
| |
| |
| Authentication |
| |
+-----------+-------------+
|
|
|
+-----------v-------------+
| |
| |
| Authorization |
| (CanDo) |
+-----------+-------------+
|
|
+-----------v-------------+
| |
| app.router |
| |
+-------------------------+
Here is a diagram of the middleware stack, the CanDo module can be placed between the Authentication and App.router. It needs the user, model, url, and method;
The concept behind the cando module is to give you the ability to create custom based authorization rules in a sharable javascript file that can be provided to both the server and the client. THis way our authorization rules are in one place and applied to the front-end to hide and show functionality and applied to the back-end to allow or deny actions.
var cando = require('cando');
cando
.define('/api/users', function() {
this.user.role === 'admin' ? this.allow() : this.deny();
this.next();
})
.define('/api/users/:id', 'PUT', function() {
this.user.id === this.model.user_id ? this.allow() : this.deny();
this.next();
});
app.use(...); //authentication
app.use(function(req, res, next) {
// /api/:model/:id
var id = req.url.split('/')[3];
db.get(id, function(err, doc) {
if (err) { return res.send(500, err); }
req.model = doc;
next();
});
});
app.use(function(req, res, next) {
var data = {
user: req.session.user,
model: req.model,
req: req
};
cando.verify(data, function(err, authorized) {
if (err) { return res.send(500, err); }
if (!authorized) { return res.send(403, { status: 'Not Authorized' }); }
console.log('authorized');
next();
});
});
Is an authorization module that includes a micro-router for matching defined routes and providing authorization logic to confirm the user has the right to execute the requested api function.
There are two endpoints, #define and #verify.
[define] takes a url pattern, a optional verb array, if null, then it is assumed you want to match against all verbs, and is the default verbs are GET, POST, PUT, DELETE. the last parameter is the function you want to be invoked on match in that function you will have access to the following:
[verify] is the function that performs the match against all of your defined patterns. So you normally call this in the middleware stack or on the client before you want to execute your application code.
FAQs
An authorization module
We found that cando 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
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.