cookie中token缺失HttpOnly和Secure属性

Blade 未结 1 83
pensiero
pensiero 剑童 2025-05-29 18:07

一、该问题的重现步骤是什么?

  1. 客户安全扫描报告提出低危问题

    Cookie缺失HttpOnly标识【低危】

    Cookie缺失secure属性【低危】

    image.png


二、已经尝试的方法,对这两个cookie值无效

1、修改nginx配置

参考:    https://www.kancloud.cn/smallchill/blade-safety/3244465

            https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_flags

 

2、增加filter

参考:    https://www.kancloud.cn/smallchill/blade-safety/3244465

企业截图_17485126345775.png

3、修改配置

image.png

image.png

4、修改org.springblade.auth.config下的文件,加上addHeaderWriter

http.authorizeRequests().anyRequest().authenticated()
    .and()
    .httpBasic()
    .authenticationEntryPoint(new CustomAuthenticationEntryPoint())
    .and()
    .csrf().disable() // 禁用CSRF保护
    .headers()
        .frameOptions()
        .and()
    .addHeaderWriter(new StaticHeadersWriter("Set-Cookie", "HttpOnly; Secure")); // 设置Cookie的HttpOnly和Secure属性




三、你正在使用的是什么产品,什么版本?在什么操作系统上?

版本:BladeX2.0.0(sorry老版本,我们接手就是这个版本)


操作系统

CentOS 7.9

RHEL 7.5



四、期望结果

能在这两个cookie上加上HttpOnly, Secure





1条回答
  • 2025-05-29 18:13

    找到前端的auth.js,把cookie的操作改成localStorage


    另外请给我们邮箱:bladejava@qq.com 发一个邮件提供授权公司名,登记为商业账号后方可进行商业版问题答疑。

    作者追问:2025-05-29 19:54

    邮件已发。

    还有更简单的修改方法吗?

    作者追问:2025-05-29 20:09

    另外就算前端转使用localstorage,cookie仍然存在,安全扫描仍然过不了吧。

    0 讨论(0)
代码语言
提交回复