跳到正文
Skillpedia
安全75k · #3017

session-cookie-flags

它能做什么

这个技能检查让用户保持登录的 Cookie,并设置保护它们的安全标志。它面向管理身份验证和服务器配置的开发者。

适用场景

  • ✓你请智能体检查登录或会话系统设置的 Cookie 的时候。
  • ✓你的网站设置会话 Cookie 时没有安全标志的时候。
  • ✓你添加身份验证中间件,并希望从一开始就安全地配置 Cookie 的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/session-cookie-flags/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/session-cookie-flags/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我检查登录系统设置的会话 Cookie,并添加 Secure、HttpOnly 和 SameSite 标志吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查 Set-Cookie 响应头和 Cookie 创建代码。它会添加 Secure,使 Cookie 只通过 HTTPS 发送;添加 HttpOnly,使脚本无法读取;并将 SameSite 设为 Strict 或 Lax,以限制跨站请求。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Set Secure, HttpOnly, and SameSite flags on session cookies

Missing cookie flags are one of the most common and easily fixed authentication weaknesses. Without Secure, session tokens are transmitted in plain text over HTTP and can be captured by network eavesdroppers. Without HttpOnly, any XSS payload can exfiltrate the session token in one line. Without SameSite, any website can trigger authenticated actions on behalf of the victim without their knowledge.

Quick Reference

  • Secure — cookie is only sent over HTTPS, never plain HTTP
  • HttpOnly — cookie is invisible to JavaScript (blocks XSS theft)
  • SameSite=Strict or Lax — prevents the cookie from being sent on cross-site requests (blocks CSRF)
  • Never use SameSite=None without also setting Secure and understanding the CSRF implications

Check

Check whether session and authentication cookies are set with the Secure, HttpOnly, and SameSite flags.

Fix

Update the server's cookie configuration to include Secure, HttpOnly, and SameSite=Strict (or Lax) on all session and auth cookies.

Explain

Explain what each cookie security flag does and the specific attack each one prevents.

Code Review

Review all Set-Cookie headers and cookie creation code. Flag any cookies missing the HttpOnly flag, absent Secure flag, or an unspecified or overly permissive SameSite setting.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/security/session-cookie-flags

常见问题

HttpOnly 防止什么?

这个技能说,它会对 JavaScript 隐藏 Cookie,从而阻止许多跨站脚本攻击窃取会话。

SameSite 防止什么?

这个技能说,它会阻止 Cookie 在跨站请求中被发送,有助于阻止跨站请求伪造。

什么时候可以使用 SameSite=None?

这个技能说,只有在同时设置了 Secure,并且理解了跨站请求风险的情况下才可以。

详情

作者的原始描述

Use when reviewing server-side session management, setting up authentication middleware, or auditing cookie configuration in HTTP response headers.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#3017
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能