AI rất giỏi làm đúng thứ bạn yêu cầu.

Vấn đề là bạn thường không yêu cầu security.

Bạn nói: “làm login”. Agent làm login.

Bạn nói: “làm upload file”. Agent làm upload file.

Bạn nói: “làm admin dashboard”. Agent làm admin dashboard.

Nếu prompt không nhắc threat model, permission, validation, logging, rate limit, secret handling, và test security, agent có thể coi đó là việc review sau.

Security bị đẩy sang reactive mode

Một paper 2026 về AI coding assistants và security awareness mô tả shift quan trọng: AI không xóa security thinking, nhưng đẩy nó từ lúc viết code sang lúc review code. Trong coding sessions của nghiên cứu, participants không đưa security requirements vào prompt ban đầu, kể cả khi họ có kiến thức liên quan.

Đây là lỗi workflow, không chỉ lỗi model.

Khi agent đã tạo xong diff, bạn đang review một quyết định đã được encode vào code. Review lúc đó vẫn cần, nhưng đã muộn hơn thiết kế.

Non-tech càng dễ rơi vào bẫy này

Người non-tech thường prompt theo màn hình:

  • “Cho user đăng nhập bằng email.”
  • “Cho admin export CSV.”
  • “Cho khách upload ảnh.”
  • “Cho staff sửa booking.”

Nhưng security cần prompt theo boundary:

  • Ai được làm gì?
  • Dữ liệu nào không bao giờ được lộ?
  • Input nào là untrusted?
  • Request nào cần rate limit?
  • Action nào cần audit log?
  • Token nào chỉ đọc, token nào được ghi?
  • Môi trường nào là production?

Nếu boundary không có trong prompt, agent sẽ tự đoán. Tự đoán security là cách nhanh để tạo lỗ hổng lịch sự.

Prompt security trước khi code

Trước khi cho agent build feature, dùng block này:

Before writing code, produce a security brief.
Identify assets, actors, permissions, untrusted inputs, abuse cases, and data that must not leak.
List the minimum controls required for this feature.
Only after I approve the brief, implement the feature with tests for those controls.

Sau khi agent code xong:

Review this diff against the approved security brief.
Point to exact files and lines where each control is implemented.
List missing controls separately.
Do not mark the task complete if any control is unimplemented.

Chốt lại

Security không thể là đoạn cuối trong prompt kiểu “nhớ làm secure nhé”.

Vibe coding có kiểm soát phải kéo security lên trước khi code được sinh ra. Nếu không, bạn đang biến security thành hoạt động dọn dẹp sau khi agent đã chọn architecture, database shape và permission model.

Rule thực dụng: feature nào chạm auth, data, payment, admin, file upload, email, webhook hoặc production thì phải có security brief trước code.

Tham khảo