[SECURITY] ทดสอบ Secure Configuration บน RedHat 8.X โดย OpenSCAP

ช่วงนี้เจอปัญหาเยอะด้าน TOR ครับ ยังไงต้องตรวจดีๆครับ จากเดิม Wording เดียวกับลูกค้าทำ VA Scan แต่มาอีกโครงการตีความไปเป็นทาง Vendor ทำ VA Scan ครับ เศร้าเลยครับ แต่ในโชคร้ายยังมีดีอยู่ครับ ตอนแรกเข้าใจว่าต้องหา Tool VA Scan แบบแพงๆ แล้วครับ แต่พอดูอ้าว เรามีซื้อ RedHat Subscription ไว้ครับ เสียเงินแล้ว มี Tool ที่ทำ VA Scan ช่วยตรวจสอบ Config ของ OS ครับ

Secure Configuration คือ อะไร

  • คำนี้หลายคนอาจจะไม่คุ้นเคยครับ ถ้าบอกว่า Hardening หลายคนร้อง อ๋อกันแล้วครับ
  • Secure Configuration = Hardening คือ การตั้งค่าของระบบตาม Base Practice ด้าน Security โดยมีคนออกมาตรฐานออกมาหลายเจ้าครับ
  • สำหรับโครงการที่ผมทำมาใช้มาตรฐาน CIS Red Hat Enterprise Linux 8 Benchmark 1.0

OpenSCAP คือ อะไร

  • Tool ที่ช่วยในทำ VA Scan เพื่อช่วยตรวจสอบ Secure Configuration ว่าได้ทำควรสมบูรณ์ไหม และตรวจสอบช่วงโหว่ของ Service หากพบจากฐานข้อมูลของตัว Tools ครับ
  • Tool นี้เป็น Open Source ครับ แต่เพราะเป็น RedHat เลยต้องมี Subscription ถึงจะติดตั้งได้สะดวกครับ

ติดตั้ง OpenSCAP

  • เนื่องจากตัว Tool เป็น Command-Line Base ครับ และเครื่องที่ถูก Scan ต้องติดตั้ง Package เพิ่มเติมด้วยสิทธิ root โดยใช้คำสั่ง ดังนี้
dnf install openscap-scanner scap-security-guide
  • กรณีที่ไม่มี RedHat Subscription ผูกกับตัวเครื่องที่ถูก Scan สามารถเอาเครืองที่มี RedHat Subscription Download Package
    • สร้าง Folder oscapinstall แล้ว cd เข้าไป
    • Download Package แบบ Offline โดยใช้ yumdownloader คำสั่งดังนี้
      yumdownloader openscap-scanner scap-security-guide --resolve
    • FTP เอา Folder oscapinstall ออกมา และนำไปวางที่เครื่องที่ถูกสแกน
    • Login เข้าไปยังเครื่องที่ถูกสแกนด้วยสิทธิ root แล้วเข้าไป Folder oscapinstall และติดตั้ง โดยใช้คำสั่ง
      yum localinstall -y *.rpm
  • ตัว Package ที่เราติดตั้งมี 2 ตัว
    • openscap-scanner (openscap-scanner-1.3.3-6.el8_3.x86_64.rpm / openscap-1.3.3-6.el8_3.x86_64.rpm) เป็น Engine ของเครื่องมือสำหรับ Scan
    • scap-security-guide (scap-security-guide-0.1.50-16.el8_3.noarch.rpm) คือ ฐานข้อมูลความเสี่ยงต่างๆที่เกิดขึ้น รวมถึงคำแนะนำในการแกไข หากเข้าข่ายครับ โดยเจ้า CIS Red Hat Enterprise Linux 8 Benchmark 1.0 ถูกบรรจุไว้ในนี้ด้วยครับ

OpenSCAP ทำ VA Scan กันครับ

  • รูปแบบคำสั้ง oscap [option] --profile [ชื่อ Profile กรณีที่ Custom] --results [ชื่อไฟล์ Result.xml] --report [กำหนดชื่อ Report.html] [Database Profile ที่ใช้งานครับ]
  • ตัวอย่าง: Scan โดยใช้ Profile ของ RedHat 8.X คำสั้ง ดังนี้
 oscap oval eval --report vulnerability.html /usr/share/xml/scap/ssg/content/ssg-rhel8-oval.xml
  • แต่จากหัว Blog ผมใช้ CIS Red Hat Enterprise Linux 8 Benchmark 1.0 ต้องมีการค้นหากันหน่อยครับ ว่ามี Database ไหมครับ โดยใช้คำสั่ง
oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml | grep "Title:"
  • เมื่อพบว่ามีแล้ว เรามาโมคำสั่งที่ใช้ Scan นิดนึงครับ
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results scan_serverresults.xml --report serverresults.html /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
  • ปกติเวลา Scan ใช้เวลาประมาณ 10-20 นาที ครับ แล้วแต่ความเร็วของเครื่องครับ ถ้าใช้กลัว Putty ที่สั่งหลุดใช้ nohup <คำสั่ง> เพื่อให้มันเป็น Background Process ได้ครับ ตามนี้
nohup oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results scan_serverresults.xml --report serverresults.html /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
  • ตัวอย่าง Report ที่ได้ครับ

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.