Download the PHP package salvatorecervone/laravel-pentest without Composer
On this page you can find all versions of the php package salvatorecervone/laravel-pentest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download salvatorecervone/laravel-pentest
More information about salvatorecervone/laravel-pentest
Files in salvatorecervone/laravel-pentest
Package laravel-pentest
Short Description Automated In-App Penetration Testing and DAST Security Audit Suite for Laravel
License MIT
Homepage https://github.com/SalvatoreCervone/laravel-pentest
Informations about the package laravel-pentest
Laravel Penetration Tester (laravel-pentest)
Automated In-App Penetration Testing and DAST Security Audit Suite for Laravel.
laravel-pentest turns your Laravel CLI and test environment into an automated, in-app offensive security tester. It scans and simulates real-world attack vectors against your routes, Eloquent models, controllers, database connections, and configurations to detect critical security gaps before bad actors do:
- BOLA / IDOR vulnerabilities (missing Policy & Gate authorizations on resource models)
- Mass Assignment flaws (
$guarded = [], risky$fillablecolumns, unfiltered$request->all()) - Unprotected Admin Routes (sensitive endpoints missing authentication middleware)
- Missing Rate Limiters (brute-force exposure on login, 2FA, and password-reset endpoints)
- Insecure HTTP Security Headers (missing CSP, HSTS, X-Frame-Options, X-Content-Type-Options)
- Active Debug & Secret Leaks (
APP_DEBUG=truein production, exposed.envand.gitfiles) - Database Hardening & Least Privilege (weak/empty passwords, root/superuser connection, missing TLS/SSL on remote DBs, exposed SQLite)
- Sensitive Data & PII Exposure (unencrypted PII columns without
casts = ['...' => 'encrypted'], secrets leaked outside$hidden) - Cryptographic & Key Integrity (missing/weak
APP_KEY, low bcrypt work factors, insecure.envfilesystem permissions) - SQL Injection in Raw Queries (string concatenations in
whereRaw(),havingRaw(),orderByRaw(), andDB::raw()) - Session & Cookie Hardening (missing
secure, disabledhttp_only, insecuresame_siteflags) - CORS Misconfiguration (wildcard origins with credentials, permissive regexes, sensitive exposed headers)
Table of Contents
- Features
- Requirements
- Installation
- Usage
- Run All Penetration Tests
- Run a Specific Audit Suite
- Fail CI Pipeline on Vulnerabilities
- Generate Standalone HTML Report
- Interactive Web Security Dashboard
- Security Baseline & False Positive Suppressions
- Safe Database Probing (
DatabaseSandbox)
- Audit Suites & Vulnerabilities Detected
- CI/CD Integration (GitHub Actions)
- Configuration
- Running Tests
- Security Vulnerabilities
- License
Requirements
- PHP:
^8.2 - Laravel Framework:
^10.0,^11.0, or^12.0
Installation
Install the package via Composer as a development dependency:
Publish the package configuration file (optional):
Usage
Run All Penetration Tests
Output preview:
Run a Specific Audit Suite
Filter which audit suite to execute using the --suite option:
Baseline & False-Positive Suppression
When introducing laravel-pentest to an existing codebase with legacy debt, avoid breaking the CI build by generating a baseline file:
Subsequent runs will automatically suppress known baseline issues, ensuring only new security regressions trigger alerts and fail the CI pipeline:
Fail CI Pipeline on Vulnerabilities
Exit with status code 1 if any Critical or High vulnerability is identified:
Or exit with status code 1 on any finding (including low or medium):
Generate Standalone HTML / JSON Reports
Export a beautifully formatted, responsive standalone HTML security report or JSON export. All generated reports automatically include the current date and time (YYYY-MM-DD_HH-mm-ss) in their filename to preserve historical audit logs:
Interactive Web Security Dashboard
Launch live security scans directly in your browser with real-time feedback and an interactive vulnerability explorer:
- Access URL:
http://localhost:8000/pentest(or your configured application domain) - Enabled by default in
localandtestingenvironments (configurable inconfig/pentest.php). - Zero external dependencies (pure vanilla CSS & lightweight JS).
- Target Actor & Environment Scope:
- Automatically detects active database connection settings from
.envandconfig/database.php. - Live User Selector Dropdown: Select test users directly from your database table/model (
#1 — Mario Rossi ([email protected])) with a single click, or type a custom user ID / email. - Model/Table Fetch: Change the target user model or table (e.g.
App\Models\Userorusers) and click🔄 Fetchto dynamically reload available users from any configured database connection. - Supports testing as Anonymous Guest and/or a specific Simulated Test Actor (by User ID or Email).
- Isolates DAST runtime probes from your active browser session so that logged-in SuperAdmin sessions do not generate false positives on dynamic ACL / permission managers (e.g. dynamic guards, Spatie, Bouncer).
- Automatically detects active database connection settings from
- Allows developers to trigger full audits with a single click, download timestamped HTML/JSON reports reflecting the active scope, and review findings with remediation advice instantly.
Security Baseline & False Positive Suppressions
Prevent legacy findings from blocking ongoing CI workflows while ensuring zero new regressions:
You can also suppress specific false positives permanently in config/pentest.php:
Safe Database Probing (DatabaseSandbox)
When performing active security probes or simulating input mutation against models and database connections, laravel-pentest provides transactional rollback isolation:
Route Access Matrix & Safe Non-GET Auditing (--access-map)
Audits all application routes and maps exactly which endpoints and Controller@action methods are reachable (200 OK or redirects) by the tested identity (Guest or authenticated user, e.g. Pippo).
- 100% Safe Non-GET Execution: When probing mutating verbs (
POST,PUT,PATCH,DELETE),DatabaseSandbox::executeSafely()begins transactions across all active database connections, suppresses side-effects (Events, Mail, Notifications, Queues via in-memory fakes), and guarantees a complete rollback to level 0 in afinallyblock. Zero persistent changes or external side-effects! - Automated BFLA Detection (
forbidden_routes): Configure endpoints or controller patterns that should never be reachable by the tested persona:
If the tested persona accesses any forbidden endpoint with success, an automatic CRITICAL vulnerability (UNAUTHORIZED_ROUTE_ACCESS / CWE-285) is generated!
Audit Suites & Vulnerabilities Detected
| Suite | Vulnerability ID | CWE | Default Severity | What It Tests |
|---|---|---|---|---|
route-exposure |
UNPROTECTED_SENSITIVE_ROUTE |
CWE-306 | CRITICAL / HIGH |
Scans registered routes for sensitive paths (admin/*, users/*, billing/*, reports/*) that lack authentication middleware. |
idor-bola |
POTENTIAL_IDOR_BOLA |
CWE-639 | HIGH |
Analyzes Route-Model binding endpoints to verify that Policies, Gates, or FormRequests protect user resources against horizontal privilege escalation. |
mass-assignment |
UNGUARDED_ELOQUENT_MODEL |
CWE-915 | CRITICAL |
Detects models declaring $guarded = [] without $fillable, leaving database columns open to arbitrary modifications. |
mass-assignment |
DANGEROUS_FILLABLE_ATTRIBUTES |
CWE-915 | HIGH |
Identifies privileged fields (is_admin, role_id, balance, permissions, is_superadmin) dangerously declared inside $fillable. |
mass-assignment |
UNFILTERED_REQUEST_MASS_ASSIGNMENT |
CWE-915 | HIGH |
Flags controller methods passing unfiltered $request->all() directly into Model::create() or $model->update(). |
csrf-protection |
MISSING_CSRF_PROTECTION |
CWE-352 | HIGH |
Verifies state-changing routes (POST, PUT, PATCH, DELETE) enforce CSRF token validation. |
rate-limit |
MISSING_RATE_LIMITING |
CWE-307 | HIGH |
Ensures that authentication, login, password recovery, and token endpoints enforce throttling (throttle:x,y) against brute force. |
security-headers |
MISSING_X_FRAME_OPTIONS |
CWE-1021 | MEDIUM |
Checks HTTP responses for clickjacking defenses (X-Frame-Options: SAMEORIGIN / DENY). |
security-headers |
MISSING_CSP |
CWE-79 | MEDIUM |
Checks for missing Content-Security-Policy (CSP) header. |
security-headers |
MISSING_HSTS |
CWE-319 | MEDIUM |
Asserts that Strict-Transport-Security (HSTS) is enabled in production. |
security-headers |
MISSING_X_CONTENT_TYPE_OPTIONS |
CWE-79 | LOW |
Verifies the X-Content-Type-Options: nosniff header to block MIME sniffing. |
debug-exposure |
APP_DEBUG_ENABLED_IN_PRODUCTION |
CWE-489 | CRITICAL |
Detects APP_DEBUG=true in production environments, exposing stack traces and database credentials. |
debug-exposure |
EXPOSED_SENSITIVE_FILE |
CWE-552 | CRITICAL / HIGH |
Checks whether sensitive files (.env, .git, storage/logs/laravel.log, .sql dumps) are placed in the public/ web root. |
database-security |
EMPTY_DATABASE_PASSWORD |
CWE-521 | CRITICAL |
Flags blank/missing passwords on network database connections. |
database-security |
WEAK_DATABASE_PASSWORD |
CWE-521 | CRITICAL |
Detects trivial/default passwords (root, admin, 123456, secret). |
database-security |
HIGHLY_PRIVILEGED_DATABASE_USER |
CWE-250 | HIGH |
Detects connecting as DBA/superuser (root, postgres, sa), violating Least Privilege. |
database-security |
UNENCRYPTED_REMOTE_DATABASE_CONNECTION |
CWE-319 | HIGH |
Verifies remote databases enforce TLS/SSL (sslmode=require / MYSQL_ATTR_SSL_CA). |
database-security |
EXPOSED_SQLITE_DATABASE |
CWE-552 | CRITICAL |
Flags SQLite databases stored inside the public/ web directory. |
sensitive-data |
UNENCRYPTED_SENSITIVE_ATTRIBUTE |
CWE-311 | HIGH |
Identifies PII columns (ssn, tax_number, credit_card, iban) missing casts = ['...' => 'encrypted']. |
sensitive-data |
SENSITIVE_ATTRIBUTE_NOT_HIDDEN |
CWE-200 | HIGH |
Detects secrets and auth tokens (password, two_factor_secret, api_token) missing from Eloquent $hidden. |
crypto-security |
MISSING_APP_KEY / PLACEHOLDER_APP_KEY |
CWE-321 | CRITICAL |
Asserts APP_KEY exists, is non-default, and matches cipher bit requirements. |
crypto-security |
WEAK_BCRYPT_ROUNDS |
CWE-916 | HIGH |
Validates password hashing work factors (bcrypt.rounds >= 10, recommended 12+). |
dependency-security |
VULNERABLE_COMPOSER_DEPENDENCY |
CWE-1395 | CRITICAL / HIGH |
Scans composer.lock for known advisories and CVEs in dependencies. |
dependency-security |
ABANDONED_OR_DEPRECATED_PACKAGE |
CWE-1104 | MEDIUM |
Warns about abandoned packages with known migration alternatives. |
cors-security |
CORS_WILDCARD_WITH_CREDENTIALS |
CWE-942 | CRITICAL |
Detects wildcard allowed origins (*) combined with supports_credentials => true. |
cors-security |
CORS_PERMISSIVE_ORIGIN_REGEX |
CWE-942 | HIGH |
Flags unanchored or overly permissive regular expressions in allowed_origins_patterns. |
cors-security |
CORS_SENSITIVE_EXPOSED_HEADER |
CWE-200 | MEDIUM |
Identifies authorization and session headers exposed to cross-origin callers. |
session-security |
SESSION_COOKIE_NOT_SECURE |
CWE-614 | HIGH |
Ensures session cookies enforce the secure flag in production/staging environments. |
session-security |
SESSION_COOKIE_NOT_HTTPONLY |
CWE-1004 | CRITICAL |
Asserts http_only => true to prevent session hijacking via JavaScript document.cookie. |
session-security |
SESSION_COOKIE_SAMESITE_INSECURE |
CWE-1275 | HIGH |
Validates same_site => 'lax' or 'strict' to prevent cross-site request leakage. |
session-security |
EXCESSIVE_SESSION_LIFETIME |
CWE-613 | LOW |
Warns if session expiration exceeds 30 days without re-authentication. |
sqli-safety |
SQL_INJECTION_RAW_QUERY |
CWE-89 | CRITICAL |
Scans controller methods for unparameterized string concatenations in whereRaw, havingRaw, orderByRaw, and DB::raw. |
route-access |
UNAUTHORIZED_ROUTE_ACCESS |
CWE-285 | CRITICAL |
Generates a complete Route Access Matrix for the tested persona (Guest vs User) mapping reachable endpoints and Controller@action, flagging forbidden routes with 100% safe non-GET execution. |
Writing Tests with InteractsWithPentest
Integrate pentest assertions directly into your existing PHPUnit or Pest test suites:
CI/CD Integration (GitHub Actions)
Add this workflow to your repository (.github/workflows/security-pentest.yml) to automatically block pull requests containing new security regressions:
Configuration
You can customize the scan behavior in config/pentest.php:
Excluding Session-Altering & Profile Routes
During security audits (such as the Route Access and IDOR/BOLA audits), laravel-pentest executes dynamic runtime probes against application endpoints.
To avoid session lock contention, unintended credential modifications, or session termination during live scans, certain routes should be excluded via ignore_routes:
-
Framework Profile & Auth Endpoints (Jetstream / Fortify / Breeze): Routes like
user/profile-photo,user/other-browser-sessions,user/password, anduser/two-factor-*alter avatar storage, terminate other browser sessions, or regenerate security tokens. The package ignores these by default, but you can customize or extend the patterns. -
Custom Session-Altering & Logout Routes: If your application defines custom endpoints that flush session tables, kill user tokens, or operate on native PHP session locks (e.g.
/logout,/admin/terminate-sessions), add them toignore_routes. - Flexible Pattern Matching (URI & Controller Actions):
Patterns support wildcard
fnmatchmatching against both the URI and the Controller Action name:- URI patterns:
'user/*','session/terminate-all','auth/logout' - Controller patterns:
'*OtherBrowserSessionsController*','App\Http\Controllers\Auth\SessionController@*'
- URI patterns:
Sandbox Execution Safeguards
When evaluating mutating endpoints (POST, PUT, PATCH, DELETE):
- 100% Database Transaction Rollback: All queries executed inside a probe run within isolated database transactions and are completely rolled back in a
finallyblock. - In-Memory Session Isolation: Requests use isolated in-memory session handlers (
ArraySessionHandler) to prevent writing to session storage or locking files. - Faked Side-Effects: External integrations are automatically mocked using
Storage::fake(),Http::fake(),Mail::fake(),Queue::fake(),Event::fake(),Notification::fake(), andBroadcasting(switched tonulldriver to suppress Pusher, Reverb, and WebSocket network calls).
Running Tests
Run the test suite with PHPUnit:
Security Vulnerabilities
If you discover a security vulnerability within laravel-pentest, please open an issue or submit a pull request on GitHub.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-pentest with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/routing Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0