Chuyển đến nội dung
Skillpedia
Bảo mật75k · #2917

leaked-secrets

Skill này làm gì

Skill này kiểm tra mã phía máy khách, mã nguồn trang và lịch sử dự án để tìm thông tin xác thực mà bất kỳ ai cũng có thể đọc. Skill dành cho lập trình viên muốn giữ khóa của mình kín.

Khi nào nên dùng

  • ✓Khi một khóa API xuất hiện trong tệp JavaScript mà khách truy cập có thể tải về.
  • ✓Khi một tệp .env có thể đã được commit vào repository.
  • ✓Khi bạn thêm dịch vụ mới và muốn chắc các bí mật của nó vẫn riêng tư.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/leaked-secrets/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể kiểm tra mã front-end của tôi xem có khóa API hoặc mật khẩu không nên công khai không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent quét mã nguồn trang và JavaScript để tìm mẫu giống bí mật, rồi tìm trong lịch sử dự án các lần lộ trước đó. Agent gợi ý chuyển bí mật lên máy chủ, thay khóa đã lộ và thêm công cụ quét bí mật.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

Vì sao khóa trong mã front-end lại rủi ro?

Skill nói bất kỳ ai có công cụ phát triển của trình duyệt đều có thể đọc nó và dùng dịch vụ liên quan.

Còn biến công khai của Next.js thì sao?

Skill nói chỉ những biến có tiền tố NEXT_PUBLIC mới đến được trình duyệt, nên bí mật tuyệt đối không được dùng tiền tố này.

Cần làm gì sau khi bị lộ?

Skill nói phải thay thông tin xác thực bị lộ ngay lập tức và coi nó đã bị xâm phạm.

Chi tiết

Mô tả gốc của tác giả

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

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2917
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự