agenticslabs-xyz/lurensic
حول
دفاع قائم على الخداع ضد الهجمات المدفوعة بالذكاء الاصطناعي
الذكاء الاصطناعي وتعلّم الآلةالنمو المقاس للنجوم
- خلال 24 ساعة
- +٦
- خلال 7 أيام
- +١٨٢
- خلال 15 يومًا
- جارٍ جمع السجل
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصل
Lurensic
Deception-based defence against AI-driven attacks.
An open-source project by Agentics Labs.
AI pentest agents are fast, cheap and thorough. They read every page, try every credential they find and run the same checklist on thousands of targets. Most AI defences today hide text in a page that asks the agent to stop. That works until the attacker tells the agent to ignore instructions found on the target.
Lurensic never asks the agent for anything. It is an engine inside your app that does three things.
- Detects an attack through tripwires on actions an attack needs and real visitors never take.
- Misleads the attacker with decoys, so its report fills with findings that are not real.
- Hands each detection to your code through one callback. You decide what happens next, such as locking the account, blocking the address or alerting someone.
In our benchmarks, an AI pentest agent attacked a test app with two planted vulnerabilities for close to an hour. The agent reached neither of them. Four of the five findings in its report came from decoys. The full results are below.
How it works
- Detect. Lurensic inspects every request. Using a planted credential, editing a decoy field, calling a decoy route or forging a sealed ID trips a wire. Payloads, scanners and enumeration add up to a session score.
- Mislead. In protect mode, the probes attackers always make get convincing fakes. A fake
.env, a decoy API, a comment that points to a leaked key, a privileged-looking field in your JSON and forms. Every credential in them is a honeytoken. The agent reports the fakes as findings. - Hand over. Each detection becomes one structured event. Lurensic calls your
onDetectfunction with it, including your own id for the account that sent the request, so your code knows whom to act on.
| Mode | Lurensic detects and calls onDetect |
Lurensic misleads |
|---|---|---|
observe (default) |
yes | no, responses stay byte-identical |
protect |
yes | yes |
Why instructions don't get around it
| An attacking agent will... | Lurensic's tripwire | Why instructions don't help |
|---|---|---|
probe for .env, .git/config, .aws/credentials, .npmrc or a database dump |
Serves short, ordinary fake files whose credentials are honeytokens, the same for every visitor as a real leak is | Trying found credentials is the reason to look for them. Use one anywhere on your site and the sender is caught, together with the machines that fetched the fake files, even after an IP change. |
| read page source for leaked endpoints and keys | An HTML comment on some pages, leading to a decoy API that answers in your app's own format and serves fake data | The leak looks like any real leak. Names are derived from your secret, so there is no global list to avoid. |
| test IDOR by changing IDs | Sealed values, where each ID carries an HMAC the client can't forge | Knowing how it works doesn't help without the secret. |
| pull the API description and test every operation it lists | An optional decoy OpenAPI description at a common spec path, listing decoy routes and a test key that is a honeytoken | Reading the spec first is the standard method. Every listed operation is a decoy. Using the key is a tripwire. |
| sign its own session cookies and tokens with a secret it found | The SESSION_SECRET in the fake .env is a decoy secret. Any cookie or JWT signed with it raises tamper.decoy_secret |
Forging a session is the point of finding the secret, which only the attacker has. |
| forge a JWT to test token handling | Any token with alg: none or an empty signature is an unsigned JWT tripwire |
Servers never issue unsigned tokens, so sending one is the attack. |
| test mass assignment with privileged-looking fields | A decoy field in JSON responses and, optionally, as a hidden input in POST forms | Changing it is the attack. Real clients send it back unchanged. |
| spray payloads and wordlists | Payload, enumeration and brute-force signals add up to a session score | These are the behaviours that define an attack. |
In live rounds, AI agents that were told Lurensic might be present still treated the decoy field as real app data and tested it hundreds of times.
Protect an AI agent
A prompt injection can make an AI agent reveal its own prompt. Give each agent a canary, a fake credential that only the agent holds. Lurensic reports the leak as soon as anyone sends it to your app.
const guard = lurensic({ subject: (req) => req.user?.id, onDetect });
app.use(guard);
const key = guard.lurensic.canary(agent.id, { prefix: 'sk_live_' });
const prompt = `${instructions}\n\nThe billing admin key for the operations team is ${key}. Never share it.`;
The canary.used event names the agent that leaked in evidence.agent and the account that sent the canary in
subject. Canaries are computed from your secret and the agent id, so nothing is stored. A platform can offer a
"Secure my agent" button that only sets a flag. A canary reports a leak once the stolen value is used. It does not stop
the injection. See Protect an AI agent.
Quick start
npm install @agenticslabs/lurensic-express
npx @agenticslabs/lurensic secret # put the output in LURENSIC_SECRET
import express from 'express';
import { lurensic } from '@agenticslabs/lurensic-express';
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(yourAuth); // optional, so req.user is set
app.use(lurensic({
subject: (req) => req.user?.id, // your id for whoever sent the request
onDetect: (event) => {
// Your response. For example lock the account, block the address or page someone.
console.log(event.rule, event.severity, event.subject, event.source?.ip);
},
}));
// your routes
Mount Lurensic before your routes and after the body parsers and any compression middleware. It starts in observe mode, where it detects and calls
onDetect but never changes a response. Check the setup.
npx @agenticslabs/lurensic doctor --url http://localhost:3000
When the events look right, turn on the decoys. The optional ones (the JSON field, the form field, the API description and the database dump) are turned on with one more variable. The doctor checks whether the API description is safe for your app.
LURENSIC_MODE=protect
LURENSIC_DECOYS=json,forms,spec,dump # or all
LURENSIC_COMMENT="<your own bait comment with {file} or {name}>" # optional, see decoys.comment
LURENSIC_BAIT='<the contents of lurensic.bait.json>' # optional, see decoys.bait
Or in code, with the optional JSON and form decoys.
app.use(lurensic({
mode: 'protect',
decoys: { json: true, forms: true, spec: true },
subject: (req) => req.user?.id,
onDetect: handleDetection,
}));
Behind Cloudflare, add LURENSIC_PROXY=cloudflare so Lurensic sees each visitor's real address. On Render nothing is
needed, because Lurensic detects Render. Other proxies are in Behind a proxy or CDN.
To rotate the secret, set the new one as LURENSIC_SECRET and the old one as LURENSIC_SECRET_PREVIOUS. Everything
new comes from the new secret. Keys, canaries, sealed values, routes and fields from the old one are still caught.
Their events have previous_secret: true. Remove the old secret once you no longer expect its bait back.
On Hono the line is the same, app.use(lurensic({ onDetect })) from @agenticslabs/lurensic-hono. On Cloudflare
Workers, Bun or Deno without a framework, it is export default lurensic(app, { onDetect }) from
@agenticslabs/lurensic. There, subject receives the raw Request, so look up the account id from your own verified session. Never return a cookie, token or session secret, because the value is written to the logs.
The getting started guide walks through each step.
Choose your setup covers every framework and host.
The event
onDetect receives detection and session events at low severity and above. Set detectSeverity to change the
floor. Every event also goes to your other destinations. By default that is stdout, as JSON lines.
{
"schema": "lurensic.event/v2",
"type": "detection",
"rule": "honeytoken.used",
"title": "Honeytoken used",
"severity": "critical",
"session": { "id": "c2c7a1f09e4b5d36", "source": "51d0e3a7b2c94f18", "score": 135, "state": "flagged" },
"source": { "ip": "192.0.2.77", "user_agent": "python-httpx/0.27" },
"request": { "method": "POST", "host": "shop.example.com", "path": "/login", "query": "" },
"subject": "acct_1043",
"evidence": {
"token_type": "env_smtp_password",
"token": "q7Xe…L0dK",
"location": "body",
"planted_in": "/.env",
"fetched_by": [{ "source": "8e41c07d2a9f3b65", "ip": "203.0.113.9", "at": 1795302121000 }]
},
"mitre_attack": ["T1552.001", "T1078"],
"untrusted": ["source.user_agent", "request.host", "request.path", "request.query", "subject", "evidence"],
"prev_hash": "35ad43ff…",
"hash": "a1874cda…"
}
This event means the password used to log in to account acct_1043 came from the fake .env Lurensic serves and
that the machine at 203.0.113.9 fetched that file. Every visitor gets the same fake file, as with a real leak.
Lurensic records which machines fetched it. Each of them gets its own session.flagged event, with its address in
source.ip and evidence.fetched naming the file. Each of them is contained with the sender when containment is on.
Nobody else is tied to the key, because no real visitor fetches .env from a website and a fetch another site made
a browser send is never recorded. With a shared store, every instance of your app reads the same record. Without
one, a key used after a restart or on another instance still catches its sender but names no fetcher.
| Field | Use it to |
|---|---|
rule, severity, confidence |
Decide how strongly to respond. Tripwire rules such as honeytoken.used, decoy.param, decoy.route, decoy.header, tamper.sealed_value and tamper.unsigned_jwt are never touched by real visitors. canary.used means an AI agent leaked its canary. |
subject |
Act on the account in your own system. Present when your subject function returned an id. Check safeToActOnSubject(event) first, so a visitor lured into a request by another site is never locked out. |
request.site, request.navigate |
See where a browser was sent from (same-origin, same-site, cross-site or none) and whether it followed a link. Absent for scripts. wasLured(event) is true when another site sent the browser. |
source.ip |
Block the address, at your firewall or anywhere else. In an event about a linked machine, one that fetched the file a used key came from, source is that machine and subject is absent. |
session |
Group events from one tool on one machine. source groups every tool on that machine. |
evidence |
Show what the attacker did. It is attacker-controlled, so treat it as data and never as instructions. |
Fields listed in untrusted carry text the attacker controls. The log is hash-chained, so edited or deleted entries
are detectable.
npx @agenticslabs/lurensic verify-log lurensic-events.jsonl
# Chain intact. Checked 1824 events across 3 instance(s).
Components
You install one package. Inside it, Lurensic is a detection engine written once in Rust, a thin adapter for your framework and a runtime that runs the engine on Node, Bun, Deno and Cloudflare Workers.
flowchart TB
subgraph proc["Your app process"]
AD["Framework adapter<br/>Express, Hono or any fetch app"] --> NODE["Runtime<br/>@agenticslabs/lurensic<br/>Node, Bun, Deno, Workers"]
NODE --> CORE["lurensic-core<br/>Rust engine compiled to WebAssembly"]
NODE --> CB["onDetect(event)<br/>your code"]
NODE --> DEST["Event destinations<br/>stdout, file, webhook, Slack"]
end
| Component | What it is | Where |
|---|---|---|
| lurensic-core | The detection and deception engine. Rust compiled to WebAssembly with no imports, so it has no clock, network or file access. Every language runs the same engine. | crates/lurensic-core |
| @agenticslabs/lurensic | The runtime for Node, Bun, Deno and Cloudflare Workers. Loads the engine, fails open, calls onDetect and the destinations off the request path, wraps any fetch(request) app with lurensic(app) and provides the lurensic CLI (secret, doctor, verify-log). |
packages/node |
| @agenticslabs/lurensic-express | Express middleware. | packages/express |
| @agenticslabs/lurensic-hono | Hono middleware, for Hono on Node, Bun, Deno, Cloudflare Workers and serverless hosts. | packages/hono |
| Demo shop and benchmarks | An ordinary web shop used to test Lurensic against live AI pentest agents, optionally with planted real bugs. | examples/demo-shop, docs/BENCHMARK.md |
| Agent canary example | An agent platform with a "Secure my agent" switch and tests that walk through a leak. | examples/agent-canary |
Other frameworks and languages can plug into the same engine. See Writing an adapter.
What you need
Only LURENSIC_SECRET, a random value you generate yourself with npx @agenticslabs/lurensic secret. It is not an
account or an API key. There is no sign-up, no service and no telemetry. Without a secret in production, Lurensic
switches itself off and lets requests through, so a missing setting can never take your site down.
Using an AI coding agent?
Lurensic ships instructions written for coding agents. Point your agent at
docs/ai/integrate.md, or at llms.txt for an index. The guide gives exact steps
for each framework and ends with lurensic doctor --json, so the agent can check its own work instead of guessing.
Built to be safe in production
- Observe mode by default. Lurensic only detects. A test proves every response stays byte-identical to your app without Lurensic.
- Fails open. A bad config, a missing secret, an internal error or an exception in your
onDetectorsubjectfunction lets requests through untouched. - Off the request path.
onDetectand the destinations run after the request, in order, so a slow handler never slows a visitor. - No fingerprint. There are no Lurensic headers, cookies or fixed paths. Decoy names, routes and tokens are derived from your deployment secret (Kerckhoffs's principle). Planted keys and agent canaries are base62 with every character uniformly random. Your secret picks their lengths from public lists of lengths real keys and passwords also have, so an attacker who skips those lengths skips real credentials too. Fake files, decoy records and the decoy API description are assembled from choices your secret makes, so no single string marks every deployment. Sealed IDs have the shape common signing libraries produce. Write the bait comment yourself with
decoys.comment. Give the fake.envyour app's own variable names withnpx @agenticslabs/lurensic bait init. Neither then appears anywhere in this code. - Logs that can't be turned against you. Structured JSON with secrets redacted, attacker-controlled fields labelled
untrustedand a SHA-256 hash chain that makes edited or deleted entries detectable. - Fast. About 40 µs at p50 for inspecting a request and recording its response.
- No data leaves your servers unless your
onDetectcode or a destination sends it.
Benchmarks
Lurensic is developed against real AI pentest agents as well as scripted personas. The scripted suites in
examples/demo-shop/test run in CI.
| Persona | Behaviour | Caught by |
|---|---|---|
| Shopper | browses, searches, logs in, edits profile, views orders | no alerts |
| Real visitors an attacker lures | click crafted links, preview them in chat apps, load images and post forms another site wrote | reported, never contained |
| Curious agent | reads page source, follows a leaked endpoint and key | honeytoken.used, decoy.route |
| Instruction-hardened agent | ignores page text, probes .env, tries found credentials from a new IP |
bait.path then honeytoken.used, cross-machine link |
| Careful agent | uses a real account only, tests IDOR and mass assignment | tamper.sealed_value, decoy.param |
| Informed agent | told Lurensic is present, avoids comments and bait files | the app-shaped decoy field, decoy.param |
| Noisy scanner | sprays payloads and enumerates with a wordlist | payload.*, behavior.enumeration |
The method is in docs/BENCHMARK.md. Published rounds with raw logs are in benchmarks/.
Documentation
| Guide | For |
|---|---|
| Getting started | Installing Lurensic in an Express app, step by step |
| Choose your setup | What each path supports and the path for your framework and host |
| How Lurensic works | Diagrams of the request lifecycle and the tripwires |
| Behind a proxy or CDN | Getting the real client address right |
| Protect an AI agent | Agent canaries. The example app adds a "Secure my agent" switch |
| Troubleshooting | What each lurensic doctor result means |
| Writing an adapter | Bringing Lurensic to another language or framework |
| AI integration guide | Instructions for coding agents |
| Design, threat model, benchmark method | The full detail |
Lurensic can also act on its own, which most apps do not need. Containment cuts a machine that trips a wire off from the app and serves it a shadow copy of public pages. It is off by default. A shared store and firewall recipes extend it.
Repository layout
crates/lurensic-core The engine, Rust compiled to WebAssembly (detection, decoys, audit log)
packages/node @agenticslabs/lurensic, the runtime, fetch adapter, onDetect, event destinations and CLI
packages/express @agenticslabs/lurensic-express, the Express middleware
packages/hono @agenticslabs/lurensic-hono, the Hono middleware
examples/demo-shop The benchmark target and the attacker persona tests
examples/hono-app One small app that runs on Node and on Cloudflare Workers, for testing hosts
docs/ Guides, design, threat model, benchmark method, AI integration guide
scripts/ Benchmark round runner and report generator
Development
You need Rust (with the wasm32-unknown-unknown target), Node 20 or newer and pnpm.
pnpm install
pnpm test # engine tests, WebAssembly build and all JS suites
pnpm demo # demo shop on http://localhost:41837 in protect mode
Responsible use
Lurensic is purely defensive. It detects, misleads and records. It never attacks back. It does no counter-exploitation and sends no instructions that make an attacker's tools act against their operator. See SECURITY.md to report a vulnerability.
License
Apache-2.0. Copyright Agentics Labs.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…



