跳到正文
Skillpedia
安全75k · #2917

leaked-secrets

它能做什么

这个技能检查客户端代码、页面源代码和项目历史,查找任何人都能看到的凭据。它面向希望保护密钥的开发者。

适用场景

  • ✓访客可以下载的 JavaScript 文件中出现 API 密钥的时候。
  • ✓可能有 .env 文件被提交到代码仓库的时候。
  • ✓你添加新服务,并希望确保其密钥保持私密的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/leaked-secrets/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/leaked-secrets/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我检查前端代码中是否有不应公开的 API 密钥或密码吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会扫描页面源代码和 JavaScript 中类似密钥的模式,并搜索项目历史中过去的泄露。它会建议把密钥移到服务器端、更换任何已暴露的密钥,并添加密钥扫描。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Leaked Environment Variables

An API key embedded in client-side JavaScript gives anyone with a browser devtools tab full access to your cloud services, databases, or third-party APIs — leading to data breaches, unexpected charges, or account takeover.

Quick Reference

  • Any secret in client-side JavaScript is publicly readable — treat all front-end code as public
  • In Next.js, only variables prefixed with NEXT_PUBLIC_ are exposed to the browser — never put secrets in these
  • Common leak locations: .env files committed to git, hardcoded API keys in JS bundles, service account credentials in window.__INITIAL_STATE__
  • Use git log -S 'keyword' to search git history for previously committed secrets; rotate any found secrets immediately
  • Tools: GitLeaks, TruffleHog, GitHub Secret Scanning can detect leaks in repositories automatically

Check

Scan the page HTML source and JavaScript bundles for patterns that look like secrets: API keys, tokens, passwords, private keys, connection strings, or credentials. Check for common patterns like sk_, pk_, AIza, ghp_, AKIA, and base64-encoded strings in unusual contexts.

Fix

Move all secrets server-side. Replace client-exposed credentials with server-side API proxies. Rotate any leaked credentials immediately — treat them as compromised. Implement git-secrets or a pre-commit hook to prevent future leaks.

Explain

Explain why client-side JavaScript is public code, how secrets leak into bundles, what the impact of a leaked API key is, and how to architect applications to keep secrets server-side.

Code Review

Review server config, headers, forms, and integration points related to Leaked Environment Variables. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/security/leaked-secrets

常见问题

为什么前端代码中的密钥有风险?

这个技能说,任何使用浏览器开发者工具的人都能读取它,并使用相关服务。

Next.js 的公共变量怎么办?

这个技能说,只有带 NEXT_PUBLIC 前缀的变量会发送到浏览器,因此密钥绝对不能使用该前缀。

泄露之后应该怎么做?

这个技能说,应该立即更换泄露的凭据,并将其视为已被入侵。

详情

作者的原始描述

Use when reviewing client-side JavaScript, HTML source, or git history for exposed credentials, API keys, or tokens.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2917
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能