Logo Laravel Owasp Security

Laravel Owasp Security

Cộng đồng
AsyrafHussin
laravel-owasp-security

Hướng dẫn kiểm tra bảo mật OWASP Top 10 và lập trình an toàn cho ứng dụng Laravel + React/Inertia.js. Dùng khi kiểm tra lỗ hổng ("run OWASP audit", "security review", "check my app security") hoặc viết mã Laravel an toàn liên quan đến xác thực, thanh toán, tải tệp lên hoặc thiết kế API. Kích hoạt với các tác vụ liên quan đến bảo mật, xử lý thanh toán, xác thực hoặc mọi yêu cầu kiểm tra mã nguồn Laravel.

Add to TypingMind

Tổng quan

Nhà phát hànhAsyrafHussin
Kho mãagent-skills
Tên kỹ nănglaravel-owasp-security
Sao
78
Bản fork
10
Tệp đi kèm
12
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ộ.

  • 12 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 AsyrafHussin 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 Laravel Owasp Security 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/AsyrafHussin/agent-skills/tree/main/skills/laravel-owasp-security
  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/AsyrafHussin/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/laravel-owasp-security .claude/skills/laravel-owasp-security
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 Laravel Owasp Security 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 Laravel Owasp Security 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 Laravel Owasp Security 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.

Laravel OWASP Security

Dual-purpose security skill for Laravel 13 + React/Inertia.js applications. Run a full OWASP Top 10 audit against a codebase, or use as a secure coding reference when building features.

How to Audit

Step 1: Detect Stack

Check if the project uses React + Inertia.js by looking for:

  • app/Http/Middleware/HandleInertiaRequests.php exists
  • resources/js/ contains .tsx or .jsx files
  • inertiajs/inertia-laravel in composer.json
  • @inertiajs/react in package.json

If detected, state at the top of the report:

"React + Inertia.js detected — Laravel OWASP checklist AND React/Inertia security checks will both be applied."

If not detected, state:

"No React/Inertia.js detected — applying Laravel OWASP checklist only."

Step 2: Determine Scope

  • If arguments provided ($ARGUMENTS): review only those files or features
  • If no arguments: review the entire codebase

Step 3: Run Checklist

Work through every item below. For each, output:

  • PASS — brief confirmation of what was verified
  • FAIL — exact file:line, a description of the vulnerability (do NOT reproduce any code, values, API keys, tokens, or .env contents from the file), and a fix recommendation
  • N/A — if the check does not apply to this project

OWASP Top 10 Checklist

1. Broken Access Control (A01:2021)

  • Middleware protects all route groups by role (auth, role:admin, etc.)
  • Resource queries scoped to authenticated user — ->where('user_id', auth()->id())
  • No direct object reference without ownership check
  • Gates and Policies used to authorize resource access
  • Frontend role checks are mirrored server-side — never rely on React UI checks alone

2. Cryptographic Failures (A02:2021)

  • Passwords hashed with Hash::make() or 'hashed' Eloquent cast — never stored as plaintext
  • No MD5 or SHA1 used for password hashing
  • Sensitive fields (API keys, secrets) encrypted with Crypt::encryptString() or 'encrypted' Eloquent cast
  • APP_KEY is long, random, and unique per environment
  • Signed URLs (URL::signedRoute()) used for sensitive one-time actions (password reset, email verify)

3. Injection (A03:2021)

SQL & Mass Assignment:

  • No string concatenation in whereRaw(), selectRaw(), orderByRaw() — use ? bindings
  • Column names never derived from user input without a whitelist
  • No $request->all() passed directly to create(), fill(), or update()
  • No forceFill() or forceCreate() with unvalidated user input
  • Models define $fillable explicitly — not $guarded = []
  • Controllers use $request->validated() for mass operations

XSS — Blade & React:

  • No {!! $userInput !!} in Blade templates with untrusted data
  • {{ }} used for all user-supplied Blade output
  • No dangerouslySetInnerHTML in React without DOMPurify.sanitize() first
  • href and src attributes not set from unvalidated user input
  • No eval(), new Function(), or setTimeout(string) with user-controlled strings
  • External CDN scripts use Subresource Integrity (integrity="sha384-...")

4. Insecure Design (A04:2021)

  • Business logic enforced server-side — prices, totals, and discounts never trusted from client input
  • Sensitive operations require secondary confirmation (e.g. password re-entry for account deletion)
  • No mass action endpoints without per-item authorization check
  • Admin-only features isolated behind separate middleware — not just hidden in the UI
  • Payment amounts and enrollment states calculated server-side, not passed as form inputs

5. Security Misconfiguration (A05:2021)

  • APP_DEBUG=false in production
  • .env is in .gitignore and never committed
  • Database uses a restricted user — not root/admin — in production
  • storage/ and bootstrap/cache/ have correct permissions (not world-writable)
  • APP_KEY is set and unique per environment
  • CORS allowed_origins is not ['*'] for authenticated API routes

6. Vulnerable & Outdated Components (A06:2021)

  • composer audit passes with no known CVEs
  • npm audit passes with no known CVEs
  • Laravel framework is on a supported version

7. Identification & Authentication Failures (A07:2021)

Auth:

  • Using Laravel Breeze, Fortify, or Jetstream — not custom-rolled auth
  • Passwords hashed with bcrypt or argon2 (Laravel default)
  • Login route rate limited — throttle middleware or RateLimiter in LoginRequest
  • Password reset and email verification routes rate limited
  • Payment and sensitive action routes have appropriate rate limits
  • session()->regenerate() called after successful login

Cookie & Session:

  • http_only = true in config/session.php
  • same_site = lax or strict in config/session.php
  • secure = true or null (auto for HTTPS) in config/session.php
  • lifetime is a reasonable value (15–30 min recommended for most apps)
  • domain = null unless subdomains are needed
  • EncryptCookies middleware is in the web group

8. Software & Data Integrity Failures (A08:2021)

CSRF:

  • VerifyCsrfToken middleware active in the web group
  • Only stateless routes (webhooks, external callbacks) are excluded from CSRF
  • @csrf directive used in all non-Inertia POST forms
  • Excluded routes in validateCsrfTokens(except: [...]) are justified

Deserialization:

  • No unserialize($request->input(...))
  • No eval($request->input(...))
  • No extract($request->all())

9. Security Logging & Monitoring Failures (A09:2021)

  • Failed login attempts logged with IP and identifier
  • Payment failures and exceptions logged
  • Log entries do not contain raw passwords or secrets
  • Monitoring in place (Laravel Telescope, Sentry, or similar)

10. Server-Side Request Forgery — SSRF (A10:2021)

  • No Http::get($request->input('url')) with unvalidated URLs
  • User-supplied URLs validated against an allowlist or scheme check
  • Internal network addresses blocked from user-supplied URLs

Additional Checks

Not part of the OWASP Top 10 but critical for Laravel applications.

Command Injection & Dangerous Functions

  • No exec(), shell_exec(), system(), passthru() with user input
  • No open redirects — no redirect($request->input('url')) with unvalidated URLs
  • File uploads validate mimes:, max: — filenames never derived from raw user input

Security Headers

  • Content-Security-Policy set — with nonces (Vite::useCspNonce()) if possible
  • X-Frame-Options set
  • X-Content-Type-Options set
  • Strict-Transport-Security set for HTTPS
  • Referrer-Policy set
  • Permissions-Policy set

React + Inertia.js Checks

Only run if React + Inertia.js detected in Step 1.

R1. XSS in React Components

  • No dangerouslySetInnerHTML={{ __html: userInput }} without DOMPurify.sanitize() first
  • href and src attributes not set from unvalidated user input — javascript: URLs execute scripts
  • No eval(), new Function(), or setTimeout(string) with user-controlled strings
  • Links from user input validate scheme (https:// or http:// only)

R2. Inertia.js Data Exposure (Critical)

  • HandleInertiaRequests::share() does NOT expose passwords, tokens, or internal-only flags
  • Controllers use ->only([...]) or API Resources — not raw model toArray()
  • All Inertia props are treated as public — visible in data-page HTML attribute on initial load
  • Payment secret keys and admin-only credentials are never passed as Inertia props
  • Inertia v2 History Encryption enabled for pages with sensitive data

R3. CSRF in Inertia.js

  • Inertia X-XSRF-TOKEN header not disabled
  • Custom fetch or axios calls include CSRF token manually if bypassing Inertia's router
  • Webhook/callback routes are the ONLY CSRF-excluded routes

R4. Authentication State in React

  • auth.user Inertia prop excludes password hash, remember tokens, and 2FA secrets
  • Role/permission checks enforced server-side — React checks are UI-only
  • auth.user contains only fields the UI actually needs

R5. Sensitive Data in Browser

  • No API keys or secrets hardcoded in React components or TypeScript files
  • No sensitive data in localStorage or sessionStorage — use HttpOnly cookies
  • VITE_* env vars contain no secrets — they are public by design

R6. Dependency Security

  • npm audit passes with no high/critical CVEs in React or Inertia packages
  • React is on a supported version
  • Third-party component libraries reviewed for known CVEs

Output Format

Structure the audit report as:

## Laravel OWASP Security Audit Report

> React + Inertia.js detected — Laravel OWASP checklist AND React/Inertia security checks will both be applied.

### 1. Broken Access Control (A01:2021)
- **PASS** `app/Http/Middleware/RoleMiddleware.php` — role middleware applied to all route groups
- **FAIL** `app/Http/Controllers/PaymentController.php:42` — Payment model fetched without ownership check (direct object reference exposure). Fix: scope the query to the authenticated user.

[Continue for all 10 OWASP checks + Additional Checks + R1–R6 React/Inertia checks]

---

## Summary

### Critical Issues (fix immediately)
1. ...

### Warnings (fix soon)
1. ...

### Passed
X checks passed.

### Recommended Commands
composer audit
npm audit

When to Apply for Guidance

Reference the rule files when:

  • Implementing authentication or password handling
  • Building payment or webhook integrations
  • Writing file upload or download logic
  • Designing admin or role-based access control
  • Building API endpoints with user-supplied input
  • Using dangerouslySetInnerHTML in React components
  • Passing data from Laravel controllers to Inertia props

Rule Categories by Priority

PriorityCategoryImpactRule File
1Broken Access ControlCRITICALsec-broken-access-control
2Cryptographic FailuresCRITICALsec-cryptographic-failures
3Injection PreventionCRITICALsec-injection-prevention
4XSS & React/InertiaHIGHsec-xss-react-inertia
5CSRF ProtectionHIGHsec-csrf-protection
6Security MisconfigurationHIGHsec-security-misconfiguration
7Authentication & Rate LimitingHIGHsec-authentication-rate-limiting
8Inertia Data ExposureHIGHsec-inertia-data-exposure

Quick Reference

1. Broken Access Control (CRITICAL)

  • sec-broken-access-control — Middleware, ownership checks, policies, scoped queries

2. Cryptographic Failures (CRITICAL)

  • sec-cryptographic-failures — Password hashing, encrypted casts, signed URLs

3. Injection Prevention (CRITICAL)

  • sec-injection-prevention — SQL injection, mass assignment, raw query bindings

4. XSS & React/Inertia (HIGH)

  • sec-xss-react-inertia — dangerouslySetInnerHTML, DOMPurify, href/src validation

5. CSRF Protection (HIGH)

  • sec-csrf-protection — VerifyCsrfToken, webhook exclusions, Inertia CSRF

6. Security Misconfiguration (HIGH)

  • sec-security-misconfiguration — APP_DEBUG, APP_KEY, security headers, CORS

7. Authentication & Rate Limiting (HIGH)

  • sec-authentication-rate-limiting — Throttle, session regeneration, brute force prevention

8. Inertia Data Exposure (HIGH)

  • sec-inertia-data-exposure — data-page attribute exposure, secret props, API Resources

How to Use

Read individual rule files for detailed explanations and code examples:

rules/sec-broken-access-control.md
rules/sec-cryptographic-failures.md
rules/sec-injection-prevention.md
rules/sec-xss-react-inertia.md
rules/sec-csrf-protection.md
rules/sec-security-misconfiguration.md
rules/sec-authentication-rate-limiting.md
rules/sec-inertia-data-exposure.md

Each rule file contains:

  • YAML frontmatter with metadata (title, impact, tags)
  • Why it matters in Laravel/React context
  • Incorrect code example with explanation
  • Correct code example with fix
  • Laravel 13 and PHP 8.3+ specific context

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

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 Laravel Owasp Security làm được gì?

Hướng dẫn kiểm tra bảo mật OWASP Top 10 và lập trình an toàn cho ứng dụng Laravel + React/Inertia.js. Dùng khi kiểm tra lỗ hổng ("run OWASP audit", "security review", "check my app security") hoặc viết mã Laravel an toàn liên quan đến xác thực, thanh toán, tải tệp lên hoặc thiết kế API. Kích hoạt với các tác vụ liên quan đến bảo mật, xử lý thanh toán, xác thực hoặc mọi yêu cầu kiểm tra mã nguồn Laravel.

Vì sao nên dùng Laravel Owasp Security 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. Laravel Owasp Security 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 Laravel Owasp Security trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/AsyrafHussin/agent-skills/tree/main/skills/laravel-owasp-security. 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 Laravel Owasp Security?

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 Laravel Owasp Security 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 Laravel Owasp Security 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 Laravel Owasp Security có miễn phí không?

Có. Kỹ năng này được AsyrafHussin 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 👇