AD CS : Autorité de certificat sous Windows en vue de l'authentification EAP-TLS

Installation de l'autorité de certification racine

Je m'inspire de cette documentation, très complète : Offline Root CA Setup | docs.mjcb.io

Un livre papier/kindle existe, je le recommande très fortement.

Cette documentation est en cours de rédaction.

J'utilise ici les bonnes pratiques de Microsoft qui consiste à mettre en place 2 serveurs : 

On commence par mettre en place l'autorité de certification racine, qui sera par la suite offline.

A la racine du C:, on ajoute un fichier CAPolicy.inf :

[Version]
Signature = "$Windows NT$"

[PolicyStatementExtension]
Policies = AllIssuancePolicy,InternalPolicy
Critical = FALSE

; AllIssuancePolicy is set to the OID of 2.5.29.32.0 to ensure all certificate templates are available.
[AllIssuancePolicy]
OID = 2.5.29.32.0

[InternalPolicy]
OID = 1.2.3.4.1455.67.89.5
Notice = "The Khroners Labs Certification Authority is an internal resource. Certificates that are issued by this Certificate Authority are for internal usage only."
URL = http://pki.ad.khroners.fr/cps.html

[Certsrv_Server]
; Renewal information for the Root CA.
RenewalKeyLength = 4096
RenewalValidityPeriod = Years
RenewalValidityPeriodUnits = 10

; Disable support for issuing certificates with the RSASSA-PSS algorithm.
AlternateSignatureAlgorithm = 0

; The CRL publication period is the lifetime of the Root CA.
CRLPeriod = Years
CRLPeriodUnits = 10

; The option for Delta CRL is disabled since this is a Root CA.
CRLDeltaPeriod = Days
CRLDeltaPeriodUnits = 0

 

image.png

image.png

On configure le rôle :

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

certutil.exe -setreg CA\DSConfigDN "CN=Configuration,DC=ad,DC=khroners,DC=fr"
certutil.exe -setreg CA\ValidityPeriodUnits 5
certutil.exe -setreg CA\ValidityPeriod "Years"
certutil.exe -setreg CA\CRLPeriodUnits 52
certutil.exe -setreg CA\CRLPeriod "Weeks"
certutil.exe -setreg CA\CRLOverlapPeriodUnits 12
certutil.exe -setreg CA\CRLOverlapPeriod "Hours"
net stop CertSvc
net start CertSvc

Offline Root CA Setup | docs.mjcb.io

Configuration Radius NPS pour l'authentification 802.1x via EAP-TLS

Cette documentation détaille la configuration du rôle NPS (Network Policy Server) sous Windows Server 2022 afin d'authentifier les utilisateurs ou ordinateurs au réseau Wifi. On peut également l'adapter pour la connexion filaire (non détaillée ici). 

Parmi les méthodes d'authentification, le PEAP-TLS est la méthode la plus sécurisée, mais rarement supportée. De plus, elle chiffre la communication de la clé publique, qui n'a pas trop de sens.

image.png

Vous trouverez plus d'informations ici : Protocole EAP (Extensible Authentication Protocol) pour l’accès réseau dans Windows | Microsoft Learn

Après l'installation du rôle NPS, on définit la stratégie réseau comme ceci :

image.png

image.png

image.png

Le "TLS" de "EAP-TLS" correspond à "Microsoft: Smart Card or other certificate".

image.png

On clique sur "Microsoft: Smart Card or other certificate" et "Modifier..." :

image.png

Cela correspond au PEAP-TLS (ou également dit PEAP-EAP-TLS).

image.png

Dans mon cas, j'ai du ajouter l'attribut "Framed-MTU" avec une valeur de 1344, car j'ai l'erreur suivante :

Authentication failed due to an EAP session timeout; the EAP session with the access client was incomplete.

Vous pouvez observer les logs dans l'observateur d'évènements, sous "Affichages Personnalisés" > "Rôles de serveurs" > Services de stratégie et d'accès réseau".

image.png

image.png

On ajoute également le(s) client(s) RADIUS en définissant un secret partagé.

Dans les bornes wifi, on choisit WPA2 Entreprise (ou WPA3 Entreprise si supporté), en renseignant l'adresse IP du serveur NPS et le secret partagé.

Déploiement du wifi 802.1x PEAP-TLS par GPO

On peut connecter les ordinateurs aux réseaux Wifi par GPO automatiquement.

On crée et lie une GPO à une OU Ordinateurs puis on la modifie.

Sous "Configuration ordinateurs" > "Stratégies" > "Paramètres Windows" > "Paramètres de sécurité" > "Stratégies de réseau sans fil (IEEE 802.11)", on y crée une stratégie.

On ajoute nos réseaux wifi :

image.png

 

image.png

On choisit "Microsoft: PEAP (Protected EAP)" puis dans ses propriétés "Carte à puce ou autre certificat".

image.png

image.png

 

Audit et sécurisation (hardening) d'AD CS

Il est important que notre PKI soit sécurisée. Il existe différents outils permettant de l'auditer : Certipy, Exegol, PSPKIAudit ou encore Locksmith

Exemple de Certify et Certipy :

C:\>certify find /vulnerable

   _____          _   _  __
  / ____|        | | (_)/ _|
 | |     ___ _ __| |_ _| |_ _   _
 | |    / _ \ '__| __| |  _| | | |
 | |___|  __/ |  | |_| | | | |_| |
  \_____\___|_|   \__|_|_|  \__, |
                             __/ |
                            |___./
  v1.0.0

[*] Action: Find certificate templates
[*] Using the search base 'CN=Configuration,DC=ad,DC=khroners,DC=fr'

[*] Listing info about the Enterprise CA 'Khroners Labs Enterprise CA'

    Enterprise CA Name            : Khroners Labs Enterprise CA
    DNS Hostname                  : SRV-CA35-01.ad.khroners.fr
    FullName                      : SRV-CA35-01.ad.khroners.fr\Khroners Labs Enterprise CA
    Flags                         : SUPPORTS_NT_AUTHENTICATION, CA_SERVERTYPE_ADVANCED
    Cert SubjectName              : CN=Khroners Labs Enterprise CA, DC=ad, DC=khroners, DC=fr
    Cert Thumbprint               : 8FD1AEAF57EE974EB726D884775133B4D4C9D270
    Cert Serial                   : 1500000004A03185E3D30CA7C3000000000004
    Cert Start Date               : 02/10/2023 08:09:54
    Cert End Date                 : 02/10/2028 08:19:54
    Cert Chain                    : CN=KhronersLabsCertificateAuthority -> CN=KhronersLabsEnterpriseCA,DC=ad,DC=khroners,DC=fr
    UserSpecifiedSAN              : Disabled
    CA Permissions                :
      Owner: BUILTIN\Administrateurs       S-1-5-32-544

      Access Rights                                     Principal

      Allow  Enroll                                     AUTORITE NT\Utilisateurs authentifiésS-1-5-11
      Allow  ManageCA, ManageCertificates               BUILTIN\Administrateurs       S-1-5-32-544
      Allow  ManageCA, ManageCertificates               AD\Admins du domaine          S-1-5-21-1812995439-3560927909-1751902240-512
      Allow  ManageCA, ManageCertificates               AD\Administrateurs de l'entrepriseS-1-5-21-1812995439-3560927909-1751902240-519
    Enrollment Agent Restrictions : None

[+] No Vulnerable Certificates Templates found!



Certify completed in 00:00:00.5455163
certipy find -u gilles.besson@ad.khroners.fr -password Password -scheme ldap

Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 36 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 14 enabled certificate templates
[*] Trying to get CA configuration for 'Khroners Labs Enterprise CA' via CSRA
[!] Got error while trying to get CA configuration for 'Khroners Labs Enterprise CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error.
[*] Trying to get CA configuration for 'Khroners Labs Enterprise CA' via RRP
[!] Failed to connect to remote registry. Service should be starting now. Trying again...
[*] Got CA configuration for 'Khroners Labs Enterprise CA'
[*] Saved BloodHound data to '20231007001536_Certipy.zip'. Drag and drop the file into the BloodHound GUI from @ly4k
[*] Saved text output to '20231007001536_Certipy.txt'
[*] Saved JSON output to '20231007001536_Certipy.json'

3 fichiers sont ensuite générés. On peut analyser nous même le txt ou importer dans BloodHound GUI le .zip.