[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FGF15BKVKGZPRNDCBM2BAB":3,"skill-same:01M6FGF15BKVKGZPRNDCBM2BAB":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":34,"linkOnly":35,"markdownContent":36,"markdownBody":37,"frontMatter":38,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":42,"repositoryHtmlUrl":43,"repositoryHomepageUrl":44,"ownerHtmlUrl":45,"ownerBlogUrl":6,"ownerDescription":46,"updatedAt":47,"install":48,"resources":61},"01M6FGF15BKVKGZPRNDCBM2BAB","csrf-protection",null,"Implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite attributes. Use when securing web forms, protecting state-changing endpoints, or implementing defense-in-depth authentication.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcsrf-protection\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"csrf","protection","csrf protection","web","authentication","state","cookies","defense-in-depth","defense","use","endpoints","forms","tokens","submit","attributes","2026-11-10 10:12:30",false,"---\nname: csrf-protection\ndescription: Implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite attributes. Use when securing web forms, protecting state-changing endpoints, or implementing defense-in-depth authentication.\nlicense: MIT\n---\n\n# CSRF Protection\n\nDefend against Cross-Site Request Forgery attacks using multiple protection layers.\n\n## Protection Methods\n\n| Method | How It Works | Browser Support |\n|--------|--------------|-----------------|\n| Synchronizer Token | Hidden form field validated server-side | All |\n| Double Submit | Cookie + header must match | All |\n| SameSite Cookie | Browser blocks cross-origin requests | Modern |\n\n## Token-Based Protection (Express)\n\n```javascript\nconst crypto = require('crypto');\n\nfunction generateToken() {\n  return crypto.randomBytes(32).toString('hex');\n}\n\n\u002F\u002F Middleware\napp.use((req, res, next) => {\n  if (!req.session.csrfToken) {\n    req.session.csrfToken = generateToken();\n  }\n  res.locals.csrfToken = req.session.csrfToken;\n  next();\n});\n\n\u002F\u002F Validation\napp.post('*', (req, res, next) => {\n  const token = req.body._csrf || req.headers['x-csrf-token'];\n  if (!token || !crypto.timingSafeEqual(\n    Buffer.from(token),\n    Buffer.from(req.session.csrfToken)\n  )) {\n    return res.status(403).json({ error: 'Invalid CSRF token' });\n  }\n  next();\n});\n```\n\n## SameSite Cookies\n\n```javascript\napp.use(session({\n  cookie: {\n    httpOnly: true,\n    secure: true,\n    sameSite: 'strict', \u002F\u002F or 'lax'\n    maxAge: 3600000\n  }\n}));\n```\n\n## HTML Form Integration\n\n```html\n\u003Cform method=\"POST\" action=\"\u002Ftransfer\">\n  \u003Cinput type=\"hidden\" name=\"_csrf\" value=\"\u003C%= csrfToken %>\">\n  \u003Cbutton type=\"submit\">Submit\u003C\u002Fbutton>\n\u003C\u002Fform>\n```\n\n## Best Practices\n\n- Apply to all state-changing requests (POST, PUT, DELETE)\n- Use SameSite=Strict for sensitive cookies\n- Validate Origin\u002FReferer headers\n- Never use GET for modifications\n- Implement token expiration (1 hour typical)\n- Combine multiple defense layers\n\n## Additional Implementations\n\nSee [references\u002Fpython-react.md](references\u002Fpython-react.md) for:\n- Flask-WTF complete CSRF setup\n- React hooks for CSRF token management\n- Double submit cookie pattern\n\n## Common Mistakes\n\n- Assuming authentication prevents CSRF\n- Reusing tokens across sessions\n- Storing tokens in localStorage\n- Missing token expiration\n","# CSRF Protection\n\nDefend against Cross-Site Request Forgery attacks using multiple protection layers.\n\n## Protection Methods\n\n| Method | How It Works | Browser Support |\n|--------|--------------|-----------------|\n| Synchronizer Token | Hidden form field validated server-side | All |\n| Double Submit | Cookie + header must match | All |\n| SameSite Cookie | Browser blocks cross-origin requests | Modern |\n\n## Token-Based Protection (Express)\n\n```javascript\nconst crypto = require('crypto');\n\nfunction generateToken() {\n  return crypto.randomBytes(32).toString('hex');\n}\n\n\u002F\u002F Middleware\napp.use((req, res, next) => {\n  if (!req.session.csrfToken) {\n    req.session.csrfToken = generateToken();\n  }\n  res.locals.csrfToken = req.session.csrfToken;\n  next();\n});\n\n\u002F\u002F Validation\napp.post('*', (req, res, next) => {\n  const token = req.body._csrf || req.headers['x-csrf-token'];\n  if (!token || !crypto.timingSafeEqual(\n    Buffer.from(token),\n    Buffer.from(req.session.csrfToken)\n  )) {\n    return res.status(403).json({ error: 'Invalid CSRF token' });\n  }\n  next();\n});\n```\n\n## SameSite Cookies\n\n```javascript\napp.use(session({\n  cookie: {\n    httpOnly: true,\n    secure: true,\n    sameSite: 'strict', \u002F\u002F or 'lax'\n    maxAge: 3600000\n  }\n}));\n```\n\n## HTML Form Integration\n\n```html\n\u003Cform method=\"POST\" action=\"\u002Ftransfer\">\n  \u003Cinput type=\"hidden\" name=\"_csrf\" value=\"\u003C%= csrfToken %>\">\n  \u003Cbutton type=\"submit\">Submit\u003C\u002Fbutton>\n\u003C\u002Fform>\n```\n\n## Best Practices\n\n- Apply to all state-changing requests (POST, PUT, DELETE)\n- Use SameSite=Strict for sensitive cookies\n- Validate Origin\u002FReferer headers\n- Never use GET for modifications\n- Implement token expiration (1 hour typical)\n- Combine multiple defense layers\n\n## Additional Implementations\n\nSee [references\u002Fpython-react.md](references\u002Fpython-react.md) for:\n- Flask-WTF complete CSRF setup\n- React hooks for CSRF token management\n- Double submit cookie pattern\n\n## Common Mistakes\n\n- Assuming authentication prevents CSRF\n- Reusing tokens across sessions\n- Storing tokens in localStorage\n- Missing token expiration\n",{"name":5,"license":15,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fsecondsky\u002Fclaude-skills\u002Fcsrf-protection",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill csrf-protection",{"tool":54,"command":55},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill csrf-protection",{"tool":57,"command":58},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill csrf-protection","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcsrf-protection\u002FSKILL.md",true,[62],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Fpython-react.md","REFERENCE","参考文档",4217,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcsrf-protection\u002Freferences\u002Fpython-react.md",[69,78,87,96,102,108],{"skillNo":70,"name":71,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":34},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[75,76,77],"model","model hierarchy","model hierarchy skill",{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":34},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[84,85,86],"MCP","zoom","zoom mcp",{"skillNo":88,"name":89,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":34},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[93,94,95,85],"sdk","zoom apps sdk","apps",{"skillNo":97,"name":98,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":34},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[98],{"skillNo":103,"name":104,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":34},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[104],{"skillNo":109,"name":110,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":34},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[110]]