文档

security-best-practices

试用

针对 Python、JavaScript/TypeScript、Go 项目,按语言与框架的安全最佳实践做审查并给出改进建议。

它能做什么

先识别项目范围内所有语言与框架(前后端都算),再从 references 目录加载对应文档,包括与框架无关的通用文件和 javascript-general-web-frontend-security.md。它有三种用法:直接编写默认安全的代码、在写代码过程中被动标记高影响漏洞、以及按用户要求输出报告。报告默认写到 security_best_practices_report.md,含简短摘要、按严重程度分节、编号的发现项、关键问题的一句话影响说明,并标注代码行号。修复按单条发现逐个进行,注释中说明依据的最佳实践,并会评估对现有功能和测试流程的影响。

什么时候用它

  • 新项目起步,希望从第一行代码就采用安全默认配置
  • 对已有仓库做一次安全审查并要一份报告
  • 前后端都有的 Web 应用,需要同时覆盖两端的加固建议
  • 日常开发中被动发现关键漏洞,希望先解释再修复

技能文档

Security Best Practices

Overview

This skill provides a description of how to identify the language and frameworks used by the current context, and then to load information from this skill's references directory about the security best practices for this language and or frameworks.

This information, if present, can be used to write new secure by default code, or to passively detect major issues within existing code, or (if requested by the user) provide a vulnerability report and suggest fixes.

Workflow

The initial step for this skill is to identify ALL languages and ALL frameworks which you are being asked to use or already exist in the scope of the project you are working in. Focus on the primary core frameworks. Often you will want to identify both frontend and backend languages and frameworks.

Then check this skill's references directory to see if there are any relevant documentation for the language and or frameworks. Make sure you read ALL reference files which relate to the specific framework or language. The format of the filenames is ---security.md. You should also check if there is a -general--security.md which is agnostic to the framework you may be using.

If working on a web application which includes a frontend and a backend, make sure you have checked for reference documents for BOTH the frontend and backend!

If you are asked to make a web app which will include both a frontend and backend, but the frontend framework is not specified, also check out javascript-general-web-frontend-security.md. It is important that you understand how to secure both the frontend and backend.

If no relevant information is available in the skill's references directory, think a little bit about what you know about the language, the framework, and all well known security best practices for it. If you are unsure you can try to search online for documentation on security best practices.

From there it can operate in a few ways.

  1. The primary mode is to just use the information to write secure by default code from this point forward. This is useful for starting a new project or when writing new code.

  2. The secondary mode is to passively detect vulnerabilities while working in the project and writing code for the user. Critical or very important vulnerabilities or major issues going against security guidance can be flagged and the user can be told about them. This passive mode should focus on the largest impact vulnerabilities and secure defaults.

  3. The user can ask for a security report or to improve the security of the codebase. In this case a full report should be produced describe anyways the project fails to follow security best practices guidance. The report should be prioritized and have clear sections of severity and urgency. Then offer to start working on fixes for these issues. See #fixes below.

Workflow Decision Tree

  • If the language/framework is unclear, inspect the repo to determine it and list your evidence.
  • If matching guidance exists in references/, load only the relevant files and follow their instructions.
  • If no matching guidance exists, consider if you know any well known security best practices for the chosen language and or frameworks, but if asked to generate a report, let the user know that concrete guidance is not available (you can still generate the report or detect for sure critical vulnerabilities)

Overrides

While these references contain the security best practices for languages and frameworks, customers may have cases where they need to bypass or override these practices. Pay attention to specific rules and instructions in the project's documentation and prompt files which may require you to override certain best practices. When overriding a best practice, you MAY report it to the user, but do not fight with them. If a security best practice needs to be bypassed / ignored for some project specific reason, you can also suggest to add documentation about this to the project so it is clear why the best practice is not being followed and to follow that bypass in the future.

Report Format

When producing a report, you should write the report as a markdown file in security_best_practices_report.md or some other location if provided by the user. You can ask the user where they would like the report to be written to.

The report should have a short executive summary at the top.

The report should be clearly delineated into multiple sections based on severity of the vulnerability. The report should focus on the most critical findings as these have the highest impact for the user. All findings should be noted with an numeric ID to make them easier to reference.

For critical findings include a one sentence impact statement.

Once the report is written, also report it to the user directly, although you may be less verbose. You can offer to explain any of the findings or the reasons behind the security best practices guidance if the user wants more info on any findings.

Important: When referencing code in the report, make sure to find and include line numbers for the code you are referencing.

After you write the report file, summarize the findings to the user.

Also tell the user where the final report was written to

Fixes

If you produced a report, let the user read the report and ask to begin performing fixes.

If you passively found a critical finding, notify the user and ask if they would like you to fix this finding.

When producing fixes, focus on fixing a single finding at a time. The fixes should have concise clear comments explaining that the new code is based on the specific security best practice, and perhaps a very short reason why it would be dangerous to not do it in this way.

Always consider if the changes you want to make will impact the functionality of the user's code. Consider if the changes may cause regressions with how the project works currently. It is often the case that insecure code is relied on for other reasons (and this is why insecure code lives on for so long). Avoid breaking the user's project as this may make them not want to apply security fixes in the future. It is better to write a well thought out, well informed by the rest of the project, fix, then a quick slapdash change.

Always follow any normal change or commit flow the user has configured. If making git commits, provide clear commit messages explaining this is to align with security best practices. Try to avoid bunching a number of unrelated findings into a single commit.

Always follow any normal testing flows the user has configured (if any) to confirm that your changes are not introducing regressions. Consider the second order impacts the changes may have and inform the user before making them if there are any.

General Security Advice

Below is a few bits of secure coding advice that applies to almost any language or framework.

Avoid Using Incrementing IDs for Public IDs of Resources

When assigning an ID for some resource, which will then be used by exposed to the internet, avoid using small auto-incrementing IDs. Use longer, random UUID4 or random hex string instead. This will prevent users from learning the quantity of a resource and being able to guess resource IDs.

A note on TLS

While TLS is important for production deployments, most development work will be with TLS disabled or provided by some out-of-scope TLS proxy. Due to this, be very careful about not reporting lack of TLS as a security issue. Also be very careful around use of "secure" cookies. They should only be set if the application will actually be over TLS. If they are set on non-TLS applications (such as when deployed for local dev or testing), it will break the application. You can provide a env or other flag to override setting secure as a way to keep it off until on a TLS production deployment. Additionally avoid recommending HSTS. It is dangerous to use without full understanding of the lasting impacts (can cause major outages and user lockout) and it is not generally recommended for the scope of projects being reviewed by codex.

常见问题

支持哪些语言和框架?
范围限定在 Python、JavaScript/TypeScript 和 Go。它会先识别项目里实际用到的语言和框架,再加载对应的参考文档;前端框架未指定时会参考 javascript-general-web-frontend-security.md。
什么时候会触发?
只有用户明确要求安全最佳实践指导、安全审查/报告,或默认安全编码帮助时才触发。普通代码审查、调试和非安全类任务不会触发。
报告里有什么?
默认生成 security_best_practices_report.md,包含简短摘要、按严重程度划分的章节、每条发现的数字编号、关键发现的一句话影响说明,以及所引用代码的行号。写完后会向你概述结论并告知文件位置。
缺少 TLS 或 secure cookie 会被报为问题吗?
文档明确要求谨慎处理:一般不应把缺少 TLS 当作安全问题上报;secure cookie 只在应用确实走 TLS 时才设置;也不建议使用 HSTS。项目自身文档中要求覆盖某条最佳实践时,它会遵循项目约定而不是强行修改。

相关技能

执行 Git 操作(提交、分支、合并、变基、冲突解决与恢复)时强制套用安全规则。

作者 Iván534 次安装31 星标

按「收集上下文—逐节打磨—读者测试」三阶段,陪你从零写出一份结构化文档。

作者 Anthropic181.1k 星标

pptx

官方

创建、编辑和读取 .pptx 与 .potx 文件,并提供缩略图、复制幻灯片、清理和校验脚本。

作者 Anthropic181.1k 星标

xlsx

官方

用真实公式创建、编辑并校验 .xlsx、.xlsm、.csv、.tsv 文件,并完成重算。

作者 Anthropic181.1k 星标

基于 OpenAI 官方文档回答构建、选型与 Codex 问题,并给出引用来源。

作者 OpenAI28.1k 星标

gh-fix-ci

官方

Use when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft a fix plan, and implement only after exp

作者 OpenAI28.1k 星标

OpenAI 的更多技能

浏览全部技能

为 ChatGPT Apps SDK 项目生成 MCP 服务器与 widget UI 脚手架,并支持重构与排错。

作者 OpenAI28.1k 星标

复用 Figma 文件中已发布的设计系统组件、变量与样式,创建或更新整页屏幕。

作者 OpenAI28.1k 星标

按阶段把代码库转成 Figma 设计系统,每个阶段都有你确认的检查点。

作者 OpenAI28.1k 星标

figma-use

官方

在 Figma 文件里执行 JavaScript 调用 Plugin API,创建、修改和读取节点。

作者 OpenAI28.1k 星标

hatch-pet

官方

根据概念、品牌线索或参考图,生成 Codex 可用的动画宠物精灵图集。

作者 OpenAI28.1k 星标

imagegen

官方

为项目生成或编辑位图图像,并把选定的成品保存到工作区。

作者 OpenAI28.1k 星标