<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Scenario on slash-root.fr</title><link>https://beta.slash-root.fr/tags/scenario/</link><description>Recent content in Scenario on slash-root.fr</description><generator>Hugo -- gohugo.io</generator><language>fr-fr</language><lastBuildDate>Fri, 19 Jul 2024 11:12:15 +0200</lastBuildDate><atom:link href="https://beta.slash-root.fr/tags/scenario/index.xml" rel="self" type="application/rss+xml"/><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></channel></rss>