
Security News
Cline CLI npm Package Compromised via Suspected Cache Poisoning Attack
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.
CSRF protection utility for framework-free node sites.
var csrf = require('csrf-lite');
var Cookies = require('cookies');
var qs = require('querystring');
http.createServer(function (req, res) {
var c = new Cookies(req, res);
// use the session id as the token
var token = c.get('sessid');
// if the user doesn't have one, then give them one.
// it's just a random string anyway.
if (!token) {
token = csrf(token);
c.set('sessid', token);
}
switch (req.method) {
case 'GET': return showForm(req, res, token);
case 'POST': return validForm(req, res, token);
}
}).listen(PORT)
function showForm(req, res, token) {
res.end('<html><form method=post>' +
'<label>Name <input name=name></label>' +
// add the csrf token html
csrf.html(token) +
'<input type=submit value=GO>' +
'</form></html>');
}
function validForm(req, res, token) {
// note: this won't work for
req.setEncoding('utf8');
var data = '';
req.on('data', function(c) {
data += c;
});
req.on('end', function() {
data = querystring.parse(data);
// validate with the user's token
var valid = csrf.validate(data, token);
if (valid)
res.end('ok\n');
else {
res.statusCode = 403;
res.end('csrf detected!\n');
}
});
}
If a token is supplied, then returns it. If not, then it generates a 192-bit random string and returns that.
Make sure that you stash the token somewhere like a session or something, so that it can be retrieved later.
Returns an <input> field containing the token, for csrf validation
in forms.
If no token is provided, then it returns nothing.
Validates that the x-csrf-token field is equal to the token. Call this
with the parsed form data on the other side. Can also be used on
request headers, query string, or any other random data.
FAQs
csrf protection for framework-less node sites
The npm package csrf-lite receives a total of 17 weekly downloads. As such, csrf-lite popularity was classified as not popular.
We found that csrf-lite 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
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.

Product
Socket now supports PHP with full Composer and Packagist integration, enabling developers to search packages, generate SBOMs, and protect their PHP dependencies from supply chain threats.