执行 Git 操作(提交、分支、合并、变基、冲突解决与恢复)时强制套用安全规则。
文档
security-best-practices
试用针对项目所用语言与框架获取安全审查、按优先级排序的漏洞报告与修复建议。
它能做什么
先识别项目里实际使用的语言与框架,再从对应参考文档中加载安全最佳实践,用于按默认安全的方式编写代码或在已有代码中发现重大问题。在你明确要求时,会生成按严重程度分节、附编号与代码行号引用的 Markdown 安全报告,并可按"一次一个问题"的方式逐项修复,注释中说明所依据的安全规则。对于参考库未覆盖的部分,会套用通用建议(如避免使用易猜测的自增公开 ID、注意 TLS 与 secure cookie 的边界),也允许在项目自己的文档中记录有理由的偏离。
什么时候用它
- 针对代码库申请一份按优先级排序的安全报告
- 新建项目时按默认安全的方式编写代码
- 把项目里刻意的偏离记录在文档中
- 依据参考文档逐项修复关键漏洞
技能文档
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.
-
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.
-
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.
-
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.
常见问题
- 它会在每次改动时自动运行吗?
- 不会。只有在你明确请求安全指导、安全报告或默认安全编码帮助时才会触发,不会用于普通的代码审查或调试任务。
- 输出形式是什么样的?
- 一份 Markdown 安全报告,默认写入 security_best_practices_report.md(也可由你指定路径),包含简短的执行摘要、按严重程度分节的内容、每条发现都带数字编号,以及对所引用代码的行号定位。
- 如果参考库没覆盖到我用的技术栈怎么办?
- 会回退到
相关技能
通过托管 OAuth 访问 Microsoft Graph Excel 接口,读写 OneDrive 中的工作簿、工作表、区域、表格与图表。
通过托管 OAuth 代理调用 WooCommerce REST API,管理商品、订单、客户、优惠券、物流、税务等数据。
通过托管 OAuth 连接访问 Google Analytics,运行报表并管理分析资源配置。
通过托管 OAuth 调用 Google Docs API,实现文档创建、读写与样式管理。
在已有代码库里接手需求、修复缺陷、安全上线并持续运维。
OpenAI 的更多技能
浏览全部技能用文档先行的方式为 ChatGPT Apps SDK 项目搭脚手架,覆盖 MCP 服务器、Widget UI 和工具规划。
基于源码或页面描述,创建或更新整页 Figma 界面,并复用已发布的设计系统组件、变量和样式。
按分阶段流程,将代码库中的设计系统同步到 Figma,并完成基础、组件与质量检查。
获取 OpenAI 官方开发者文档,带来源引用,并附模型选型与迁移建议。
用 C# 和 Windows App SDK 完成 WinUI 3 桌面应用的搭建、开发、审查与排障。
一键脚手架生成 Codex 插件目录,含归一化命名与可编辑占位符。