content-image
ARTICLES | 25 June 2025

Shadow Credentials in Active Directory: A Silent Threat

author-image

Wisarud Wongta

Shadow Credentials in Active Directory: A Silent Threat

Introduction

Shadow Credentials เป็นเทคนิคในการโจมตีรูปแบบหนึ่งที่ทำให้ attacker สามารถแฝงตัวเข้ายึดเครื่อง computer หรือ user ที่อยู่บน environment ของ Active Directory (AD) โดยการไปแก้ไขค่าบางอย่างที่ใช้ในการยืนยันตัวตนด้วย Key Trust โดยเทคนิคนี้จะสามารถทำการโจมตีไปที่ Windows implementation of Public Key Cryptography for Initial Authentication (PKINIT) ทำให้สามารถทำการเข้าถึงเครื่อง computer หรือ user โดยที่ไม่จำเป็นต้องใช้วิธีการโจมตีที่เป็น password-based

ในบทความนี้เราจะกล่าวถึงเนื้อหาต่าง ๆ ดังนี้

  • Understanding Shadow Credentials
  • Shadow Credentials in Action
  • Mitigation and detection techniques 

Understanding Shadow Credentials

What Are Shadow Credentials?

Shadow Credentials เป็นการโจมตีที่ใช้ประโยชน์จากความสามารถของวิธีการยืนยันตัวตนทางเลือก (เช่น certificates) สำหรับ AD accounts โดยแทนที่จะขโมยรหัสผ่านหรือ hash ผู้โจมตีสามารถทำการ register key pair ไปยัง account เป้าหมาย ซึ่งทำให้สามารถ authenticate เป็นผู้ใช้คนนั้นได้โดยไม่จำเป็นต้องรู้รหัสผ่านที่แท้จริง เทคนิคนี้จะสามารถทำการโจมตีได้ก็ต่อเมื่อผู้โจมตีมีสิทธิ์ write access กับ attribute msDS-KeyCredentialLink ของเครื่องเป้าหมาย ซึ่ง msDS-KeyCredentialLink เป็น attribute ที่เก็บ cryptographic key ที่ใช้สำหรับการ authenticate

ในการ authenticate บน Active Directory Environment นั้น, NTLM และ Kerberos ทำหน้าที่เป็นโปรโตคอลในการ authenticate หลักภายในโดเมนของ Active Directory โดยทำให้มั่นใจว่ามีการตรวจสอบตัวตนของ security principal อย่างถูกต้อง ซึ่งโปรโตคอล Kerberos อาศัยการเข้ารหัสที่เรียกว่า symmetric cryptography ระหว่างไคลเอนต์และเซิร์ฟเวอร์ โดยมีการใช้ตั๋วหรือ tickets เพื่อ authenticate

เกริ่นคร่าว ๆ เกี่ยวกับ Kerberos Tickets

Kerberos มีการใช้งาน ticket สองประเภทหลัก ๆ โดยแต่ละประเภทมีบทบาทในการ authenticate ที่แตกต่างกันดังนี้:

  1. Ticket Granting Ticket (TGT): เมื่อทำการ authenticate สำเร็จ TGT จะถูกออกให้และใช้เป็นสัญลักษณ์แสดงถึงตัวตนที่ได้รับการยืนยันแล้ว
  2. Ticket Granting Service(TGS): ticket นี้จะถูกใช้โดย principal หรือตัวตนที่ได้รับการ authenticate แล้วเท่านั้น TGS ใช้สำหรับการยืนยันตัวตนกับ service ต่างๆ ภายในโดเมน ช่วยให้สามารถเข้าถึง service ต่าง ๆ ภายใน Domain ได้โดยไม่ต้องผ่านกระบวนการ authenticate ซ้ำ

ในขั้นตอนในการขอ TGT การส่ง request จาก client ไปยัง Key Distribution Centre (KDC) จะมีกระบวนการที่เรียกว่า pre-authentication ซึ่งจะมีการทำ encryption ของข้อมูลฝั่ง client โดยจะมีวิธีการอยู่สองวิธีคือ 

Symmetric Validation: โดยทั่วไปแล้ว Kerberos authentication จะมีการทำงานโดยทำการเข้ารหัส timestamp ด้วย symmetric key ที่สร้างมาจากรหัสผ่านของ client ซึ่งมีการใช้งาน encryption algorithms ต่าง ๆ เช่น RC4, DES หรือ AES128–256 เพื่อให้มั่นใจว่าในกระบวรการ authentication จะมีความปลอดภัยเพียงพอ 

Asymmetric Validation: ในการเพิ่มระดับความปลอดภัยของ Active Directory จึงมีการใช้วิธีการใหม่นอกจากการใช้ Symmetric Validation นั่นคือ PKINIT ซึ่งอนุญาตให้มีการ authenticate ผ่านวิธีการแบบ Asymmetric โดยใช้ key pair (public key, private key), Public Key Infrastructure (PKI) จะช่วยให้ KDC และ client สามารถแลกเปลี่ยน public key ของกันและกันได้โดยใช้ digital certificates ที่ถูก signed โดย entity ที่ทั้งสองฝ่ายได้สร้าง trusted agreement ไว้ ผ่าน Certification Authority (CA) ทั้งหมดนี้คือ Certificate Trust model ซึ่งจะมีความเกี่ยวข้องกับการโจมตี Shadow Credential นั่นเอง

msDS-KeyCredentialLink เป็น attribute พิเศษที่เกี่ยวข้องกับ LDAP Service ซึ่งถูกเพิ่มเข้ามาใน Windows Server 2016 โดยจะทำหน้าที่เป็น attribute ที่เก็บค่าของ public key ที่ linked กับ computer หรือ user object บนโดเมน เมื่อ certificate ถูกเชื่อมกับ machine account แล้ว ค่าของ public key ก็จะถูกเก็บไว้ภายใน attribute msDS-KeyCredentialLink นั้นเอง

โดยในการแก้ไขค่าของ attribute msDS-KeyCredentialLinkจะมีเงื่อนไขบางอย่าง คือ user objects จะไม่สามารถแก้ไข attribute ของ msDS-KeyCredentialLink ของตนเองได้ ในขณะที่ computer objects จะสามารถทำได้ แต่จะสามารถเพิ่มได้เฉพาะในกรณีที่ยังไม่มี KeyCredential อยู่แล้วเท่านั้น

และเมื่อผู้ใช้มีสิทธิ์ GenericAll, GenericWrite หรือ WriteAccountRestrictions ใน Discretionary Access Control List หรือ DACL สำหรับ object นั้น ๆ ซึ่งอาจเป็นได้ทั้ง computer หรือ user account ผู้ใช้คนดังกล่าวจะสามารถแก้ไข attribute ของ object ได้ซึ่งรวมถึงการแก้ไข attribute msDS-KeyCredentialLinkของ object เป้าหมายให้เป็นค่าของ public key ที่ต้องการได้ ซึ่งหากมีการตั้งค่าที่ผิดพลาดก็อาจจะทำให้มีความเสี่ยงในการถูกโจมตีด้วย Shadow Credential นั้นเอง

Why Are They Dangerous?

  • Persistence: Attacker จะยังคงมีสิทธิ์ในการเข้าถึงแม้ว่าจะมีการเปลี่ยนรหัสผ่านของเครื่องที่ถูกโจมตีแล้ว
  • Stealth: ไม่มีการแก้ไขรหัสผ่านได ๆ ทำให้ยากต่อการถูกตรวจจับ

Shadow Credentials in Action

Pre-requisites

  1. Domain Controller ต้องเป็น Windows Server 2016 ขึ้นไป
  2. Domain Controller ต้องมีการใช้งาน certificate สำหรับ authentication (มีการใช้งาน AD CS)
  3. สามารถเข้าถึงหรือมี account ที่มีสิทธิ์ในการแก้ไข attribute msDS-KeyCredentialLink ของเครื่องเป้าหมาย

How Attackers Exploit Shadow Credentials

  1. Obtain Write Access: attacker ต้องมีสิทธิ์ในการแก้ไขค่า attribute msDS-KeyCredentialLink ของ เป้าหมาย (เป็นได้ทั้ง user และ computer)
  2. Generate a Key Pair: attacker ทำการสร้าง asymmetric key pair (public and private keys)
  3. Register the Key: เพิ่มค่า public key ที่ทำการสร้างในขั้นตอนก่อนหน้าและนำไปแทนที่ใน attributute msDS-KeyCredentialLink ของเป้าหมาย
  4. Authenticate as the Target: attacker ก็จะสามารถทำการ authenticate ด้วย PKINIT เป็น user ได้เลยโดยไม่จำเป็นต้องรู้รหัสผ่าน

Hands-On: Exploiting Shadow Credentials with whisker

Whisker เป็นเครื่องมือที่ช่วยในการโจมตี Shadow Credential แบบอัตโนมัติ ถูกพัฒนาด้วยภาษา C# เป็น 1 ในเครื่องมือภายในโปรเจค DSInternal ที่ถูกพัฒนาโดยคุณ Michael Grafnetter, Whisker จะช่วยในการ add, replace attribute msDS-KeyCredentialLink ให้กับ user โดยอัตโนมัติ

สำหรับตัวอย่างจาก Bloodhound ด้านล่างจะเห็นว่า user "Shadow" มีสิทธิ์ "AddKeyCredentialLink" กับ user "Sonic" ดังนั้นเราจะทำการใช้งานเครื่องมือนี้บน workstation ของ user "Shadow" เพื่อทำการแก้ไขค่า msDS-KeyCredentialLink ของ user "Sonic"

เริ่มด้วยการ list keycredential ของ user "Sonic" ด้วยคำสั่งด้านล่าง

.\Whisker.exe list /target:<target>

จากผลลัพธ์ของการใช้คำสั่งจะเห็นว่า user "Sonic" มีข้อมูล publickey อยู่ที่ attribute msDS-KeyCredentialLink

จากนั้นทำการสั่งใช้งานให้ whisker ทำการสร้าง certificate และทำการ add Public key ไปยัง attribute msDS-KeyCredentialLink ของ user "Sonic"

.\Whisker.exe add /target:<target> /domain:<domain> /dc:<dc_ip>

จะเห็นว่าเมื่อ Whikser ทำงานเสร็จสิ้น จะมีการสร้างคำสั่ง Rubeus ที่ใช้ในการดึง password มาให้ด้วย โดยการใช้ certificate เพื่อทำการร้องขอ TGT และนำไปดึงข้อมูล password ของ user นั่นเอง

ก็เป็นอันเสร็จสิ้นขั้นตอนการโจมตีด้วยวิธีการ Shadow Credential Attacks  โดยหลังจากนี้จะเป็นการแสดงตัวอย่างการขยายผลด้วยวิธีการโจมตีข้างต้น ด้วยการใช้งานเครื่องมือ Rubeus ในการ show credential ของ user "Sonic" 

Rubeus.exe asktgt /user:sonic /certificate:<certfromwhisker> /password:"Le5kc2QjNAEajuRH" /domain:VAULT.TEC /dc:SANTA-MONICA.VAULT.TEC /getcredentials /show

หรือสามารถนำ certificate มา pass the ticket เพื่อ impersonate ไปเป็น user "Sonic" ก็ได้เช่นเดียวกัน

Rubeus.exe asktgt /user:sonic /certificate:<certfromwhisker> /password:"Le5kc2QjNAEajuRH" /domain:VAULT.TEC /dc:SANTA-MONICA.VAULT.TEC /ptt

ด้วยวิธีการดังกล่าวจะทำให้ผู้โจมตีทำการ compromise account ได้ถึงแม้ว่าจะไม่ทราบ credential ใด ๆ เลย และถึงแม้ว่า account ที่ถูก compromise จะมีการเปลี่ยนรหัสผ่าน ผู้โจมตีก็ยังสามารถที่จะใช้งาน certificate ที่สร้างขึ้นเพื่อ impersonate เป็น user นั้นได้อยู่ดี


Detection & Prevention

How to Detect Shadow Credentials

  • Monitor msDS-KeyCredentialLink Changes: ทำการตรวจสอบ event logs หากมีการแก้ไขค่า attribute
  • Audit Write Permissions: ตรวจสอบ users/groups ที่มีสิทธิ์ในการเขียนหรือแก้ไขค่า msDS-KeyCredentialLink อย่างสม่ำเสมอ

How to Prevent Shadow Credential Attacks

  • Restrict Write Access: ทำการจำกัดไม่ให้มีการแก้ไข attribute msDS-KeyCredentialLink โดย user ที่ไม่สมควรแก้ไข
  • Implement Certificate-Based Authentication Monitoring: ติดตามกระบวนการ authentication ที่ไม่ได้มาตรฐาน

Conclusion

Shadow Credential เป็นวิธีการโจมตีบน Activie Directory Enviroment ที่มีความรุนแรงและยังสามารถถูกตรวจจับได้ยาก ซึ่งการทำความเข้าใจการทำงานของการโจมตีดังกล่าว, วิธีที่ attacker จะนำไปใช้, การตรวจจับและการป้องกันการโจมตีนี้ก็ถือเป็นส่วนสำคัญที่จะทำให้สามารถทำการป้องกันการโจมตีนี้ได้

logologo

INCOGNITO LAB CO., LTD.

38 Soi Petchakasem 30, Petchakasem Road, Pak Khlong Phasi Charoen, Phasi Charoen, Bangkok 10160

©2025 Incognito Lab Co., Ltd. All rights reserved

Terms & Conditions Privacy Policy