stack-trace-exposure
它能做什么
这个技能检查服务器代码和 API 响应中的错误处理,确保详细的错误信息被私下记录,而不是展示给用户。它面向希望减少攻击者能从应用中获取信息的开发者。
适用场景
- ✓你请智能体检查 API 或服务器代码中的错误处理是否安全的时候。
- ✓线上错误响应中包含堆栈跟踪、文件路径或库的细节的时候。
- ✓你希望有一个统一的错误处理程序来处理所有路由的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/stack-trace-exposure/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“出错时,我的 API 会把完整的错误堆栈发送到浏览器。请帮我改成显示安全的提示,并把细节私下记录下来吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出原始错误对象、堆栈跟踪或内部路径被发送到客户端的地方。它会添加一个统一的错误处理程序,在服务器上记录完整细节,并返回通用消息,同时附带一个关联 ID,以便将日志与用户反馈对应起来。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prevent stack trace exposure in production error responses
Stack traces reveal file paths, function names, library versions, and sometimes database schema or configuration details. An attacker uses this information to identify the exact version of a framework or ORM, look up known CVEs for that version, and craft a targeted exploit. OWASP lists "Security Logging and Monitoring Failures" (A09) as a top-10 risk partly because organisations often expose this information without realising it.
Quick Reference
- Never return raw error objects or stack traces in API responses
- Log full error details server-side; send only a generic message to the client
- Use a central error handler to ensure consistent sanitisation across all routes
- Assign correlation IDs so support teams can match client-visible errors to server logs
Check
Check whether production API error responses include stack traces, file paths, or internal implementation details.
Fix
Implement a central error handler that logs full details server-side and returns only a sanitised, generic error message to the client.
Explain
Explain what information stack traces reveal and how attackers use that information to identify and exploit vulnerabilities.
Code Review
Review error handlers, catch blocks, and API response code. Flag any location where error.stack, error.message (raw), or internal paths are serialised directly into a response body.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/security/stack-trace-exposure
常见问题
为什么堆栈跟踪有风险?
这个技能说,它们可能泄露攻击者用来寻找已知弱点的文件路径、函数名和库版本。
什么是关联 ID?
这个技能建议将它作为参考代码,以便支持团队能将访客的错误与服务器日志对应起来。
这涵盖 OWASP 的指导吗?
这个技能提到了 OWASP 关于日志和监控风险的说明作为依据,但它的检查重点是响应中暴露了什么。
详情
作者的原始描述
Use when reviewing error handling middleware, API route handlers, or server responses for security-sensitive information disclosure.
热度
- GitHub 星标
- 75k
- 排名
- #3035
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。