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.
micro-csrf
is a csrf middleware for Zeit.co's micro framework. This module is heavily inspired by express-csurf
.
$ npm install micro-csrf
# or
$ yarn add micro-csrf
// Use the micro-session middleware for storing the token secret
const SessionManager, { MemoryStore } = require('micro-session');
const { csrfMiddleware } = require('micro-csrf');
const sessionManager = SessionManager({
store: new MemoryStore(),
secret: 'my session secret'
})
const csrf = csrfMiddleware();
module.exports = async (req, res) => {
let session = await getSession(req, res);
// This will automatically end the request with a 403 error
// if this is a POST, PUT, PATCH, DELETE request without a valid
// CSRF Token.
const csrfToken = await csrf(session, req, res);
// ...
return {
csrfToken
};
};
The token is automatically read from the following locations:
req.body._csrf - requires a parsed request body
req.query._csrf - requires a query parser
req.headers['csrf-token'] - the CSRF-Token HTTP request header.
req.headers['xsrf-token'] - the XSRF-Token HTTP request header.
req.headers['x-csrf-token'] - the X-CSRF-Token HTTP request header.
req.headers['x-xsrf-token'] - the X-XSRF-Token HTTP request header.
FAQs
Anti-CSRF middleware for micro
The npm package micro-csrf receives a total of 3 weekly downloads. As such, micro-csrf popularity was classified as not popular.
We found that micro-csrf 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.