Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
crowdsec-client-scenarios
Advanced tools
This library is a Node.js client to talk with crowdsec rest API .
install it
npm i crowdsec-client-scenarios
and then read the documentation in the wiki
This package, is planned to host scenarios used by crowdsec-http-middleware and other middleware that extend it
in this part, we will use the variables scenarios
and scenariosOptions
, to illustrate the use in the middlewares
the defaults scenarios are (defined here) :
The available scenarios are :
This scenario will validate the XForwardedFor header . Some malicious persons will send you a fake X-Forwarded-For
header, to hide their real IP .
This scenario will trigger an alert, if an untrusted IP try to pass X-Forwarded-For
const scenarios = [XForwardedForChecker];
const scenariosOptions = {
'x-forwarded-for': {
//list of trusted CIDR, you need to setup here that all the trusted proxies, else, it will trigger alert for your reverse proxies, and extract incorrect ip
trustedProxies: [],
//trigger alert if an untrusted ip set the header (true by default)
alertOnNotTrustedIps: true
}
}
this scenario support the extractIp capability, so, if you enable it, it will extract the IP automatically from the headers, will use set it on req.ip
, and will use it to trigger alerts and check if decisions exists
you are using cloudflare (you can get cloudflare ips here, then traefik in subnet 10.0.3.0/24, and finally your webserver
on your server, you will configure :
const scenarios = [XForwardedForChecker];
const scenariosOptions = {
'x-forwarded-for': {
//list of trusted CIDR, you need to setup here that all the trusted proxies, else, it will trigger alert for your reverse proxies, and extract incorrect ip
trustedProxies: [
//cloudflare ips
"173.245.48.0/20",
"103.21.244.0/22",
"103.22.200.0/22",
"103.31.4.0/22",
"141.101.64.0/18",
"108.162.192.0/18",
"190.93.240.0/20",
"188.114.96.0/20",
"197.234.240.0/22",
"198.41.128.0/17",
"162.158.0.0/15",
"104.16.0.0/13",
"104.24.0.0/14",
"172.64.0.0/13",
"131.0.72.0/22",
"2400:cb00::/32",
"2606:4700::/32",
"2803:f800::/32",
"2405:b500::/32",
"2405:8100::/32",
"2a06:98c0::/29",
"2c0f:f248::/32",
//traefik ip
"10.0.3.0/24"
],
//trigger alert if an untrusted ip set the header
alertOnNotTrustedIps: true
}
}
so, if someone with ip 1.2.3.4
it will produce an X-Forwarded-For
like 1.2.3.4, 173.245.48.2
, and your webserver will detect a remote address like 10.0.3.1
.
This scenario will parse the information, and so set req.ip = "1.2.3.4"
, so you now know the real ip of your visitor .
I need to warn you, if you miss configured the list of allowed ips, it can ban your reverse proxy .
you can test it before, by setting alertOnNotTrustedIps
to false, and log req.ip
, if the IP is correct, you can enable the alerts
This scenario allow you to exclude some ips from alerts
const scenarios = [AllowListEnricher];
const scenariosOptions = {
'allow-list': {
//list of CIDR/IP to allow to skip alert checks
allowed: ['127.0.0.1']
}
}
by default, the CIDR allowed are the RFC 1918 one (private network)
const scenariosOptions = {
'allow-list': {
allowed: ['127.0.0.1', '::1', '192.168.0.0/16', '10.0.0.0/8', '172.16.0.0/12']
}
}
this scenario will add context to your alert, linked with the current http request
const scenarios = [AllowListEnricher];
//no options
const scenariosOptions = {}
this scenario will add context to your alert with the help of the maxmind databases
const scenarios = [MaxMindEnricher];
const scenariosOptions = {
maxmind: {
//specify path to ASN or city databases . you need need to set one, or the two databases
paths: {
ASN: 'path/to/geoLite2-ASN.mmdb',
city: 'path/to/geoLite2-City.mmdb'
},
//you can watch for updates, and so, updating the database on the filesytem will automatically reload the database
watchForUpdates: true
}
}
to use this scenario, you will need to download free databases available here. If you need better accuracy you should consider buying commercial subscription.
this library include debug, to debug, you can set the env variable :
DEBUG=crowdsec-client-scenarios:*
FAQs
tmp
The npm package crowdsec-client-scenarios receives a total of 6 weekly downloads. As such, crowdsec-client-scenarios popularity was classified as not popular.
We found that crowdsec-client-scenarios 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
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.