การป้องกัน XSS และ XSRF
หากต้องการป้องกันการเขียนสคริปต์ข้ามเว็บไซต์ (XSS) ให้ใช้ส่วนหัว X-Content-Type-Options: nosniff
ของการตอบกลับทั้งหมด และใส่ Content-Type: application/json; charset=utf-8
ในส่วนหัวการตอบกลับด้วย
เพื่อป้องกันการปลอมแปลงคําขอแบบข้ามเว็บไซต์ (XSRF) จึงต้องใช้ส่วนหัว HTTP ชื่อ X-XSRF-Protected: 1
สําหรับคําขอทั้งหมด
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2022-09-26 UTC
[null,null,["อัปเดตล่าสุด 2022-09-26 UTC"],[[["All responses must include the `X-Content-Type-Options: nosniff` and `Content-Type: application/json; charset=utf-8` headers to mitigate cross-site scripting (XSS) vulnerabilities."],["All requests must include the `X-XSRF-Protected: 1` header to defend against cross-site request forgery (XSRF) attacks."]]],["Responses should include `X-Content-Type-Options: nosniff` and `Content-Type: application/json; charset=utf-8` headers to prevent cross-site scripting (XSS). To prevent cross-site request forgery (XSRF), all requests must include the `X-XSRF-Protected: 1` header. These actions enhance security by ensuring content types are strictly interpreted and verifying the origin of requests, thus mitigating common web vulnerabilities.\n"]]