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

cross-origin-security

Skill này làm gì

Skill này kiểm tra cách website xử lý yêu cầu và tin nhắn vượt qua ranh giới origin. Skill dành cho lập trình viên muốn ngăn kẻ tấn công đọc dữ liệu hoặc hành động thay người dùng.

Khi nào nên dùng

  • ✓Khi website lắng nghe tin nhắn từ cửa sổ hoặc iframe khác.
  • ✓Khi cài đặt CORS cho phép mọi origin trên các route đã đăng nhập.
  • ✓Khi tham số chuyển hướng có thể đưa người dùng tới bất kỳ địa chỉ bên ngoài nào.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/cross-origin-security/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/cross-origin-security/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

“Hãy kiểm tra các trình lắng nghe tin nhắn và cài đặt CORS của website tôi xem có gì cho phép site khác đọc dữ liệu người dùng không.”

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

Cách hoạt động

Agent kiểm tra xem trình lắng nghe tin nhắn có xác minh nguồn gốc của mỗi tin nhắn không, CORS có bị giới hạn trên các route đã xác thực không, và chuyển hướng chỉ đi tới các đích đã được duyệ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.

Handle cross-origin requests securely

The Same-Origin Policy is the browser's primary defense against malicious sites stealing data or performing actions on behalf of your users. Misconfiguring CORS or failing to validate postMessage origins can allow attackers to bypass this protection — reading private data, submitting forms as users, or injecting content into your pages.

Quick Reference

  • Always verify event.origin before processing postMessage data
  • Never set Access-Control-Allow-Origin: * for authenticated endpoints
  • Validate and sanitize all data received from cross-origin messages
  • Use SameSite cookies to prevent CSRF from cross-origin requests
  • Reject unvalidated redirect targets such as next, redirect, or callbackUrl

Check

Check this code for insecure cross-origin patterns: missing origin validation in postMessage listeners, overly permissive CORS settings, and missing CSRF protections. Flag redirect parameters that accept arbitrary external URLs.

Fix

Add origin validation to postMessage listeners and review CORS configuration to ensure it's not overly permissive for authenticated routes. Reject or allow-list untrusted redirect destinations before navigating.

Explain

Explain the Same-Origin Policy, how CORS works, and how to securely use postMessage for cross-origin communication.

Code Review

Review scripts, client components, and browser execution paths related to Handle cross-origin requests securely. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser. Check login, logout, SSO, and return-to flows for open redirects.


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

Rule page: https://frontendchecklist.io/rules/javascript/cross-origin-security

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

Same-Origin Policy là gì?

Skill mô tả đó là lớp phòng thủ chính của trình duyệt chống lại các site độc hại đọc hoặc hành động trên dữ liệu người dùng.

Agent kiểm tra gì trong tin nhắn?

Nguồn gốc của tin nhắn được xác minh trước khi dùng bất kỳ dữ liệu nào.

Vì sao tham số chuyển hướng lại rủi ro?

Skill nói chúng có thể đưa người dùng tới bất kỳ site bên ngoài nào nếu không được kiểm tra hoặc duyệt trước.

Chi tiết

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

Use when reviewing scripts, client components, bundles, or runtime behavior related to Handle cross-origin requests securely. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2793
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ự