secure-coding
Input validation, output encoding, buffer safety, integer overflow, format strings
- License 许可
- MIT
- 所属仓库
- poppyTM/oride
- 最近更新
- 2026-09-30
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- secure-coding
- description
- Input validation, output encoding, buffer safety, integer overflow, format strings
02 资源文件 10
- 参考文档checks/secure-coding-checklist.md1.6 KB
- 参考文档examples/sql_injection_prevention.md1.7 KB
- 参考文档examples/sql-injection-prevention.md148 B
- 参考文档manifest.json1.8 KB
- 参考文档references/owasp-secure-coding-practices.md2.2 KB
- 参考文档references/owasp-top-10.md127 B
- 脚本scripts/run-sast.sh73 B
- 脚本scripts/sast_wrapper.sh207 B
- 脚本scripts/verify.sh4.0 KB
- 参考文档templates/secure-coding-report.md1.1 KB
03 SKILL.md 正文
Secure Coding Practices
1. Input Validation
Implement strict allow-list validation for all external input. Validate data type, length, format, and range. Reject any input that does not conform to expected patterns. Never rely solely on client-side validation.
2. Output Encoding
Contextually encode all user-controllable data before rendering it in a browser, injecting it into a command, or inserting it into a database query. This is the primary defense against injection attacks like XSS.
3. Buffer Safety
When using memory-unsafe languages (C/C++), rigidly control buffer boundaries. Avoid unsafe functions like strcpy or sprintf. Use safe alternatives (strncpy, snprintf) and strictly validate lengths to prevent buffer overflows.
4. Integer Overflows
Be vigilant against integer overflows and underflows, which can bypass logic checks or cause memory corruption. Use safe math libraries or compiler flags that trap on overflow, especially when calculating buffer sizes or array indices.
5. Format String Vulnerabilities
Never pass user-controlled data directly as the format string parameter to logging or formatting functions (e.g., printf in C, logging in Python). Always use static format strings and pass user data as arguments.
6. Parameterized Queries
Prevent SQL Injection by exclusively using parameterized queries or prepared statements. Never concatenate untrusted data into SQL strings, regardless of any escaping mechanisms applied.
7. Safe Deserialization
Avoid deserializing complex objects from untrusted sources if possible. If required, use safe serialization formats (JSON, Protobuf) rather than language-native binary formats (Java Serialization, Python Pickle) which can lead to Remote Code Execution.
8. Cryptographic Agility
Do not roll your own crypto. Use standard, well-vetted cryptographic libraries. Implement cryptographic agility: design systems so that algorithms and key sizes can be easily upgraded if a vulnerability is discovered.
9. Fail Securely
Ensure systems fail into a secure state. If an authorization check fails or throws an exception, the default action must be to deny access. Never fail open.
10. Least Privilege Enforcement
Apply the Principle of Least Privilege at the code level. Drop unnecessary privileges immediately after use. Run processes with the minimum permissions required. Restrict file system and network access to only what is strictly necessary.
04 同仓库更多 Skills
zoom-reflow
暂无简介
wireframe-styleguide
暂无简介
visual-regression
Pixel-by-pixel snapshot testing, Playwright integration, dynamic content masking, deterministic font rendering, and cross-browser CI gates
ui-implementation
Component-driven UI implementation, multi-state matrix (default, hover, focus-visible, active, disabled, loading, empty, error), DTCG design tokens, responsive layout contracts, and accessibility tree mapping.
tui-editor-engine
Text buffer and editing semantics for a terminal code editor — index conversion, transaction-first editing, multi-cursor invariants, undo grouping, and large-file behaviour.
tree-sitter-context-indexing
暂无简介