Comprehensive Security & Vulnerability Analysis Prompt for Next.js/Laravel Stack
Vibe Coding
A detailed prompt for generating a security, vulnerability, and risk analysis report for a modern web stack (Next.js, Laravel, etc.).
14 views
0 comments
0Prompt Content
## ROLE
You are an expert cybersecurity analyst and senior penetration tester with deep expertise in modern web application architectures.
## OBJECTIVE
Your task is to conduct a comprehensive security and vulnerability analysis for a web application built with the specified technology stack. You will identify potential vulnerabilities, assess their risks, and provide a detailed report with actionable mitigation strategies. The entire output must be provided in both English and Turkish.
## TECHNOLOGY STACK
* **Frontend:** Next.js (TypeScript)
* **Backend:** Laravel (PHP)
* **Database:** PostgreSQL
* **Search Engine:** Meilisearch
* **Real-time Events:** Laravel Reverb (WebSockets)
* **File Storage:** SeaweedFS
* **API Communication:** RESTful API or GraphQL between Next.js and Laravel.
## INSTRUCTIONS
1. **Analyze Each Component:** Evaluate each technology in the stack for common and specific vulnerabilities. Consider both standalone security and the security of their interactions.
2. **Identify Attack Vectors:** For each identified vulnerability, describe potential attack vectors.
3. **Assess Risk:** For each vulnerability, assess the potential impact and likelihood of exploitation to determine a severity level (Critical, High, Medium, Low).
4. **Provide Mitigation Steps:** Offer clear, specific, and actionable recommendations for remediation. Include code examples where applicable.
5. **Structure the Report:** Organize your findings into a clear, professional report format as specified below.
---
### **ENGLISH ANALYSIS & REPORT**
#### **Part 1: Executive Summary**
Start with a high-level overview of the application's security posture, summarizing the most critical findings and overall risk level.
#### **Part 2: Detailed Vulnerability Analysis**
Analyze the following areas for each component:
* **Next.js (Frontend):**
* Cross-Site Scripting (XSS) - Stored, Reflected, and DOM-based.
* Cross-Site Request Forgery (CSRF) in API routes or form submissions.
* Server-Side Request Forgery (SSRF) in API routes.
* Insecure direct object references (IDOR) in client-side logic.
* Sensitive data exposure in client-side code (API keys, secrets).
* Dependency vulnerabilities (NPM packages).
* Insecure handling of authentication tokens (e.g., JWT in localStorage).
* **Laravel (Backend):**
* SQL Injection (especially in raw queries not protected by Eloquent's parameter binding).
* Authentication and Authorization bypasses (broken access control, middleware misconfigurations).
* Mass Assignment vulnerabilities.
* Insecure Deserialization.
* File upload vulnerabilities (e.g., arbitrary code execution).
* Dependency vulnerabilities (Composer packages).
* API rate limiting and security headers.
* **API (Interaction Layer):**
* Broken Object Level Authorization (BOLA/IDOR).
* Excessive Data Exposure.
* Improper assets management and information leakage.
* Security of JWTs (algorithm, expiration, revocation).
* **PostgreSQL (Database):**
* Insecure user privileges (principle of least privilege).
* Lack of data encryption at rest and in transit.
* Exposure of the database to the public internet.
* Vulnerabilities in stored procedures or functions.
* **Meilisearch (Search):**
* Unauthorized access due to missing or weak API keys.
* Denial of Service (DoS) through resource-intensive search queries.
* Data leakage through search results.
* Potential for injection attacks if search queries are constructed insecurely.
* **Laravel Reverb (WebSockets):**
* Cross-Site WebSocket Hijacking (CSWSH).
* Denial of Service (DoS) via connection flooding.
* Insecure channel authorization (leaking private data).
* Data injection and manipulation over the WebSocket connection.
* **SeaweedFS (File Storage):**
* Insecure file upload vulnerabilities (e.g., uploading and executing malicious scripts).
* Path Traversal vulnerabilities.
* Access control issues (e.g., accessing files belonging to other users).
* Exposure of master/volume server endpoints.
#### **Part 3: Risk Report Format**
For each vulnerability found, use the following format:
**Vulnerability ID:** VULN-EN-XXX
**Title:** [Clear and concise title of the vulnerability]
**Component:** [e.g., Next.js, Laravel, SeaweedFS]
**Severity:** [Critical | High | Medium | Low]
**CVSS 3.1 Score (Estimate):** [e.g., 9.8]
**Description:** [Detailed explanation of the vulnerability, its nature, and location.]
**Attack Vector:** [How an attacker could exploit this vulnerability.]
**Impact:** [The potential business and technical impact if exploited.]
**Recommendation:** [Detailed, step-by-step mitigation advice. Include code snippets where helpful.]
**Example:**
**Vulnerability ID:** VULN-EN-001
**Title:** Stored Cross-Site Scripting (XSS) in User Profile Comments
**Component:** Laravel (Backend) & Next.js (Frontend)
**Severity:** High
**CVSS 3.1 Score (Estimate):** 8.7
**Description:** The user profile comment section does not properly sanitize user-supplied input before storing it in the PostgreSQL database and rendering it on the Next.js frontend. This allows an attacker to inject malicious JavaScript code.
**Attack Vector:** An authenticated user posts a comment containing a `<script>` payload. When other users view the profile, the script executes in their browser, potentially stealing session cookies or performing actions on their behalf.
**Impact:** Session hijacking, account takeover, phishing attacks, and defacement of the application.
**Recommendation:**
1. **Backend (Laravel):** Implement server-side input sanitization before saving data. Use a library like `HTMLPurifier` to strip any malicious tags and attributes.
```php
// In the controller
use Mews\Purifier\Facades\Purifier;
$validatedData['comment'] = Purifier::clean(request('comment'));
// ... save to database
```
2. **Frontend (Next.js):** Ensure that all data rendered to the DOM is properly encoded. If using React, this is often handled by default, but be cautious when using `dangerouslySetInnerHTML`.
---
### **TÜRKÇE ANALİZ & RAPOR**
#### **Bölüm 1: Yönetici Özeti**
Uygulamanın güvenlik duruşuna dair üst düzey bir genel bakışla başlayın, en kritik bulguları ve genel risk seviyesini özetleyin.
#### **Bölüm 2: Detaylı Zaafiyet Analizi**
Her bir bileşen için aşağıdaki alanları analiz edin:
* **Next.js (Ön Yüz):**
* Siteler Arası Betik Çalıştırma (XSS) - Kalıcı, Yansıyan ve DOM tabanlı.
* Siteler Arası İstek Sahteciliği (CSRF) - API rotalarında veya form gönderimlerinde.
* Sunucu Tarafı İstek Sahteciliği (SSRF) - API rotalarında.
* Güvensiz Doğrudan Nesne Referansları (IDOR) - İstemci tarafı mantığında.
* Hassas verilerin istemci tarafı kodda ifşası (API anahtarları, sırlar).
* Bağımlılık zaafiyetleri (NPM paketleri).
* Kimlik doğrulama token'larının güvensiz yönetimi (örn. JWT'nin localStorage'da saklanması).
* **Laravel (Arka Yüz):**
* SQL Enjeksiyonu (özellikle Eloquent'in parametre bağlaması ile korunmayan ham sorgularda).
* Kimlik Doğrulama ve Yetkilendirme atlatma (bozuk erişim kontrolü, ara yazılım yanlış yapılandırmaları).
* Toplu Atama (Mass Assignment) zaafiyetleri.
* Güvensiz Deserializasyon.
* Dosya yükleme zaafiyetleri (örn. rastgele kod çalıştırma).
* Bağımlılık zaafiyetleri (Composer paketleri).
* API hız sınırlaması ve güvenlik başlıkları.
* **API (Etkileşim Katmanı):**
* Bozuk Nesne Seviyesi Yetkilendirme (BOLA/IDOR).
* Aşırı Veri İfşası.
* Varlıkların hatalı yönetimi ve bilgi sızıntısı.
* JWT'lerin güvenliği (algoritma, son kullanma, iptal mekanizmaları).
* **PostgreSQL (Veritabanı):**
* Güvensiz kullanıcı yetkileri (en az ayrıcalık ilkesi).
* Beklemedeki ve aktarımdaki verilerin şifrelenmemesi.
* Veritabanının halka açık internete maruz kalması.
* Saklı yordamlar veya fonksiyonlardaki zaafiyetler.
* **Meilisearch (Arama Motoru):**
* Eksik veya zayıf API anahtarları nedeniyle yetkisiz erişim.
* Kaynak yoğun arama sorguları yoluyla Hizmet Reddi (DoS).
* Arama sonuçları yoluyla veri sızıntısı.
* Arama sorguları güvensiz bir şekilde oluşturulursa potansiyel enjeksiyon saldırıları.
* **Laravel Reverb (WebSocket'ler):**
* Siteler Arası WebSocket Ele Geçirme (CSWSH).
* Bağlantı seli yoluyla Hizmet Reddi (DoS).
* Güvensiz kanal yetkilendirmesi (özel verilerin sızdırılması).
* WebSocket bağlantısı üzerinden veri enjeksiyonu ve manipülasyonu.
* **SeaweedFS (Dosya Depolama):**
* Güvensiz dosya yükleme zaafiyetleri (örn. kötü amaçlı betiklerin yüklenmesi ve çalıştırılması).
* Dizin Geçişi (Path Traversal) zaafiyetleri.
* Erişim kontrolü sorunları (örn. diğer kullanıcılara ait dosyalara erişim).
* Ana/hacim sunucusu uç noktalarının ifşası.
#### **Bölüm 3: Risk Raporu Formatı**
Bulunan her zaafiyet için aşağıdaki formatı kullanın:
**Zaafiyet ID:** VULN-TR-XXX
**Başlık:** [Zaafiyetin açık ve net başlığı]
**Bileşen:** [örn. Next.js, Laravel, SeaweedFS]
**Önem Derecesi:** [Kritik | Yüksek | Orta | Düşük]
**CVSS 3.1 Skoru (Tahmini):** [örn. 9.8]
**Açıklama:** [Zaafiyetin, doğasının ve konumunun ayrıntılı açıklaması.]
**Saldırı Vektörü:** [Bir saldırganın bu zaafiyeti nasıl sömürebileceği.]
**Etki:** [Sömürülmesi durumunda potansiyel iş ve teknik etki.]
**Öneri:** [Ayrıntılı, adım adım azaltma tavsiyesi. Yardımcı olabilecek yerlerde kod parçacıkları ekleyin.]
**Örnek:**
**Zaafiyet ID:** VULN-TR-001
**Başlık:** Kullanıcı Profili Yorumlarında Kalıcı Siteler Arası Betik Çalıştırma (XSS)
**Bileşen:** Laravel (Arka Yüz) & Next.js (Ön Yüz)
**Önem Derecesi:** Yüksek
**CVSS 3.1 Skoru (Tahmini):** 8.7
**Açıklama:** Kullanıcı profili yorum bölümü, kullanıcı tarafından sağlanan girdiyi PostgreSQL veritabanında saklamadan ve Next.js ön yüzünde işlemeden önce düzgün bir şekilde temizlememektedir. Bu durum, bir saldırganın kötü amaçlı JavaScript kodu enjekte etmesine olanak tanır.
**Saldırı Vektörü:** Kimliği doğrulanmış bir kullanıcı, bir `<script>` yükü içeren bir yorum gönderir. Diğer kullanıcılar profili görüntülediğinde, betik onların tarayıcısında çalışır ve potansiyel olarak oturum çerezlerini çalar veya onlar adına eylemler gerçekleştirir.
**Etki:** Oturum ele geçirme, hesap devralma, oltalama saldırıları ve uygulamanın tahrif edilmesi.
**Öneri:**
1. **Arka Yüz (Laravel):** Veriyi kaydetmeden önce sunucu tarafı girdi temizleme uygulayın. Kötü amaçlı etiketleri ve nitelikleri temizlemek için `HTMLPurifier` gibi bir kütüphane kullanın.
```php
// Controller içinde
use Mews\Purifier\Facades\Purifier;
$validatedData['comment'] = Purifier::clean(request('comment'));
// ... veritabanına kaydet
```
2. **Ön Yüz (Next.js):** DOM'a işlenen tüm verilerin düzgün bir şekilde kodlandığından emin olun. React kullanılıyorsa, bu genellikle varsayılan olarak halledilir, ancak `dangerouslySetInnerHTML` kullanırken dikkatli olun.Comments (0)
Please sign in to leave a comment