开发安全之:Cookie Security: Cookie not Sent Over SSL

Overview

程序创建了 Cookie,但未将 <code>Secure</code> 标记设置为 <code>true</code>。

Details

现今的 Web 浏览器支持每个 cookie 的 Secure 标记。如果设置了该标记,那么浏览器只会通过 HTTPS 发送 cookie。通过未加密的通道发送 cookie 将使其受到网络截取攻击,因此安全标记有助于保护 cookie 值的保密性。如果 cookie 包含私人数据或带有会话标识符,那么该标记尤其重要。

示例 1:以下代码会在未设置 Secure 标记的情况下将 cookie 添加到响应中。 ... setcookie("emailCookie", $email, 0, "/", "www.example.com"); ... 如果应用程序同时使用 HTTPS 和 HTTP,但没有设置 Secure 标记,那么在 HTTPS 请求过程中发送的 cookie 也会在随后的 HTTP 请求过程中被发送。攻击者随后可截取未加密的网络信息流(通过无线网络时十分容易),从而危及 cookie 安全。

Recommendations

对所有新 cookie 设置 Secure 标记,指示浏览器不要以明文形式发送这些 cookie。通过将 true 作为第六个参数传递给 setcookie(),便可完成此配置。

示例 2:以下代码会通过将 Secure 标记设置为 true 来更正Example 1 中的错误。 setcookie("emailCookie", $email, 0, "/", "www.example.com", TRUE);

相关推荐

  1. 开发安全:SQL Injection

    2024-01-18 10:38:04       50 阅读
  2. 开发安全:Path Manipulation

    2024-01-18 10:38:04       65 阅读
  3. 开发安全:XML Injection

    2024-01-18 10:38:04       50 阅读
  4. 开发安全:Header Manipulation

    2024-01-18 10:38:04       51 阅读
  5. 开发安全:split()安全漏洞

    2024-01-18 10:38:04       56 阅读
  6. 开发安全:Access Control: Database

    2024-01-18 10:38:04       63 阅读
  7. 开发安全:System Information Leak: External

    2024-01-18 10:38:04       52 阅读
  8. 开发安全Dangerous File Inclusion

    2024-01-18 10:38:04       47 阅读
  9. 开发安全:Server-Side Request Forgery

    2024-01-18 10:38:04       48 阅读
  10. 开发安全:Cross-Site Scripting: DOM

    2024-01-18 10:38:04       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-18 10:38:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-18 10:38:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-18 10:38:04       87 阅读
  4. Python语言-面向对象

    2024-01-18 10:38:04       96 阅读

热门阅读

  1. 将一个数组中的元素轮转

    2024-01-18 10:38:04       51 阅读
  2. 03 SpringBoot整合MVC+Application.yaml的Web配置

    2024-01-18 10:38:04       57 阅读
  3. .Net 全局过滤,防止SQL注入

    2024-01-18 10:38:04       55 阅读
  4. apache seatunnel web 安装部署

    2024-01-18 10:38:04       56 阅读
  5. 有关引入介绍

    2024-01-18 10:38:04       55 阅读
  6. android 中一个app中打开另一个app

    2024-01-18 10:38:04       60 阅读
  7. 基于kubernetes部署MySQL主从环境

    2024-01-18 10:38:04       45 阅读