ข้ามไปเนื้อหาหลัก
Security

OWASP Top 10 สำหรับนักพัฒนา PHP: สิ่งที่ต้องเช็กก่อน Deploy

สรุป OWASP Top 10 ในมุมนักพัฒนา PHP พร้อม Checklist สั้น ๆ ที่ใช้ตรวจระบบก่อนขึ้น Production ได้ทันที

AI Pairoj อ่าน 2 นาที 158 ครั้ง

OWASP Top 10 คือรายการความเสี่ยงด้านความปลอดภัยของ Web Application ที่พบบ่อยที่สุด นักพัฒนา PHP ควรใช้เป็น Checklist ก่อน Deploy ทุกครั้ง

Checklist ก่อน Deploy

ความเสี่ยงสิ่งที่ต้องตรวจ
Broken Access Controlตรวจสิทธิ์ฝั่ง Server ทุก Endpoint
Security Misconfigurationปิด display_errors, APP_DEBUG=false
InjectionPrepared Statement ทุก Query
Cryptographic Failurespassword_hash() และ HTTPS
Insecure DesignRate limit ฟอร์ม Login / Contact
Vulnerable Componentsอัปเดต Library และ PHP
Authentication FailuresLockout, Session Regenerate
Integrity Failuresไม่ Deserialize ข้อมูลที่ไม่น่าเชื่อถือ
Logging FailuresAudit Log การกระทำสำคัญ
SSRFWhitelist ปลายทางที่ Server เรียกออกไป

XSS: Escape ทุกครั้งที่แสดงผล

function e(?string $v): string {
    return htmlspecialchars((string) $v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}

CSRF: Token ทุกฟอร์ม POST

  • สร้าง Token ด้วย random_bytes()
  • เปรียบเทียบด้วย hash_equals()

Security Headers

  • Content-Security-Policy
  • X-Frame-Options: DENY
  • X-Content-Type-Options: nosniff
  • Strict-Transport-Security (เมื่อใช้ HTTPS)

ความปลอดภัยไม่ใช่งานที่ทำครั้งเดียว ควรตรวจซ้ำทุกครั้งที่เพิ่มฟีเจอร์ใหม่

แชร์บทความ: