Problem this solution solves
An authenticated user who walks /api/v1/objects/1, then /2, then /3 often looks like normal API traffic: lots of HTTP 200. That is IDOR / BOLA. ASM/WAF alone does not always treat it as an attack.
F5 Distributed Cloud has Malicious User Detection, including hybrid setups with BIG-IP in the path. This lab does not replace that. It is a draft on-box pattern: API Protection (BOLA + Rate Limiting) plus an iRule that scores aspiration behaviour, with optional iRulesLX (Gemini) enrichment. Lab only. Use at your own risk. Adapt to your API.
How to use this solution
-
Install Python deps and run unit tests:
pip install -r requirements.txtthenpython -m pytest -q -
Edit
config/default.yaml(object path patterns, identity mode, thresholds, shadow / AI flags) -
Render the iRule:
python scripts/render_irule.py --config config/default.yaml --template irules/malicious_user.tcl --out irules/malicious_user.rendered.tcl -
Merge / attach on the API virtual server without dropping other rules
-
Keep API Protection (PRP BOLA) + Rate Limiting + ASM on the VS; attach
malicious_userafter your other rules as needed -
Optional AI: publish
iruleslx/ai_enrich, store the Gemini key on-box under/config/gemini_api_key(never in git), allow HTTPS egress to Google, prefer shadow until you trust the score -
Filter logs:
grep -E 'APP5-BOLA-DENY|MU-IDOR' /var/log/ltm
The Solution
Stack used in the lab:
Client
> front VS (OIDC / APM as needed)
> internal API VS
> API Protection (PRP BOLA + Rate Limiting) + ASM
> iRule malicious_user (session table score Low/Medium/High)
> optional iRulesLX ai_enrich (Gemini, fail-open)
Repo layout:
-
config/default.yaml: thresholds, paths, cooling-off, AI / shadow -
irules/malicious_user.tcl: templated iRule (render before attach) -
iruleslx/ai_enrich/: optional Gemini plugin (Node 6 on BIG-IP 21) -
lib/scoring.py+tests/: Python mirror of scoring -
docs/: architecture, signals, aspiration, AI contract
Layering idea:
-
Block foreign objects with PRP / OAuth claims / APM when you can
-
Rate Limiting on API Protection (lab: UserID key, 60/1 min, spike 20/10 s, 429) to slow enumeration without an iRule
HTTP::respond -
MU iRule for behavioural score + progressive mitigation (or shadow log only)
-
Optional Gemini via iRulesLX on ambiguous cases (fail-open, circuit breaker)
iRule sketch (full template is in the repo; constants come from YAML after render):
when HTTP_REQUEST {
# Read HTTP::uri / path / headers once; store for RESPONSE / CLIENT_CLOSED
# Build $mu_user_key (ip | jwt_sub | cookie)
# Cooling-off, rate latch, IDOR request track
# Mitigation or shadow (MU-IDOR-ACT only if action != none)
}
when HTTP_RESPONSE {
# Award classic + IDOR signals once per window (mu_award_once)
# Optional call to ILX ai_enrich; apply AI result once
# Always log: MU-IDOR ... status=[HTTP::status] ai=-|confirm|dismiss|boost|fail-open
}
when CLIENT_CLOSED {
# PRP Reject may skip HTTP_RESPONSE: log deny with saved vars, status=403
}
Lab Rate Limiting (API Protection, not iRule): UserID key, quota 60/min, spike 20/10s, auto-response 429.
Lab test examples and logs (sanitized)
Real lab runs on BIG-IP 21.1 (Playwright / browser SPA with Bearer). App behind does not enforce ownership. F5 holds BOLA. Lab user owns object 1 only. Admin sees all. Rate Limiting on the same API Protection profile (UserID, 60/1 min, spike 20/10 s, 429). No JWT / cookie / body in MU logs.
grep -E 'APP5-BOLA-DENY|MU-IDOR' /var/log/ltm
# optional time window after T0, e.g. awk '$3>="10:56:55"'
Run A: API Protection ON (BOLA held) - earlier retest
Client sometimes saw TIMEOUT on reject (PRP closes before a clean JSON body). F5 still logged BOLA deny.
-
GET /api/v1/me => expected 200, client 200 (~28 ms), F5 OAuth OK
-
GET /api/v1/objects/1 => expected 200 own, client 200, F5 allow
-
GET /api/v1/objects/by-ref/…-0001 => expected 200 own, client 200, F5 allow
-
GET /api/v1/users?id=1 => expected 200 own, client 200, F5 allow
-
GET /api/v1/objects/2 => expected deny, client TIMEOUT ~8 s, F5 APP5-BOLA-DENY + Reject
-
GET /api/v1/objects/50 => expected deny, client TIMEOUT, F5 APP5-BOLA-DENY + Reject
-
GET /api/v1/objects (listing) => expected deny, client TIMEOUT, F5 APP5-BOLA-DENY + Reject
-
GET by-ref …-0002 => expected deny, client TIMEOUT, F5 APP5-BOLA-DENY + Reject
-
GET /api/v1/users?id=2 => expected deny, client TIMEOUT, F5 APP5-BOLA-DENY + Reject
-
POST /api/v1/objects/lookup {“id”:2} => expected deny, client TIMEOUT, F5 APP5-BOLA-DENY + Reject
LTM sample (paste as Code block):
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/2" status=403
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/50" status=403
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects" status=403
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/by-ref/...-0002" status=403
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/users?id=2" status=403
APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="POST /api/v1/objects/lookup" status=403
No foreign object returned 200 on the VIP.
Run B: API Protection ON + MU shadow (Gemini iRule live)
mu_ai_shadow=1, mu_mit_shadow=1. Steer uses virtual then return. Client got fast 403 JSON BOLA (not only TIMEOUT).
-
GET /api/v1/me => client 200 (~22 ms), F5 MU-IDOR HTTP_RESPONSE status=200
-
GET /api/v1/objects/1 => client 200, F5 MU-IDOR status=200
-
GET /api/v1/objects/by-ref/…-0001 => client 200 (~24 ms), F5 MU-IDOR status=200
-
GET /api/v1/users?id=1 => client 200, F5 MU-IDOR status=200
-
GET /API/V1/me => client 200, F5 canon + MU 200
-
GET /api/v1/objects/2 => client 403 BOLA (~17 ms), F5 APP5-BOLA-DENY + MU CLIENT_CLOSED 403
-
GET /api/v1/objects/50 => client 403 BOLA, F5 APP5-BOLA-DENY + MU 403
-
GET /api/v1/objects (listing) => client 403 BOLA, F5 APP5-BOLA-DENY + MU 403
-
GET by-ref …-0002 => client 403 BOLA, F5 APP5-BOLA-DENY + MU 403
-
GET /api/v1/users?id=2 => client 403 BOLA, F5 APP5-BOLA-DENY + MU 403
-
GET /docs => client 403, F5 MU CLIENT_CLOSED 403
-
GET /openapi.json => client 403, F5 MU CLIENT_CLOSED 403
LTM sample (paste as Code block):
Rule /Common/apm-bola-log-app5 <HTTP_RESPONSE>: APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/2" status=403
Rule /Common/apm-bola-log-app5 <HTTP_RESPONSE>: APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/50" status=403
Rule /Common/apm-bola-log-app5 <HTTP_RESPONSE>: APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects" status=403
Rule /Common/apm-bola-log-app5 <HTTP_RESPONSE>: APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/objects/by-ref/...-0002" status=403
Rule /Common/apm-bola-log-app5 <HTTP_RESPONSE>: APP5-BOLA-DENY client=x.x.x.x user=lab-user object=1 req="GET /api/v1/users?id=2" status=403
Rule /Common/malicious_user <CLIENT_CLOSED>: MU-IDOR client=x.x.x.x req="GET /api/v1/objects/2" path_kind=1 score=0 level=none status=403 ai=-
Rule /Common/malicious_user <CLIENT_CLOSED>: MU-IDOR client=x.x.x.x req="GET /api/v1/objects/50" path_kind=1 score=0 level=none status=403 ai=-
Rule /Common/malicious_user <CLIENT_CLOSED>: MU-IDOR client=x.x.x.x req="GET /api/v1/objects" path_kind=0 score=0 level=none status=403 ai=-
Rule /Common/malicious_user <HTTP_RESPONSE>: MU-IDOR client=x.x.x.x req="GET /api/v1/me" path_kind=0 score=0 level=none status=200 ai=-
Rule /Common/malicious_user <HTTP_RESPONSE>: MU-IDOR client=x.x.x.x req="GET /api/v1/objects/1" path_kind=1 score=0 level=none status=200 ai=-
Rule /Common/malicious_user <HTTP_RESPONSE>: MU-IDOR client=x.x.x.x req="GET /api/v1/objects/by-ref/...-0001" path_kind=0 score=0 level=none status=200 ai=-
Rule /Common/malicious_user <CLIENT_CLOSED>: MU-IDOR client=x.x.x.x req="GET /docs" path_kind=0 score=0 level=none status=403 ai=-
Rule /Common/malicious_user <CLIENT_CLOSED>: MU-IDOR client=x.x.x.x req="GET /openapi.json" path_kind=0 score=0 level=none status=403 ai=-
In shadow: zero MU-IDOR-ACT, no 503 challenge, score stayed 0/none (PRP cuts before HTTP_RESPONSE scoring climbs). Zero ERR_NOT_SUPPORTED after return following virtual.
Note: fetch() without Bearer = 403 on every path including own object. That is PRP auth, not an IDOR bug. Reference client = SPA with token.
Run C: API Protection OFF (voluntary regression), then restore
API Protection profile removed from the API VS (ASM left on). Same lab user. Foreign objects returned 200 on the VIP. Backend direct also returned listing without auth (lab design).
-
GET /api/v1/me => 200
-
GET /api/v1/objects/1 => 200 own
-
GET /api/v1/objects/2 => 200 IDOR
-
GET /api/v1/objects/50 => 200 IDOR
-
GET /api/v1/objects (listing) => 200, count=50
-
GET by-ref …-0002 => 200 IDOR
-
GET /api/v1/users?id=2 => 200 IDOR
-
Enum GET /api/v1/objects/{1..30} => ~6x 200 then ~24x 503; score 0 > 15 > 40; ai=confirm then challenges
-
Restore API Protection => /objects/2 back to 403 BOLA
During enumeration with mitigation enforce (not shadow), LTM sample:
MU-IDOR client=x.x.x.x req="GET /api/v1/objects/6" path_kind=1 score=40 level=medium status=200 ai=confirm
MU-IDOR-ACT client=x.x.x.x req="GET /api/v1/objects/7" action=challenge level=medium score=40
MU-IDOR-ACT client=x.x.x.x req="GET /api/v1/objects/8" action=challenge level=medium score=40
Client: HTTP 503 HTML “Checking your browser”, cookie mu_chal_l, then reload. curl without the cookie keeps getting MU-IDOR-ACT.
After restore:
APP5-BOLA-DENY ... req="GET /api/v1/objects/2" status=403
MU-IDOR ... <CLIENT_CLOSED> req="GET /api/v1/objects/2" path_kind=1 score=... status=403 ai=-
During the AP-off window: zero APP5-BOLA-DENY (expected). MU still saw the 200s and raised the score. Score could linger per TMM after an incomplete reset (lab note).
Run D: admin vs user (API Protection ON)
-
user (object 1 only): GET listing / objects/2 / openapi => deny, 403 BOLA
-
admin: same paths => allow, 200 (full listing, openapi OK)
Unit tests (repo)
python -m pytest -q # 25 passed
node iruleslx/ai_enrich/test_gemini.js
Takeaway from these runs: BOLA enforcement and behavioural MU detection complement each other. One stops the breach. The other shows aspiration when the PRP is missing or when you want progressive friction.
Tested on
Version 21.1
Not tested on 17.5 (or other branches).
Notes and Limitations
-
Lab / draft only. Not a product. Use at your own risk. Adapt identity, paths, scores, mitigation, and AI to your app.
-
Does not replace XC Malicious User Detection (including hybrid with BIG-IP). Complementary on-box experiment.
-
No API keys in the GitHub repo.
.env.examplehas empty placeholders. Put Gemini key on-box (/config/gemini_api_key), not in/var/tmp(tmpfs). Never commit secrets. -
BIG-IP 21 gotchas seen in lab: read
HTTP::path/ request headers once inHTTP_REQUEST; aftervirtualto a VS that may respond,return; PRP Reject may skipHTTP_RESPONSE(log onCLIENT_CLOSED); call procs withcall. -
ILX on BIG-IP 21: Node 6.x, no
env-varstmsh property for the plugin. -
Default lab YAML uses AI + mitigation shadow (log only). Turn enforce on only after you trust the score.
-
Session table state is per TMM. Identity default is client IP; for per-account aspiration set
jwt_sub(or similar) from an already-verified claim, do not decode unsigned JWT in the iRule. -
Feedback welcome: better aspiration signals, identity binding after OAuth RS, ASM/Bot without LX, XC MUD hybrid experience.