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 |
| Injection | Prepared Statement ทุก Query |
| Cryptographic Failures | password_hash() และ HTTPS |
| Insecure Design | Rate limit ฟอร์ม Login / Contact |
| Vulnerable Components | อัปเดต Library และ PHP |
| Authentication Failures | Lockout, Session Regenerate |
| Integrity Failures | ไม่ Deserialize ข้อมูลที่ไม่น่าเชื่อถือ |
| Logging Failures | Audit Log การกระทำสำคัญ |
| SSRF | Whitelist ปลายทางที่ 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)
ความปลอดภัยไม่ใช่งานที่ทำครั้งเดียว ควรตรวจซ้ำทุกครั้งที่เพิ่มฟีเจอร์ใหม่