iri-shield 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +459 -0
- package/benchmark/README.md +35 -0
- package/benchmark/datasets/attacks.json +2596 -0
- package/benchmark/datasets/generate-datasets.js +406 -0
- package/benchmark/datasets/identity-scenarios.json +6002 -0
- package/benchmark/datasets/redaction-samples.json +8664 -0
- package/benchmark/false-positive-evaluate.js +188 -0
- package/benchmark/generate-charts.js +248 -0
- package/benchmark/identity-evaluate.js +150 -0
- package/benchmark/redaction-evaluate.js +143 -0
- package/benchmark/research-evaluate.js +254 -0
- package/benchmark/run.js +346 -0
- package/benchmark/security-baseline-compare.js +241 -0
- package/benchmark/security-evaluate.js +251 -0
- package/index.js +3 -0
- package/package.json +68 -0
- package/src/behaviour.js +135 -0
- package/src/correlation.js +120 -0
- package/src/dashboard.js +1682 -0
- package/src/identity.js +299 -0
- package/src/index.js +672 -0
- package/src/mongodb-storage.js +237 -0
- package/src/redactor.js +104 -0
- package/src/rules.js +113 -0
- package/src/sqlite-storage.js +793 -0
- package/src/storage.js +404 -0
- package/src/threats.js +297 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ansari Intesab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
# 🛡️ iri-shield
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/iri-shield)
|
|
4
|
+
[](https://opensource.org/licenses/ISC)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
[](#-explainable-risk-scoring)
|
|
7
|
+
[](#-privacy-by-design)
|
|
8
|
+
|
|
9
|
+
> **Enterprise-grade API security middleware for Express.js** featuring **Explainable Risk Scoring**, **Multi-Signal Identity Continuity Analysis**, **Behavioural Anomaly Detection**, **Attack Sequence Correlation**, **Configurable Rule Engine**, **Automated PII/Secret Redaction**, and an **Interactive Real-Time Admin Dashboard**.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📑 Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Architectural Philosophy](#-architectural-philosophy)
|
|
16
|
+
- [Key Features](#-key-features)
|
|
17
|
+
- [Installation](#-installation)
|
|
18
|
+
- [Quick Start](#-quick-start)
|
|
19
|
+
- [Explainable Risk Scoring](#-explainable-risk-scoring)
|
|
20
|
+
- [Multi-Signal Identity Continuity](#-multi-signal-identity-continuity)
|
|
21
|
+
- [Security Rule Engine](#-security-rule-engine)
|
|
22
|
+
- [Behavioural Anomaly & Correlation](#-behavioural-anomaly--correlation)
|
|
23
|
+
- [Privacy Controls & Fail-Safe Modes](#-privacy-controls--fail-safe-modes)
|
|
24
|
+
- [Interactive Admin Dashboard](#-interactive-admin-dashboard)
|
|
25
|
+
- [Automated Benchmarking](#-automated-benchmarking)
|
|
26
|
+
- [Full Configuration Reference](#-full-configuration-reference)
|
|
27
|
+
- [Security & Auth Utilities](#-security--auth-utilities)
|
|
28
|
+
- [Academic & Research Defense](#-academic--research-defense)
|
|
29
|
+
- [License](#-license)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🏛️ Architectural Philosophy
|
|
34
|
+
|
|
35
|
+
Modern web threats exploit fragmented signals across rotating IP pools, forged User-Agents, and multi-step evasion techniques. Traditional WAFs rely solely on static signatures or opaque binary decisions.
|
|
36
|
+
|
|
37
|
+
`iri-shield` introduces a **transparent, multi-layered defense model**:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
Incoming HTTP Request
|
|
41
|
+
│
|
|
42
|
+
├──► 1. Base Security (Helmet Headers, CORS, Fail-Safe Policy)
|
|
43
|
+
├──► 2. Identity Continuity Engine (IP + Session + Client Hints + Drift Analysis)
|
|
44
|
+
├──► 3. Configurable Rule Engine (SQLi, XSS, Path Traversal, SSTI, Custom Rules)
|
|
45
|
+
├──► 4. Behavioural Baseline (Rolling 5-min RPM & Deviation Tracking)
|
|
46
|
+
├──► 5. Attack Sequence Correlation (Multi-Step Recon & Takeover Chains)
|
|
47
|
+
├──► 6. Explainable Risk Scorer (Transparent Point Breakdown + Confidence Score)
|
|
48
|
+
├──► 7. Automated Mitigation (Rate-Limit, Temporary Block, Permanent Block)
|
|
49
|
+
└──► 8. Automated Response & Log Redaction (PII Masking)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ✨ Key Features
|
|
55
|
+
|
|
56
|
+
| Capability | Description |
|
|
57
|
+
| :--- | :--- |
|
|
58
|
+
| **🔍 Explainable Risk Scoring** | Provides a transparent, auditable breakdown table (`+30 SQLi`, `+20 Sensitive Endpoint`, `+15 Identity Drift`) with a mathematical **Confidence Score (0-100%)**. |
|
|
59
|
+
| **🧬 Multi-Signal Profiling** | Evaluates **Identity Continuity** using IP address, session tokens, Client Hints (`sec-ch-ua`, `sec-ch-ua-platform`), user-agents, accept headers, and device context to detect evasion attempts without violating user privacy. |
|
|
60
|
+
| **⚙️ Configurable Rule Engine** | Individually toggle built-in threat detection rules or declare flexible **Custom Rules** (by endpoint, method, IP prefix, user-agent regex, or body fields). |
|
|
61
|
+
| **📈 Behavioural Baselining** | Continuously learns normal per-endpoint request rates (RPM) and flags statistical anomalies (`Behaviour deviation: 92%`). |
|
|
62
|
+
| **🔗 Attack Sequence Correlation** | Evaluates ordered request chains to detect advanced multi-step campaigns (e.g., *Failed Auth ×3 → User Enumeration → Admin Access*). |
|
|
63
|
+
| **🔒 Privacy by Design** | Built-in SHA-256 IP hashing for persistent storage and automatic FIFO retention purging (`retentionDays: 30`). |
|
|
64
|
+
| **🛡️ Fail-Safe Policies** | Choose between `fail-open` (resilience first) and `fail-closed` (strict containment) on internal subsystem failures. |
|
|
65
|
+
| ** Built-in Benchmark Suite** | Automated performance comparison against baseline unshielded servers (`npm run benchmark`) measuring throughput, latency percentiles (p50/p95/p99), and defense efficacy. |
|
|
66
|
+
| **🖥️ Light-Theme Dashboard** | Enterprise management interface for real-time monitoring, reactive IP block/unblock, active alerts, security event forensics, and live configuration updates. |
|
|
67
|
+
| **🎭 Deep PII/Secret Redaction** | Deep redaction for passwords, API keys, bearer tokens, emails, phone numbers, SSNs, Aadhaar numbers, and credit cards across responses and log storage. |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 📦 Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install iri-shield
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> **Requirements**: Node.js **>= 22.0.0** recommended for native SQLite (`node:sqlite`) support.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ⚡ Quick Start
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
const express = require('express');
|
|
85
|
+
const { createShield, apiKeyAuth } = require('iri-shield');
|
|
86
|
+
|
|
87
|
+
const app = express();
|
|
88
|
+
app.use(express.json());
|
|
89
|
+
|
|
90
|
+
// Initialize iri-shield
|
|
91
|
+
const shield = createShield({
|
|
92
|
+
appName: 'secure-api',
|
|
93
|
+
security: 'medium', // 'low' | 'medium' | 'high'
|
|
94
|
+
storage: {
|
|
95
|
+
mode: 'sqlite',
|
|
96
|
+
sqliteFile: './data/iri-shield.sqlite'
|
|
97
|
+
},
|
|
98
|
+
dashboard: {
|
|
99
|
+
enabled: true,
|
|
100
|
+
path: '/iri-shield',
|
|
101
|
+
username: 'admin',
|
|
102
|
+
password: 'admin'
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Attach security middleware
|
|
107
|
+
app.use(shield.middleware);
|
|
108
|
+
|
|
109
|
+
// Attach admin dashboard
|
|
110
|
+
app.use('/iri-shield', shield.dashboard);
|
|
111
|
+
|
|
112
|
+
// Example protected endpoint
|
|
113
|
+
app.get('/api/users', apiKeyAuth('my-secret-key'), (req, res) => {
|
|
114
|
+
res.json({
|
|
115
|
+
status: 'success',
|
|
116
|
+
token: 'jwt-secret-token-abc', // Automatically redacted to [REDACTED]
|
|
117
|
+
email: 'alex@example.com' // Automatically redacted to [REDACTED]
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
app.listen(3000, () => {
|
|
122
|
+
console.log('🚀 Server running on http://localhost:3000');
|
|
123
|
+
console.log(' Dashboard available at http://localhost:3000/iri-shield');
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🔍 Explainable Risk Scoring
|
|
130
|
+
|
|
131
|
+
Every intercepted security event produces a transparent **Score Breakdown**:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"score": 85,
|
|
136
|
+
"riskLevel": "high",
|
|
137
|
+
"confidence": 92,
|
|
138
|
+
"action": "temporary_block",
|
|
139
|
+
"breakdown": [
|
|
140
|
+
{ "rule": "sql_injection", "points": 40, "category": "injection", "confidence": 90, "label": "SQL Injection pattern" },
|
|
141
|
+
{ "rule": "sensitive_endpoint_access", "points": 20, "category": "anomaly", "confidence": 80, "label": "Access to sensitive endpoint: /admin" },
|
|
142
|
+
{ "rule": "correlated_attack_account_takeover", "points": 25, "category": "correlation", "confidence": 88, "label": "Possible account takeover / reconnaissance" }
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
In the **Admin Dashboard**, expanding any Security Event displays this structured breakdown table, enabling instant auditability for security analysts.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 🧬 Multi-Signal Identity Continuity
|
|
152
|
+
|
|
153
|
+
Rather than claiming "guaranteed unique identification" (which is technically invalid across modern NATs and VPNs), `iri-shield` evaluates **Identity Continuity**:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
Known Client Profile (C-89a1)
|
|
157
|
+
├── Baseline Hardware Hash
|
|
158
|
+
├── Platform & Client Hints (Windows / Chrome 120)
|
|
159
|
+
└── Established Sessions
|
|
160
|
+
│
|
|
161
|
+
▼
|
|
162
|
+
Sudden Switch Detected:
|
|
163
|
+
• New IP (203.0.113.88)
|
|
164
|
+
• Missing Modern Sec-Fetch Headers
|
|
165
|
+
• Identity Drift Count: +1
|
|
166
|
+
│
|
|
167
|
+
▼
|
|
168
|
+
Action: Risk Score Penalty (+15 pts) applied to request
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## ⚙️ Security Rule Engine
|
|
174
|
+
|
|
175
|
+
Toggle built-in detection modules or supply flexible custom rules:
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
const shield = createShield({
|
|
179
|
+
rules: {
|
|
180
|
+
sqlInjection: true,
|
|
181
|
+
xss: true,
|
|
182
|
+
pathTraversal: true,
|
|
183
|
+
commandInjection: true,
|
|
184
|
+
ssti: true,
|
|
185
|
+
nosqlInjection: true,
|
|
186
|
+
secretProbe: true,
|
|
187
|
+
scannerDetection: true,
|
|
188
|
+
openRedirect: true,
|
|
189
|
+
headerAnomaly: true,
|
|
190
|
+
|
|
191
|
+
// Custom Rules
|
|
192
|
+
customRules: [
|
|
193
|
+
{
|
|
194
|
+
name: 'restrict-internal-billing',
|
|
195
|
+
match: {
|
|
196
|
+
endpoint: '/api/v1/internal/billing',
|
|
197
|
+
method: ['POST', 'DELETE']
|
|
198
|
+
},
|
|
199
|
+
score: 35,
|
|
200
|
+
label: 'Sensitive Billing Modification Attempt',
|
|
201
|
+
confidence: 90
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'block-deprecated-crawler',
|
|
205
|
+
match: {
|
|
206
|
+
userAgent: /legacy-scraper/i
|
|
207
|
+
},
|
|
208
|
+
score: 40,
|
|
209
|
+
label: 'Deprecated Scraper Bot Match',
|
|
210
|
+
confidence: 95
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 📈 Behavioural Anomaly & Correlation
|
|
220
|
+
|
|
221
|
+
### 1. Rolling Behaviour Baseline
|
|
222
|
+
Maintains a 5-minute rolling request rate (RPM) profile per IP and endpoint. Sudden traffic spikes (>3× baseline) trigger a proportional anomaly score penalty:
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
Endpoint: /api/login
|
|
226
|
+
Baseline Rate: 2.4 req/min
|
|
227
|
+
Current Rate: 45.0 req/min
|
|
228
|
+
Behaviour Deviation: 94% (Anomaly Penalty: +18 pts)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 2. Attack Sequence Correlation
|
|
232
|
+
Detects multi-step attack patterns across request sequences:
|
|
233
|
+
- **Account Takeover Chain**: Repeated failed logins followed by enumeration or admin route access.
|
|
234
|
+
- **Secret Enumeration**: Sequential probes for `.env`, `wp-config`, `.git`, or `config.json`.
|
|
235
|
+
- **Multi-Vector Escalation**: Combining SQL injection payloads with directory traversal probes.
|
|
236
|
+
- **Scanner Sweeps**: Rapidly touching 5+ distinct endpoints with automated tool fingerprints.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 🔒 Privacy Controls & Fail-Safe Modes
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
const shield = createShield({
|
|
244
|
+
// Fail-Safe Policy
|
|
245
|
+
failureMode: 'fail-open', // 'fail-open' (default) | 'fail-closed'
|
|
246
|
+
|
|
247
|
+
// Privacy by Design
|
|
248
|
+
privacy: {
|
|
249
|
+
hashIp: false, // If true, IPs are stored as SHA-256 hashes (e.g. sha256:4f8a...)
|
|
250
|
+
retainRawIp: true, // Retains raw IP in memory exclusively for active block enforcement
|
|
251
|
+
retentionDays: 30 // Automatically purges SQLite event/request logs older than 30 days
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 📊 Automated Benchmarking & Research Evaluation
|
|
259
|
+
|
|
260
|
+
`iri-shield` includes a built-in automated evaluation suite to benchmark performance, threat detection efficacy, false positives, identity continuity, and data redaction against baseline Express.js:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Run comprehensive multi-experiment research evaluation suite
|
|
264
|
+
npm run research:evaluate
|
|
265
|
+
|
|
266
|
+
# Or run individual benchmark modules:
|
|
267
|
+
npm run benchmark # Multi-workload latency/throughput matrix
|
|
268
|
+
npm run security:evaluate # 220-vector category threat detection
|
|
269
|
+
npm run security:compare # Vanilla Express vs iri-shield defense comparison
|
|
270
|
+
npm run fp:evaluate # 2,000 legitimate queries false positive evaluation
|
|
271
|
+
npm run identity:evaluate # 500-scenario identity continuity & drift evaluation
|
|
272
|
+
npm run redaction:evaluate # 500-sample recursive PII masking evaluation
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Comprehensive Research Evaluation Summary (v1.2.0-research)
|
|
276
|
+
|
|
277
|
+
| Evaluation Dimension | Workload / Dataset | Success Metric | Value | Baseline Comparison |
|
|
278
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
279
|
+
| **Threat Detection** | 220 Attack Payloads (14 Categories) | Overall Mitigation Rate | **97.3%** (214/220) | Vanilla Express: 0.0% (+97.7% Net Gain) |
|
|
280
|
+
| **False Positive Rate** | 2,000 Legitimate Queries | True Negative Pass Rate | **100.00%** (0% FPR) | Zero business disruption on clean traffic |
|
|
281
|
+
| **Identity Continuity** | 500 State Transitions | Profiling Accuracy | **100.0%** (0% False Drift) | Accurately flags IP/UA/Fingerprint drift |
|
|
282
|
+
| **PII Data Redaction** | 500 Structured Payloads | Redaction Precision | **100.0%** (0% Overmask) | 5-level nested JSON & unstructured logs |
|
|
283
|
+
| **Low-Load Overhead** | 300 Requests @ Concurrency 5 | Average Latency Delta | **+1.99 ms** | 2.97 ms (Base) vs 4.96 ms (Shield) |
|
|
284
|
+
|
|
285
|
+
### Multi-Workload Performance & Latency Matrix
|
|
286
|
+
|
|
287
|
+
| Workload Configuration | Baseline Req/s | Shield Req/s | Throughput Impact | Base Latency (Avg) | Shield Latency (Avg) | Overhead (Δ) | Shield p95 | Shield p99 | Host CPU (Base vs Shield) | Cores Utilized (Base vs Shield) |
|
|
288
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
289
|
+
| **300 req @ c=5** | 1,904 req/s | 997 req/s | -47.6% | 2.97 ms | 4.96 ms | **+1.99 ms** | 7.80 ms | 9.77 ms | 17.6% vs 13.6% | 1.41 vs 1.09 cores |
|
|
290
|
+
| **300 req @ c=15** | 2,404 req/s | 706 req/s | -70.6% | 6.28 ms | 21.49 ms | **+15.21 ms** | 34.24 ms | 35.73 ms | 12.8% vs 14.7% | 1.02 vs 1.17 cores |
|
|
291
|
+
| **500 req @ c=5** | 2,669 req/s | 630 req/s | -76.4% | 1.86 ms | 7.92 ms | **+6.06 ms** | 12.16 ms | 16.58 ms | 14.9% vs 13.1% | 1.19 vs 1.05 cores |
|
|
292
|
+
| **500 req @ c=15** | 3,097 req/s | 730 req/s | -76.4% | 4.79 ms | 20.44 ms | **+15.65 ms** | 29.80 ms | 33.06 ms | 15.2% vs 14.9% | 1.21 vs 1.19 cores |
|
|
293
|
+
|
|
294
|
+
> **CPU Metric Definitions:**
|
|
295
|
+
> - **Host Normalized CPU %**: Percentage of entire multi-core host compute bandwidth consumed ($\frac{\Delta \text{CPU}_{\mu s}}{\text{Duration}_s \times 10^6 \times N_{\text{cores}}} \times 100\%$).
|
|
296
|
+
> - **Cores Utilized**: Total saturated CPU cores consumed by the V8 runtime / libuv thread pool ($\frac{\Delta \text{CPU}_{\mu s}}{\text{Duration}_s \times 10^6}$, where 1.0 = 1 full CPU core).
|
|
297
|
+
|
|
298
|
+
JSON and CSV benchmark artifacts are automatically recorded in `results/`, `final-results/`, and `research-results/`.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 🖥️ Interactive Admin Dashboard
|
|
303
|
+
|
|
304
|
+
Access the real-time security dashboard at `/iri-shield`:
|
|
305
|
+
|
|
306
|
+
- **Overview Panel**: Live requests, mitigated threats, latency gauges, threat distribution donut charts, and top endpoint statistics.
|
|
307
|
+
- **Alerts ⚡**: Active suspicious client queue with one-click **Block IP** and **Dismiss** actions.
|
|
308
|
+
- **Security Events**: Filterable by risk level (`critical`, `high`, `medium`, `low`) with expandable **Risk Breakdown Tables**, **Confidence Badges**, and **Correlation Banners**.
|
|
309
|
+
- **Client Identity**: Identity continuity records, platform breakdown, IP rotation count, and anomaly histories.
|
|
310
|
+
- **Blocked IPs**: Full persistent blocklist management with instant **Unblock** and manual block creation modal.
|
|
311
|
+
- **Settings**: Live security mode switcher (`low`, `medium`, `high`), Security Rule Engine checkboxes, Privacy controls, and Redaction field managers.
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## ⚙️ Full Configuration Reference
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
const shield = createShield({
|
|
319
|
+
appName: 'iri-shield',
|
|
320
|
+
security: 'medium', // 'low' | 'medium' | 'high'
|
|
321
|
+
trustProxy: false,
|
|
322
|
+
failureMode: 'fail-open', // 'fail-open' | 'fail-closed'
|
|
323
|
+
|
|
324
|
+
// HTTP Security Headers & CORS
|
|
325
|
+
helmet: {
|
|
326
|
+
enabled: true,
|
|
327
|
+
contentSecurityPolicy: false,
|
|
328
|
+
crossOriginEmbedderPolicy: false
|
|
329
|
+
},
|
|
330
|
+
cors: false,
|
|
331
|
+
logger: true,
|
|
332
|
+
|
|
333
|
+
// Rate Limiting
|
|
334
|
+
rateLimit: {
|
|
335
|
+
enabled: true,
|
|
336
|
+
windowMs: 60 * 1000, // 1 minute
|
|
337
|
+
max: 120 // Requests per window
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
// Automated IP Blocking
|
|
341
|
+
block: {
|
|
342
|
+
enabled: true,
|
|
343
|
+
threshold: 80, // Threat score (0-100) to trigger block
|
|
344
|
+
durationMs: 24 * 3600 * 1000 // Block duration (24 hours)
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
// Alert Queue
|
|
348
|
+
alert: {
|
|
349
|
+
enabled: true,
|
|
350
|
+
threshold: 35 // Score threshold for active alert queue
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
// Anomaly Thresholds
|
|
354
|
+
anomaly: {
|
|
355
|
+
mediumThreshold: 35,
|
|
356
|
+
highThreshold: 65,
|
|
357
|
+
criticalThreshold: 90,
|
|
358
|
+
singleEndpointMax: 80,
|
|
359
|
+
failedAuthMax: 5,
|
|
360
|
+
allowedMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
|
361
|
+
sensitiveEndpoints: ['/admin', '/internal', '/debug', '/.env', '/config']
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
// Security Rule Engine
|
|
365
|
+
rules: {
|
|
366
|
+
sqlInjection: true,
|
|
367
|
+
xss: true,
|
|
368
|
+
pathTraversal: true,
|
|
369
|
+
commandInjection: true,
|
|
370
|
+
ssti: true,
|
|
371
|
+
nosqlInjection: true,
|
|
372
|
+
secretProbe: true,
|
|
373
|
+
scannerDetection: true,
|
|
374
|
+
openRedirect: true,
|
|
375
|
+
headerAnomaly: true,
|
|
376
|
+
customRules: []
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
// PII & Secret Redaction
|
|
380
|
+
redaction: {
|
|
381
|
+
enabled: true,
|
|
382
|
+
mask: '[REDACTED]',
|
|
383
|
+
fields: [
|
|
384
|
+
'password', 'token', 'accessToken', 'refreshToken',
|
|
385
|
+
'authorization', 'apiKey', 'secret', 'ssn',
|
|
386
|
+
'aadhaar', 'email', 'phone', 'creditCard', 'cvv'
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
// Privacy Controls
|
|
391
|
+
privacy: {
|
|
392
|
+
hashIp: false,
|
|
393
|
+
retainRawIp: true,
|
|
394
|
+
retentionDays: 30
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
// Storage Engine
|
|
398
|
+
storage: {
|
|
399
|
+
mode: 'sqlite', // 'memory' | 'sqlite' | 'mongodb'
|
|
400
|
+
sqliteFile: './data/iri-shield.sqlite',
|
|
401
|
+
mongoUrl: 'mongodb://localhost:27017/iri-shield',
|
|
402
|
+
maxRequestRows: 50000,
|
|
403
|
+
maxEventRows: 10000
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
// Dashboard Options
|
|
407
|
+
dashboard: {
|
|
408
|
+
enabled: true,
|
|
409
|
+
path: '/iri-shield',
|
|
410
|
+
username: 'admin',
|
|
411
|
+
password: 'admin',
|
|
412
|
+
refreshMs: 300000 // 5 minutes
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 🛡️ Security & Auth Utilities
|
|
420
|
+
|
|
421
|
+
`iri-shield` ships with built-in cryptographic security utilities:
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
const {
|
|
425
|
+
apiKeyAuth,
|
|
426
|
+
signToken,
|
|
427
|
+
jwtAuth,
|
|
428
|
+
hashPassword,
|
|
429
|
+
comparePassword
|
|
430
|
+
} = require('iri-shield');
|
|
431
|
+
|
|
432
|
+
// API Key Guard
|
|
433
|
+
app.get('/api/v1/data', apiKeyAuth(['prod-key-1', 'prod-key-2']), handler);
|
|
434
|
+
|
|
435
|
+
// JWT Middleware
|
|
436
|
+
app.get('/api/v1/me', jwtAuth(process.env.JWT_SECRET), handler);
|
|
437
|
+
|
|
438
|
+
// Password Hashing
|
|
439
|
+
const hashed = await hashPassword('user-password', 12);
|
|
440
|
+
const isValid = await comparePassword('input-password', hashed);
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## 🎓 Academic & Research Defense
|
|
446
|
+
|
|
447
|
+
When presenting or publishing research using `iri-shield`:
|
|
448
|
+
|
|
449
|
+
> **Terminology Note**: `iri-shield` utilizes **Multi-Signal Client Profiling and Identity Continuity Analysis**. We do not claim absolute identity guarantee, but rather compute continuous probabilistic risk scores derived from observed identity signal drift across request lifetimes.
|
|
450
|
+
|
|
451
|
+
### Theoretical Foundation
|
|
452
|
+
- **Multi-Vector Threat Fusion**: Combining signature heuristics, behavioral statistical deviations, and sequential Markovian attack chains into a unified, explainable score vector.
|
|
453
|
+
- **Privacy-Preserving Telemetry**: Deterministic SHA-256 IP pseudonyms with strict temporal data lifecycle controls.
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
## 📄 License
|
|
458
|
+
|
|
459
|
+
ISC © [ansari-in](https://github.com/ansari-in)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 🔬 iri-shield Scientific Research Evaluation Suite
|
|
2
|
+
|
|
3
|
+
This comprehensive evaluation suite is designed for academic research, empirical evaluation, and **Thesis Chapter 5 (Results & Discussion)** analysis of `iri-shield`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Research Commands Matrix
|
|
8
|
+
|
|
9
|
+
| Command | Purpose | Primary Metric Evaluated | Output Artifacts |
|
|
10
|
+
| :--- | :--- | :--- | :--- |
|
|
11
|
+
| `npm run research:evaluate` | **Master Suite** (Executes all 5 experiments) | End-to-End Chapter 5 Report | `research-results/research_summary.md`, `experiments.csv` |
|
|
12
|
+
| `npm run benchmark` | Multi-Workload Matrix Performance Benchmark | Latency (Mean, p95, p99), Throughput, CPU & Memory | `results/performance.csv`, `comparison.json` |
|
|
13
|
+
| `npm run security:evaluate` | 220+ Structured Attack Scenarios | Category-wise Detection & Direct Blocking Rate | `results/security.csv`, `security.json` |
|
|
14
|
+
| `npm run fp:evaluate` | 10,000 Legitimate Requests | False Positive Rate (FPR = 0%) | `results/false_positives.csv`, `false_positives.json` |
|
|
15
|
+
| `npm run identity:evaluate` | 500 Identity Continuity & Drift Scenarios | Identity Profiling Accuracy & False Drift Rate | `results/identity.csv`, `identity.json` |
|
|
16
|
+
| `npm run redaction:evaluate` | 500 PII, Token & Secret Payloads | Redaction Accuracy (100%) & Over-masking (0%) | `results/redaction.csv`, `redaction.json` |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📁 Output Artifacts Directory Structure
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
research-results/
|
|
24
|
+
├── research_summary.md # Formatted Thesis Chapter 5 Tables & Analysis
|
|
25
|
+
├── experiments.csv # Master CSV of all 5 experimental dimensions
|
|
26
|
+
└── summary_report.json # Consolidated JSON telemetry
|
|
27
|
+
|
|
28
|
+
results/
|
|
29
|
+
├── performance.csv # Workload matrix throughput, latency percentiles, CPU, memory
|
|
30
|
+
├── security.csv # Category-wise detection rates (SQLi, XSS, SSTI, etc.)
|
|
31
|
+
├── false_positives.csv # False positive validation results
|
|
32
|
+
├── identity.csv # Identity continuity profiling results
|
|
33
|
+
├── redaction.csv # Sensitive data redaction metrics
|
|
34
|
+
└── comparison.json # Performance delta JSON
|
|
35
|
+
```
|