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.
express-slow-down
Advanced tools
Basic IP rate-limiting middleware for Express that slows down responses rather than blocking the user.
Basic rate-limiting middleware for Express that slows down responses rather than blocking them outright. Use to limit repeated requests to public APIs and/or endpoints such as password reset.
Plays nice with Express Rate Limit
Note: this module does not share state with other processes/servers by default. This module was extracted from Express Rate Limit 2.x and can work with it's stores:
$ npm install --save express-rate-limit
For an API-only server where the rules should be applied to all requests:
const slowDown = require('express-slow-down');
app.enable('trust proxy'); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
const speedLimiter = slowDown({
windowMs: 15*60*1000, // 15 minutes
delayAfter: 100 // allow 100 requests per 10 minutes, then...
delayMs: 500 // begin adding 500ms of delay per request above 100:
// request # 101 is delayed by 500ms
// request # 102 is delayed by 1000ms
// request # 103 is delayed bu 1500ms
// etc.
});
// apply to all requests
app.use(speedLimiter);
For a "regular" web server (e.g. anything that uses express.static()
), where the rate-limiter should only apply to certain requests:
const slowDown = require("express-slow-down");
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
const resetPasswordSpeedLimiter = slowDown({
windowMs: 15 * 60 * 1000, // 15 minutes
delayAfter: 5, // allow 5 requests to go at full-speed, then...
delayMs: 100 // 6th request has a 100ms delay, 7th has a 200ms delay, 8th gets 300ms, etc.
});
// only apply to POST requests to /reset-password/
app.post("/reset-password/", resetPasswordSpeedLimiter, function(req, res) {
// handle /reset-password/ request here...
});
A req.slowDown
property is added to all requests with the current
, and remaining
number of requests for usage in your application code.
60000
(1 minute).windowMs
before starting to delay responses. Defaults to 1
. Set to 0
to disable delaying.delayAfter
). Defaults to 1000
(1 second). Set to 0
to disable delaying.true
failed requests (response status >= 400) won't be counted. Defaults to false
.true
successful requests (response status < 400) won't be counted. Defaults to false
.function (req /*, res*/) {
return req.ip;
}
function (/*req, res*/) {
return false;
}
function (req, res, options) {
/* empty */
}
MIT © Nathan Friedly
FAQs
Basic IP rate-limiting middleware for Express that slows down responses rather than blocking the user.
The npm package express-slow-down receives a total of 12,806 weekly downloads. As such, express-slow-down popularity was classified as popular.
We found that express-slow-down demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.