Files
vibe_coding/.cursor/rules/026-secure-coding.mdc
2026-03-05 21:27:11 +08:00

45 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: >
安全编码规范 — 开发时主动安全实践Secure by Default
基于 Project CodeGuard 框架,覆盖注入防护、加密算法、访问控制、会话安全、
客户端安全和文件上传。编写 PHP 或 TypeScript/Vue 代码时自动应用。
globs:
- "**/*.php"
- "**/*.ts"
- "**/*.vue"
alwaysApply: false
---
# 🔐 Secure Coding Standards (Core)
## 总原则
- 外部输入默认不可信
- 安全优先于便捷Secure by Default
- 敏感操作必须有鉴权、审计与告警
## 必须遵守
- 禁用弱算法MD5/SHA1/DES/3DES/RC4/AES-ECB
- 注入防护SQL/命令/模板注入全面参数化与白名单
- 访问控制:每个资源接口都做所有权/权限校验
- 会话安全HttpOnly + Secure + SameSite避免 token 泄漏
- 文件上传:校验扩展名 + MIME + magic bytes隔离存储
## 前后端协同
- 前端不信任本地状态作为权限依据
- 后端做最终授权裁决
- 错误提示不暴露内部实现细节
## 验证清单
- [ ] 关键接口已做输入验证与授权
- [ ] 无禁用算法与危险函数
- [ ] 会话与凭证存储符合安全基线
- [ ] 上传与下载链路具备安全防护
## Tier 3 深度参考
- `.cursor/rules/references/026-secure-coding-deep.md` — 完整安全编码规范与示例