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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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.
热度
- GitHub 星标
- 75k
- 排名
- #3017
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。