Logo Secure Coding

Secure Coding

Cộng đồng
MartinOlivero
secure-coding

Dùng kỹ năng này KHI VIẾT bất kỳ mã backend, API, xác thực hoặc xử lý dữ liệu nào cho ứng dụng web hay SaaS — nhằm ngăn lỗ hổng bảo mật trước khi phát hành, thay vì đợi đến lúc kiểm tra mới phát hiện. Các cụm từ kích hoạt gồm: "add an endpoint", "handle user input", "store user data", "is this secure", "build the API", "save to the database", "handle the form", "user uploads", "process payment", "handle secrets", "set up CORS", "rate limit". Kỹ năng này áp dụng các biện pháp phòng ngừa theo OWASP Top 10, xác thực dữ liệu đầu vào, thực hành an toàn với thông tin bí mật và các nguyên tắc cơ bản của GDPR trong quá trình xây dựng.

Add to TypingMind

Tổng quan

Nhà phát hànhMartinOlivero
Kho mãsaas-builder
Tên kỹ năngsecure-coding
Sao
4
Bản fork
2
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được MartinOlivero công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Secure Coding trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/MartinOlivero/saas-builder/tree/main/skills/secure-coding
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MartinOlivero/saas-builder.git /tmp/saas-builder
mkdir -p .claude/skills
cp -r /tmp/saas-builder/skills/secure-coding .claude/skills/secure-coding
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Secure Coding trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Secure Coding ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Secure Coding với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Secure Coding

This skill keeps you from introducing vulnerabilities while you build. It is prevention, not audit — it runs at the moment you write an endpoint, a form handler, or a database write, and bakes in the safe default before the bug exists.

Analogy: it is the seatbelt you put on before driving, not the crash investigator who shows up afterward. Audit tools (Trail of Bits, Semgrep, CodeQL) inspect the wreck. This skill stops the crash.

Scope

This skill is for the solo dev or small team who has no security tooling installed and just wants to ship without leaving holes. If a dedicated audit plugin is present, this skill still runs first — preventing a vuln is always cheaper than finding it later.

Trigger

Activate whenever code touches: a request handler/endpoint, user input, a database write, authentication, file uploads, secrets/env vars, CORS, or any third-party webhook. Default-deny mindset: code with no explicit security decision is the bug.

Discovery (max 3 questions, only if unknown)

  1. Is this endpoint/data public, authenticated, or admin-only?
  2. Does it touch personal data (email, name, payment, location, anything identifying a person)?
  3. What is the backend — serverless functions (Vercel), a Node server, or a BaaS (Supabase/InsForge)?

The OWASP Top 10, as prevention rules

Apply the matching rule the instant you write the code. Each maps an OWASP 2021 category to a concrete default.

RiskPrevent it by
A01 Broken Access ControlCheck authorization on the server, on every endpoint. Verify the resource belongs to req.user (stop IDOR). Default-deny: no explicit check = bug. Never trust client-sent role/price/owner fields.
A02 Cryptographic FailuresHTTPS everywhere (free on Vercel). Hash passwords with bcrypt or argon2, never plaintext/reversible. Encrypt PII at rest. Never roll your own crypto.
A03 InjectionNever string-concat SQL. Parameterized queries / ORM only (pg params, Drizzle, Prisma, Kysely). Validate every input at the boundary with zod before it reaches logic or the DB.
A04 Insecure DesignThreat-model the feature first: who can call this, what is the worst input. Enforce limits by design — quotas, server-side amount/price checks.
A05 Security MisconfigurationAdd Helmet for secure headers. CORS = explicit origin allowlist (never * with credentials: true). Disable verbose error stacks in prod.
A06 Vulnerable ComponentsPin deps, run npm audit + Dependabot, remove unused packages, update before shipping.
A07 Auth FailuresUse a vetted auth provider (see the auth skill). Rate-limit login routes harder. httpOnly + Secure + SameSite cookies for sessions. MFA where possible.
A08 Data IntegrityVerify webhook signatures (e.g. Stripe signing secret). Don't deserialize untrusted data. Commit the lockfile.
A09 Logging FailuresLog auth + authz denials — but never log PII, tokens, passwords, or full request bodies. Redact first.
A10 SSRFDon't fetch user-supplied URLs server-side without an allowlist; block internal/metadata IP ranges.

API security defaults

  • Validate at the boundary with zod, and use .strict() schemas that whitelist exactly the allowed fields. This kills mass assignment — never spread req.body into a DB write; explicitly drop role, isAdmin, id, ownerId.
  • Rate-limit every public and auth endpoint (express-rate-limit, or the platform's edge limiter). Auth routes get a stricter limit.
  • CORS: allowlist origins explicitly. With credentials, * is forbidden by spec and a real hole.
  • Return correct status codes — 401 vs 403, 422 on validation, 429 + Retry-After on limit.

User data & GDPR basics (for developers)

  • Collect the minimum PII. Drop optional fields. Less data = less liability (GDPR Art. 5 minimization).
  • Encrypt in transit (TLS) and at rest. GDPR Art. 32 cites encryption as the recommended safeguard.
  • Set retention + deletion. Provide a way to delete a user's data on request.
  • Never log PII. Redact emails, tokens, bodies before they hit logs or Sentry.

Secrets hygiene

  • .gitignore .env, .env*.local, *.pem, *.key. Commit a .env.example with names only.
  • Secrets live in the platform's encrypted store (Vercel env vars marked Sensitive), never in the repo.
  • On Vite, only VITE_-prefixed vars reach the browser — a secret behind that prefix is a public leak.
  • Rotate by add-new → redeploy → revoke-old. Optionally run gitleaks as a pre-commit net.

Server decides, client asks

The rule behind most real holes: anything the client sends is a request, not a fact.

  • Prices, totals, roles, owners, statuses — computed or checked on the server.
  • File uploads — the server builds the path (scoped to the user), chooses the bucket, restricts the type, caps the size.
  • Identity — from a token the server validates, never from a cookie or field the browser can edit.
  • Never switch to the admin/service client to make a permission error go away. That removes the permission. Find out why the user's own credentials were refused.

Public endpoints (no login)

A form or endpoint anyone can call needs, at minimum: a captcha or equivalent, a honeypot field (named so autofill won't fill it), a rate cap that does not depend on the caller's IP, and sanitizing of every value that ends up in a message sent to someone else.

Field notes

references/field-notes.md holds the security failures behind these rules — plus a working Content-Security-Policy recipe (per-request nonce, strict-dynamic, Report-Only rollout) and where secrets actually leak from. The three that cost the most:

  1. A storage path taken from the form, uploaded with the admin client.
  2. An order line saved at a client-chosen price.
  3. An API key published inside a Markdown notes file by git add -A.

For database permissions on a BaaS, run rls-audit. For third-party webhooks, see integrations. For LLM calls, see ai-features.

Output

For each piece of code, deliver: the secure implementation, a one-line note on which risk it defends against, and any validation schema (zod) inline. When you spot a violation in existing code the user shows you, flag it with the fix — but the job is to write it safe the first time.

Reference

OWASP Cheat Sheet Series (~29k⭐), OWASP Top 10:2021, GDPR.eu / gdpr-info Art. 32. Tools: zod, helmet, express-rate-limit, bcrypt/argon2, gitleaks.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

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

Kỹ năng AI Secure Coding làm được gì?

Dùng kỹ năng này KHI VIẾT bất kỳ mã backend, API, xác thực hoặc xử lý dữ liệu nào cho ứng dụng web hay SaaS — nhằm ngăn lỗ hổng bảo mật trước khi phát hành, thay vì đợi đến lúc kiểm tra mới phát hiện. Các cụm từ kích hoạt gồm: "add an endpoint", "handle user input", "store user data", "is this secure", "build the API", "save to the database", "handle the form", "user uploads", "process payment", "handle secrets", "set up CORS", "rate limit". Kỹ năng này áp dụng các biện pháp phòng ngừa theo OWASP Top 10, xác thực dữ liệu đầu vào, thực hành an toàn với thông tin bí mật và các nguyên tắc cơ b...

Vì sao nên dùng Secure Coding trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Secure Coding là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Secure Coding trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/MartinOlivero/saas-builder/tree/main/skills/secure-coding. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Secure Coding?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Secure Coding với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Secure Coding với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Secure Coding có miễn phí không?

Có. Kỹ năng này được MartinOlivero phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇