<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Decision on slash-root.fr</title><link>https://beta.slash-root.fr/tags/decision/</link><description>Recent content in Decision on slash-root.fr</description><generator>Hugo -- gohugo.io</generator><language>fr-fr</language><lastBuildDate>Wed, 07 Aug 2024 11:53:52 +0200</lastBuildDate><atom:link href="https://beta.slash-root.fr/tags/decision/index.xml" rel="self" type="application/rss+xml"/><item><title>CrowdSec : Avoid a Duplicate Decision / Notification</title><link>https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/</link><pubDate>Wed, 07 Aug 2024 10:52:44 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/cover.png" alt="Featured image of post CrowdSec : Avoid a Duplicate Decision / Notification" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Prenons le cas de l'utilisation de CrowdSec pour protéger des applications web en analysant les logs du reverse-proxy.&lt;/p&gt;
&lt;p&gt;Suivant le scénario qui se déclenchera, CrowdSec prendra une décision concernant l'adresse IP concernée. Par exemple, renvoyer un code HTTP 403. Dans ce cas de figure, si l'acteur malveillant persiste, une décision sera prise à chaque fois. Si des notifications sont envoyées à chaque prise de décision, cela peut vite devenir du spam ! C'est le comportement normal puisque le profil par défaut de CrowdSec prend une décision à chaque déclenchement de scénario.&lt;/p&gt;
&lt;p&gt;Nous allons voir comment modifier la prise de décision pour vérifier au préalable si une décision identique n'a pas été prise récemment.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Toutes les commandes / manipulations présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="modification-de-la-remediation"&gt;&lt;a href="#modification-de-la-remediation" class="header-anchor"&gt;&lt;/a&gt;Modification de la Remediation
&lt;/h2&gt;&lt;p&gt;Tout va se passer dans un seul fichier : &lt;code&gt;/etc/crowdsec/profiles.yaml&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Voici un fichier classique qui &lt;strong&gt;ban&lt;/strong&gt; pendant 4h l'adresse IP qui déclenche un scénario :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#/etc/crowdsec/profiles.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default_ip_remediation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filters&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Alert.Remediation == true &amp;amp;&amp;amp; Alert.GetScope() == &amp;#34;Ip&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;decisions&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ban&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;duration&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;4h&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#duration_expr: &amp;#34;Sprintf(&amp;#39;%dh&amp;#39;, (GetDecisionsCount(Alert.GetValue()) + 1) * 4)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;on_success&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nous allons modifier le filtre pour vérifier si une décision n'a pas été prise il y a moins de 2h pour l'adresse IP concernée.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Voici le fichier modifié :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#/etc/crowdsec/profiles.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default_ip_remediation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filters&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Alert.Remediation == true &amp;amp;&amp;amp; Alert.GetScope() == &amp;#34;Ip&amp;#34; &amp;amp;&amp;amp; GetDecisionsSinceCount(Alert.GetValue(), &amp;#34;2h&amp;#34;) &amp;lt; 1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;decisions&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ban&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;duration&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;4h&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#duration_expr: &amp;#34;Sprintf(&amp;#39;%dh&amp;#39;, (GetDecisionsCount(Alert.GetValue()) + 1) * 4)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;on_success&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Pour valider la modification, redémarrez le service :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="intérêt"&gt;&lt;a href="#int%c3%a9r%c3%aat" class="header-anchor"&gt;&lt;/a&gt;Intérêt
&lt;/h2&gt;&lt;p&gt;On peut se dire : Mais pourquoi faire ça ?&lt;/p&gt;
&lt;p&gt;A chaque fois que CrowdSec prendra une décision, si les notifications sont configurées, cela en déclenchera une systématiquement.&lt;/p&gt;
&lt;p&gt;Dans mon cas, cela concernait les scans multi-ports et j'en avais marre de recevoir du spam de notification... (Effet JO 2024 ???).&lt;/p&gt;
&lt;p&gt;Voici l'output que cela donnait en moins d'une minute :&lt;/p&gt;
&lt;p&gt;&lt;img data-recalc-dims="1" decoding="async" src="01.png" alt="image-20240807104724911" /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;Maintenant, CrowdSec prendra une décision concernant l'adresse IP qui déclenchera un scénario et qui n'a pas été &lt;strong&gt;ban&lt;/strong&gt; il y a moins de 2h. Si celle-ci revient au bout de 3h et redéclenche un scénario, ça sera reparti pour 4h, etc.&lt;/p&gt;</description></item><item><title>CrowdSec : Protéger l’authentification Gitlab</title><link>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/</link><pubDate>Fri, 19 Jul 2024 11:06:58 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/cover.png" alt="Featured image of post CrowdSec : Protéger l’authentification Gitlab" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Ce guide explique comment protéger l'authentification sur Gitlab contre les attaques de Bruteforce à l'aide de CrowdSec. Il est essentiel de sécuriser un portail d'authentification web. Une nouvelle collection crowdsec, comprenant 1 parser et 1 scénario, sera installée.&lt;/p&gt;
&lt;p&gt;Ce guide se base sur une installation de Gitlab sur Debian 12. La version Gitlab utilisée est la dernière en date (17.2.0).&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Une machine Debian 12 avec un accès root ou sudo. Toutes les commandes présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Une connexion internet active.&lt;/li&gt;
&lt;li&gt;Gitlab CE ou EE installé&lt;/li&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="modification-du-port-de-lapi-crowdsec"&gt;&lt;a href="#modification-du-port-de-lapi-crowdsec" class="header-anchor"&gt;&lt;/a&gt;Modification du port de l&amp;rsquo;API CrowdSec
&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Très important !&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Avec une installation standard de Gitlab, le serveur PUMA (serveur web ruby faisant partie de gitlab) écoute sur le port TCP 8080. Il est donc impératif de modifier le port d'écoute de l'API de CrowdSec pour éviter tout conflit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Procédure décrite &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/#toc-10"&gt;[ici]&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Vérifiez bien que vos services crowdsec fonctionnent correctement :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="installation-de-la-collection-pour-gitlab"&gt;&lt;a href="#installation-de-la-collection-pour-gitlab" class="header-anchor"&gt;&lt;/a&gt;Installation de la collection pour gitlab
&lt;/h2&gt;&lt;p&gt;En navigant sur le hub de CrowdSec, une collection pour gitlab est disponible.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installer la collection :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli collections install timokoessler/gitlab
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ceci a pour effet d'installer 1 parser et 1 scénario.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Lister les parsers :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli parsers list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# timokoessler/gitlab-logs ✔️ enabled 0.1 /etc/crowdsec/parsers/s01-parse/gitlab-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lister les sénarios :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli scenario list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# timokoessler/gitlab-bf ✔️ enabled 0.2 /etc/crowdsec/scenarios/gitlab-bf.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="création-du-fichier-dacquisition"&gt;&lt;a href="#cr%c3%a9ation-du-fichier-dacquisition" class="header-anchor"&gt;&lt;/a&gt;Création du fichier d&amp;rsquo;acquisition
&lt;/h2&gt;&lt;p&gt;Afin que le parser Gitlab puisse être utilisé, il faut définir la méthode d'acquisition.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/gitlab.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filenames&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/var/log/gitlab/gitlab-rails/production_json.log&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;gitlab&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="redémarrage-du-service"&gt;&lt;a href="#red%c3%a9marrage-du-service" class="header-anchor"&gt;&lt;/a&gt;Redémarrage du service
&lt;/h2&gt;&lt;p&gt;A présent, le service crowdsec peut être rechargé :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl reload crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="vérification"&gt;&lt;a href="#v%c3%a9rification" class="header-anchor"&gt;&lt;/a&gt;Vérification
&lt;/h2&gt;&lt;p&gt;Nous allons vérifier le fonctionnement du parser et du nouveau scénario dédié à gitlab.&lt;/p&gt;
&lt;p&gt;Pour cela, spammez la page de login de Gitlab, puis vérifiez les résultats :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Alertes :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli alerts list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 2 │ Ip:66.66.66.66 │ timokoessler/gitlab-bf │ │ │ ban:1 │ 2024-07-19 07:56:48.649063483 +0000 UTC&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Décisions :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli decisions list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 15001 │ crowdsec │ Ip:66.66.66.66 │ timokoessler/gitlab-bf │ ban │ │ │ 6 │ 3h59m43.261827214s │ 2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;En suivant ce guide, vous avez sécurisé l'authentification de votre Gitlab contre les attaques de Bruteforce grâce à CrowdSec. &lt;/p&gt;</description></item><item><title>CrowdSec : Protéger l’authentification Proxmox</title><link>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/</link><pubDate>Thu, 18 Jul 2024 14:50:45 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/cover.png" alt="Featured image of post CrowdSec : Protéger l’authentification Proxmox" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Ce guide explique comment protéger l'authentification sur Proxmox contre les attaques de Bruteforce à l'aide de CrowdSec. Suite aux dernières actualités de VMware, de nombreux utilisateurs ont migré vers Proxmox. Il est donc essentiel de sécuriser le portail d'authentification, exposé par défaut sur le port TCP 8006.&lt;/p&gt;
&lt;p&gt;Ce guide se base sur une installation de Proxmox sur Debian 12. Par défaut, &lt;code&gt;rsyslog&lt;/code&gt; n'est plus installé sur Debian 12. Nous verrons comment configurer cela avec &lt;code&gt;journald&lt;/code&gt; mais également avec &lt;code&gt;rsyslog&lt;/code&gt; si besoin.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Une machine Debian 12 avec un accès root ou sudo. Toutes les commandes présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Une connexion internet active.&lt;/li&gt;
&lt;li&gt;Proxmox installé&lt;/li&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="installation-de-la-collection-pour-proxmox"&gt;&lt;a href="#installation-de-la-collection-pour-proxmox" class="header-anchor"&gt;&lt;/a&gt;Installation de la collection pour proxmox
&lt;/h2&gt;&lt;p&gt;En navigant sur le hub de CrowdSec, une collection pour proxmox est disponible.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installer la collection :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli collections install fulljackz/proxmox
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ceci a pour effet d'installer 2 parsers et 1 scénario.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Lister les parsers :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli parsers list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# crowdsecurity/syslog-logs ✔️ enabled 0.8 /etc/crowdsec/parsers/s00-raw/syslog-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# fulljackz/proxmox-logs ✔️ enabled 0.2 /etc/crowdsec/parsers/s01-parse/proxmox-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lister les sénarios :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli scenario list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# fulljackz/proxmox-bf ✔️ enabled 0.2 /etc/crowdsec/scenarios/proxmox-bf.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pour que ceux-ci soient pris en compte, le service CrowdSec doit être rechargé. Nous le ferons après quelques modifications.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="modification-du-parser-proxmox"&gt;&lt;a href="#modification-du-parser-proxmox" class="header-anchor"&gt;&lt;/a&gt;Modification du parser proxmox
&lt;/h2&gt;&lt;p&gt;Le parser spécifique à proxmox se situe ici : &lt;strong&gt;/etc/crowdsec/parsers/s01-parse/proxmox-logs.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Pour qu'il soit compatible avec la dernière version de Proxmox, nous allons l'éditer et apporter les modifications suivantes :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;pattern_syntax&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;PVE_AUTH_FAIL&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;authentication failure; rhost=::ffff:%{IP:client_ip} user=%{USERNAME:source_user}@%{WORD:realm} msg=&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ajout : &lt;code&gt;::ffff:&lt;/code&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="création-du-fichier-dacquisition"&gt;&lt;a href="#cr%c3%a9ation-du-fichier-dacquisition" class="header-anchor"&gt;&lt;/a&gt;Création du fichier d&amp;rsquo;acquisition
&lt;/h2&gt;&lt;p&gt;Afin que le parser Proxmox puisse être utilisé, il faut définir la méthode d'acquisition.&lt;/p&gt;
&lt;h3 id="utilisation-avec-journald"&gt;&lt;a href="#utilisation-avec-journald" class="header-anchor"&gt;&lt;/a&gt;Utilisation avec journald
&lt;/h3&gt;&lt;p&gt;Pour utiliser le parser avec journald :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/proxmox.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;journalctl_filter&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;_SYSTEMD_UNIT=pvedaemon.service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;syslog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="utilisation-avec-rsyslog"&gt;&lt;a href="#utilisation-avec-rsyslog" class="header-anchor"&gt;&lt;/a&gt;Utilisation avec rsyslog
&lt;/h3&gt;&lt;p&gt;Si vous préférez utiliser rsyslog avec le fichier de log &lt;code&gt;/var/log/syslog&lt;/code&gt; :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installez &lt;code&gt;rsyslog&lt;/code&gt; si ce n'est pas déjà fait :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install -y rsyslog
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/proxmox.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filenames&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/var/log/syslog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pvedaemon&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="redémarrage-du-service"&gt;&lt;a href="#red%c3%a9marrage-du-service" class="header-anchor"&gt;&lt;/a&gt;Redémarrage du service
&lt;/h2&gt;&lt;p&gt;A présent, le service crowdsec peut être rechargé :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl reload crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="vérification"&gt;&lt;a href="#v%c3%a9rification" class="header-anchor"&gt;&lt;/a&gt;Vérification
&lt;/h2&gt;&lt;p&gt;Nous allons vérifier le fonctionnement des parsers et du nouveau scénario dédié à proxmox.&lt;/p&gt;
&lt;p&gt;Pour cela, spammez la page de login de Proxmox, puis vérifiez les résultats :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Alertes :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli alerts list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# | 2 │ Ip:66.66.66.66 │ fulljackz/proxmox-bf │ │ │ ban:1 │ 2024-07-18 12:13:37.498899667 +0000 UTC &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Décisions :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli decisions list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 15001 │ crowdsec │ Ip:66.66.66.66 │ fulljackz/proxmox-bf │ ban │ │ │ 7 │ 3h59m51.44622068s │ 2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;En suivant ce guide, vous avez sécurisé l'authentification de votre Proxmox contre les attaques de Bruteforce grâce à CrowdSec. &lt;/p&gt;</description></item></channel></rss>