Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ddos-express
Advanced tools
Configurable Denial-Of-Service prevention library for Express
var expresss = require("express");
var ddos = require("ddos-express");
var app = express();
app.use(ddos({
/*Configuration options*/
}));
Data to be passes to the client on DDoS detection. Default: "Not so fast!".
HTTP error code to be set on DDoS detection. Default: 429 (Too Many Requests).
Default request weight. 1 by default.
Default maximum allowed weight per IP. 10 by default.
Interval (in milliseconds) to check connections and decrement weights. Default: 1000 (1 second).
List of rules to apply to each request. Example:
rules: [
{ /*Allow 4 requests accessing the application API per checkInterval*/
regexp: "^/api.*",
flags: "i",
maxWeight: 4,
queueSize: 4 /*If request limit is exceeded, new requests are added to the queue*/
},
{ /*Only allow 1 search request per check interval.*/
string: "/action/search",
maxWeight: 1
},
{ /*Allow up to 16 other requests per check interval.*/
regexp: ".*",
maxWeight: 16
}
]
A function used for logging detected DDoS. The following arguments are passes to the function:
req.ip
— user's IP addressreq.path
— request pathuser.weight
— current weightrule.maxWeight
— maximum allowed weightrule.regexp || rule.string
— rule patternEvery request is checked against a chain of rules. Rules with a string
path pattern are checked first. They are added to a map for the sake of performance. Then the request is checked against every regexp
-based rules.
If request path (req.path
) matches the rule's pattern, that rule is applied. Other rules are not checked.
User IP is retrieved from the req.ip
property. You have to handle proxies (X-Forwarded-For
header and such) yourself.
A weight is assigned to each user. Every time a new request is made, the weight is increased. If the weight becomes larger than maxWeight
, the errorData
is returned to the user along with the errorCode
.
Requests which did not match any rule or have passed the test are forwarded to the next middleware/router.
Every checkInterval
milliseconds all users are checked. The weights are decremented by the maxWegight
. If user's weight becomes less than or equal to 0, that user is deleted from the map.
Say weight
is 1, maxWeight
is 10 and checkInterval
is 1000.
A user makes 35 requests in one second. First 10 request pass the module, the other 25 do not. The weight is 35 for now. Then the user stops sending requests.
After 1 second passes by, the weight is decremented by 10 and becomes 25. The user attempts to make one more request, which does not pass. The weight becomes 26.
Two sceonds later (after two checks) the weight is decreased twice and becomes 6. The user attempts to make a request, which now successfully passes the check. The weight becomes 7.
FAQs
Configurable Denial-Of-Service prevention library for Express
The npm package ddos-express receives a total of 11 weekly downloads. As such, ddos-express popularity was classified as not popular.
We found that ddos-express 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.