Documentation
Protect your applications from SQL injection, XSS, and 25+ attack vectors in 30 seconds. No complex setup. No dependencies.
Installation
Choose the method that fits your workflow β all take less than 60 seconds
Manual Installation
Perfect for shared hosting, cPanel, or when you prefer full control.
kriosa.php
index.php
or bootstrap file
Quick Code Integration
Add these 2 lines to your entry point file.
<?php
// Add this to your index.php or front controller
require_once __DIR__ . '/kriosa.php';
$apiKey = getenv('KRIOSA_API_KEY') ?: 'YOUR_API_KEY_HERE';
try {
$kriosa = new Kriosa($apiKey, [
'timeout' => 3,
'debug' => false,
'fail_closed' => false,
'show_badge' => true,
]);
if (!$kriosa->protect()) {
header('X-Kriosa-Blocked: true');
http_response_code(403);
exit('Access Denied');
}
} catch (Exception $e) {
error_log('Kriosa Security Error: ' . $e->getMessage());
}
// Your application continues safely here...
Direct URL Include β Zero File Upload
Just one line of code β perfect for testing or quick prototypes.
<?php
// Add this single line to your index.php
step 1:
require_once 'https://kriosa.com/kriosa.php';
step 2:
// Define your API key in .env or directly:
require_once __DIR__ . '/kriosa.php';
step 3:
$apiKey = getenv('KRIOSA_API_KEY') ?: 'YOUR_API_KEY_HERE';
try {
$kriosa = new Kriosa($apiKey, [
'timeout' => 3,
'debug' => false,
'fail_closed' => false,
'show_badge' => true,
]);
if (!$kriosa->protect()) {
header('X-Kriosa-Blocked: true');
http_response_code(403);
exit('Access Denied');
}
} catch (Exception $e) {
error_log('Kriosa Security Error: ' . $e->getMessage());
}
Composer (PHP)
Best for modern PHP applications and dependency management.
# Install via Composer
composer require kriosa-ai/kriosa-php
# Or add to your composer.json{
"require": {
"kriosa-ai/kriosa-php": "v1.0.1"
}
}
<?php
// After Composer installation
require_once 'vendor/autoload.php';
$apiKey = getenv('KRIOSA_API_KEY') ?: 'YOUR_API_KEY_HERE';
try {
$kriosa = new Kriosa($apiKey, [
'timeout' => 3,
'debug' => false,
'fail_closed' => false,
'show_badge' => true,
]);
if (!$kriosa->protect()) {
header('X-Kriosa-Blocked: true');
http_response_code(403);
exit('Access Denied');
}
} catch (Exception $e) {
error_log('Kriosa Security Error: ' . $e->getMessage());
}
// Your application continues safely...
One-Line Installer (CLI)
For VPS/SSH users who want the fastest setup.
# One-line installer with curlcurl -sS https://kriosa.com/install.sh | bash
# Or with wgetwget -qO- https://kriosa.com/install.sh | bash
This automatically downloads and configures kriosa.php in your current directory.
Framework Integrations
Kriosa works seamlessly with your favorite PHP framework
Laravel Integration
Add Kriosa to your Laravel application as middleware for automatic protection on every request.
composer require kriosa-ai/kriosa-php
Add these environment variables to your .env file:
KRIOSA_API_KEY=sk_your_api_key_here
KRIOSA_TIMEOUT=5
KRIOSA_DEBUG=false
KRIOSA_BADGE=true
Create the configuration file:
// config/kriosa.php
return [
'api_key' => env('KRIOSA_API_KEY'),
'timeout' => env('KRIOSA_TIMEOUT', 5),
'debug' => env('KRIOSA_DEBUG', false),
];
Run the artisan command and replace the contents:
// app/Http/Middleware/KriosaSecurity.php
use Closure;
use Kriosa;
use Illuminate\Http\Request;
class KriosaSecurity
{
public function handle(Request $request, Closure $next)
{
$apiKey = config('kriosa.api_key');
// Skip if no API key configured
if (!$apiKey) {
return $next($request);
}
try {
$kriosa = new Kriosa($apiKey, [
'timeout' => config('kriosa.timeout', 5),
'debug' => config('kriosa.debug', false),
]);
if (!$kriosa->protect()) {
return response('Access denied', 403);
}
} catch (\Exception $e) {
// Fail open β don't block users if Kriosa is unreachable
report($e);
}
return $next($request);
}
}
Register the middleware in app/Http/Kernel.php:
// app/Http/Kernel.php
protected $middleware = [
// ... existing middleware
\App\Http\Middleware\KriosaSecurity::class,
];
// OR apply to specific routes only:
// routes/web.php
Route::middleware(['kriosa'])->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index']);
});
Also works with: Yii2, CakePHP, Phalcon, Slim, Lumen, Zend/Laminas, and any PHP framework
Simply include kriosa.php in your bootstrap/front controller β instant protection!
Why Choose KRIOSA?
Simple integration, powerful protection β built for developers by developers
30 Second Install
One file. One API key. One include. No configuration files, no database setup, no friction.
25+ Attack Vectors
SQL injection, XSS, command injection, path traversal, LDAP, NoSQL, SSRF, XXE, deserialization, CSRF, IDOR, and more.
AI-Powered Detection
Machine learning models trained on real threat intelligence detect zero-day attacks traditional WAFs miss.
Lightning Fast
Average response time under 10ms. Your users won't notice the protection, but attackers will.
Works Anywhere
Shared hosting, VPS, dedicated servers, even localhost. Anywhere PHP 5.6+ runs, Kriosa works.
24/7 Expert Support
Email, WhatsApp, and ticket system. Our security engineers are here when you need them.
Complete Protection
Every attack vector we detect and block in real-time
Injection Attacks
- SQL Injection
- NoSQL Injection
- LDAP Injection
- Command Injection
- Code Injection
Cross-Site Attacks
- XSS (Reflected/Stored/DOM)
- CSRF
- IDOR
- Open Redirect
Server-Side Attacks
- SSRF
- XXE
- Path Traversal
- Deserialization
Additional Protections
- Rate Limiting
- Brute Force Protection
- Malicious Bot Detection
- Suspicious Pattern Matching
Handling API Timeouts & Fail Behavior
One of the most important configuration decisions in Kriosa. Understand exactly what happens when the API cannot be reached so you can configure it correctly for your use case.
By default, Kriosa is configured to fail open. If the API does not respond within the timeout window, the request is not automatically blocked.
This is intentional. A misconfigured timeout that locks out all traffic on a fresh install is a worse experience than a brief unprotected window during an API hiccup.
But it does not just wave requests through.
Before making any fallback decision, the SDK runs a local pattern matching layer directly on the raw request. This covers:
If a request matches any of these patterns locally, it gets blocked immediately β no API call needed.
fail_closed: false
Request passes through
fail_closed: true
Request blocked
Authenticated Traffic
User dashboards, admin panels, API endpoints
Any request that cannot be fully evaluated gets blocked rather than passed through. The tradeoff is availability β if Kriosa API goes down, protected routes go down with it. For sensitive authenticated traffic, that is the correct tradeoff.
$kriosa = new Kriosa('your-key', [
'fail_closed' => true, // block all unverified requests 'timeout' => 5, // give API up to 5s to respond]);
Public Pages
Marketing pages, landing pages, public content
Availability matters more than strict security. The local fallback layer still catches obvious attack patterns. Full ML analysis resumes as soon as the API is reachable again.
$kriosa = new Kriosa('your-key', [
'fail_closed' => false, // local patterns only on API failure 'timeout' => 3, // shorter timeout for public pages]);
| Setting | Best For | Behavior on API Failure |
|---|---|---|
fail_closed: false |
Public pages | Local patterns only β clean requests pass through |
fail_closed: true |
Authenticated routes | Block all unverified requests |
Fail open for public traffic, fail closed for anything a logged-in user touches.
API Reference
Simple, RESTful API for seamless integration
Request
{
"user_id": 123,
"tenant_id": "tenant_abc",
"ip_address": "192.168.1.100",
"user_agent": "Mozilla/5.0...",
"method": "POST",
"resource": "/api/users",
"payload": { "username": "john" },
"query_params":{ "page": 1 }
}
Allowed Response
{
"allowed": true,
"request_id": "req_abc123xyz",
"processing_time_ms": 45,
"score": 12
}
Blocked Response
{
"allowed": false,
"attack_type": "sql_injection",
"threat_score": 95,
"request_id": "req_def456uvw",
"details": "Malicious pattern detected in 'username' field"
}
Frequently Asked Questions
Everything you need to know about KRIOSA
No! Just download <code>kriosa.php</code> and include it in your project. That's it. No Composer, no npm, no external libraries β pure PHP that works everywhere.
No. Our average response time is under 10ms, and all processing happens asynchronously. Your users won't notice any difference, but attackers will be blocked instantly.
Absolutely! Kriosa works anywhere PHP runs (5.6+). No special extensions, no root access required β perfect for shared hosting, cPanel, and managed WordPress hosting.
Our ML models achieve 99.9% detection rate with less than 0.01% false positives. Models are continuously retrained on real attack data from CISA KEV, OWASP, and our global threat intelligence network.
Yes! We have dedicated plugins and integration guides for WordPress, Laravel, Symfony, CodeIgniter, Yii2, CakePHP, and any PHP framework. Check the Installation section for framework-specific instructions.
Every block includes an <code>attack_type</code> and <code>request_id</code> for debugging. You can whitelist specific patterns from your dashboard, adjust security sensitivity, or report false positives to our team for model improvement.
Yes! The free tier includes 10,000 requests per month β perfect for small projects, testing, or development environments. No credit card required to start.
Need Help? We're Here 24/7
Our security engineers are ready to assist you with integration, configuration, or any questions.