AI Security Auditor: Real-Time Threat Detection for OpenEdge Applications

At PUG Challenge Amsterdam 2026, in my session “AI Security Auditor: Real-Time Threat Detection for OpenEdge Applications”, I showed how an OpenEdge application can log its own activity, let two small machine-learning models judge it, and have a local language model explain every alert in plain words, without any data leaving the machine.

Picture a doctor’s account in a hospital prescription system. The password is right, the session is valid and every request is permitted. Then the same account reads the same prescription list 25 times in two and a half seconds. No access rule is broken and nothing throws an error, yet no doctor works that way.

OpenEdge has a native Auditing feature that records who changed what, and when. But that is a change log, not a behavioural system: it does not learn what normal looks like, and it does not alert anyone in real time. The gap is not missing logging. It is missing detection.

The AI Security Auditor covers that gap. It does not replace authentication or authorisation; it raises a hand when behaviour stops looking like a person at work, using only what an ordinary OpenEdge shop already has, with all data staying on the local machine.

 

 

THE TEST BED: WAYMED

 

WayMed is a small prescription assistant: a browser front end and three ABL web handlers (doctor, medicine, prescription) on a PAS for OpenEdge instance, with matching Doctor, Medicine and Prescription tables. Nothing was rebuilt. The auditor is additive: one added call per endpoint, plus a separate Python process.

 

 

THE PIPELINE:

 

ABL web handlers call LogEvent after each read or write, and each event is stored in a SecurityEvent table. A securityevents handler exposes it as JSON, and the Python auditor polls it every two seconds. There, two models judge every event (a classifier and a novelty detector), and only flagged events reach a local LLM (llama3.2:3b in Ollama) that explains them. Results go to a dashboard, an incidents.jsonl file and a compliance report. Everything runs on one machine, next to the database: no cloud service and no API key.

 

 

STEP ONE: LET THE APPLICATION LOG WHAT HAPPENS

 

Each handler calls one method, LogEvent, on a small singleton class SecurityEventLogger, right after it reads or writes data:

 

SecurityEventLogger:Instance:LogEvent(cSecSid, STRING(iDoctorId), cClientIp,
“RECORD_READ”, “Prescription”, STRING(iCount), “limit=” + STRING(iLimit)).

 

The arguments are the session ID, doctor ID, client address, event type (RECORD_READ or RECORD_WRITE), record type, record ID and a detail string. The logger adds a timestamp and a database sequence number and stores one row in SecurityEvent. A fourth handler, securityevents, exposes the table as JSON at /web/securityevents?since=N, which the Python side polls every two seconds.

The log lives in the database, not in memory, because PASOE runs several sessions in parallel with isolated memory, and the database is the one thing they all share. A write is logged in the same transaction as the write itself, and the row is stored with NO-ERROR, so a logging failure can never break a prescription.

 

 

STEP TWO: SIX NUMBERS PER SESSION

 

For each new event, the Python code condenses the last 30 seconds of that session’s activity into six numbers. Training and live scoring use the very same code, and timing comes from the timestamp ABL recorded, not from the moment Python happens to process the event.

– event_count: actions by the session in the last 30 s (3 on a page load; 5 at first flag, up to 45 in attacks)
– distinct_entities: record types touched, out of Doctor, Medicine, Prescription (3 on a page load; 1 when only prescriptions are read)
– distinct_actors: different doctor identities used in the session (1 normally; 20 when ids are cycled)
– distinct_records: different record values seen (1 to 3 normally; 1 when the same result is pulled again and again)
– write_ratio: share of actions that are writes (0.0 when browsing; 0.94 in the mass-write demo)
– seconds_since_last: seconds since the previous action, capped at 30 (1 to 5 s normally; 0.03 to 0.2 s in attacks)

 

 

STEP THREE: TWO MODELS, TWO JOBS

 

An event is flagged as soon as either of two models objects.

The first is a classifier: a Random Forest of 200 trees trained offline on 550 labelled snapshots, 238 normal and 312 from three simulated attacks, each run four times. The first events of each attack, which still look like a page load, are not labelled as attack. At run time it returns the probability of a known attack, and 0.7 or above is flagged. It is confident about shapes it has seen, and blind to the rest.

What it relies on, by importance: event_count 46.0%, seconds_since_last 27.2%, distinct_actors 17.7%, write_ratio 4.7%, distinct_records 2.8%, distinct_entities 1.6%. The forest puts how many actions happened, and how fast they came, far above everything else. The write ratio, which describes a mass write, carries under 5% of the weight.

The second is a novelty detector: an Isolation Forest trained only on normal behaviour, 238 snapshots at the start. It has no idea what an attack looks like; it notices when a session looks unlike a normal doctor, so it can catch what nobody anticipated. The price is that it keeps learning from live traffic. Two rules limit that. Events the classifier flags are never added to its training data, so a known attack cannot teach it that attacks are normal. And freeze_model.py switches learning off for a demo or an incident. The first rule has a limit: in my live run the detector was not frozen, and the eleven events it flagged during mass_write were added to its baseline (275 to 286 snapshots).

 

 

STEP FOUR: EXPLAIN THE ALERT IN PLAIN LANGUAGE

 

A flag such as if=-0.020 clf=1.00 means little to a compliance officer. So the first anomaly in each session goes to a local model, llama3.2:3b in Ollama, with the six numbers and strict instructions: use only the numbers given, never invent a motive, stay under 55 words, end with a concrete review step. This came back for the volume attack:

“[Matches a known attack pattern, high confidence] A single doctor account (id 1) read the same Prescription record (Record type touched: Prescription) five times in the last 30 seconds. These actions were all read/lookup actions, with no changes made. Review this session’s access log to verify the doctor’s authorization for this repeated access.”

Three guard rails mattered more than the prompt. The bracketed line saying which detector fired is written by Python, so the model can never claim both agree when only one did. A small correction step restores the right record type if the model defaults to “prescription” out of habit. And a low temperature, because at default settings it embellished, once inventing “potentially altered records” when the data said zero writes.

Each incident goes into incidents.jsonl, a live dashboard and a compliance report with an executive summary from the same local model. The explanation is generated once, so what you saw live is what is on paper.

 

 

WHAT THE DEMOS SHOWED

 

The demo ran four scripted scenarios against the real API, bypassing the user interface the way an attacker would. The first three are in the classifier’s training data. The fourth deliberately is not.

– volume (25 prescription reads in about 2.5 seconds): first flagged on the 5th read, classifier 1.00, 0.17 s after the previous one. Caught by the classifier; the novelty detector joined at the 10th.
– identity (one session cycles through 20 doctor ids): first flagged on the 1st request (novelty score -0.046), then on the 5th, with five doctor ids seen (classifier 0.99). Novelty detector first, then both.
– burst (45 requests across all three endpoints, no pauses): first flagged on the 5th request, classifier 0.99, 0.05 s after the previous one. Caught by the classifier.
– mass_write (15 prescriptions written in quick succession): first flagged on the 5th write, write ratio 0.83, novelty score -0.073. Caught by the novelty detector alone; the classifier stayed between 0.17 and 0.24.

Apart from identity, every attack began as ordinary traffic: in the volume run the classifier climbed from 0.08 to 0.45 and 0.57 before crossing 0.7 on the fifth read, less than a second into the attack. identity was caught by two models: the novelty detector objected to the very first request, a lone read with nothing before it, and the classifier agreed once five doctor ids had appeared. mass_write justifies the design: the classifier never saw it coming, while the novelty detector flagged every write from the fifth.

 

 

WHERE IT WENT WRONG, AND WHAT I DID ABOUT IT

 

The most useful part of the project was the false alarms and the wrong sentences. Two were fixed while building:

 

– The page refresh that looked like an attack. Opening WayMed fires three requests at once, but my first training data sent them one after another, so every refresh looked like the burst attack. The simulator now behaves like the real front end.
– Legitimate behaviour the model had never seen. Doctors glance at colleagues’ queues and take their time before saving a prescription. Adding sessions that switch doctors, and writes that come quickly or after 20 to 40 seconds, removed most of those alerts.

Two problems were still there at the demo. One ordinary session was flagged: a session reading three doctors’ queues 1.8 seconds apart was flagged by the novelty detector alone (classifier 13%), a borderline case that only a person can settle. And two explanations did not match the numbers: the burst one says the doctor read “the same Medicine record 5 times” though the session touched all three record types, and the mass_write one says “read” when 83% of the actions were writes. The detection and the bracketed first line were right; the 3-billion-parameter model’s sentence was not. That is why every explanation ends with a review step, and why I would never let one trigger an automatic action.

The attacks are simulated by me, and I did not test slow ones: an attacker who spaces requests out would probably have to be caught by the novelty detector alone.

 

 

WHAT IT COSTS TO RUN

 

benchmark_overhead.py measured each step over 2,000 iterations on my own machine, so the numbers will differ on other hardware.

– Compute the six numbers: 0.10 ms per event (95th percentile 0.12 ms)
– Novelty detector: 6.77 ms (7.38 ms)
– Classifier: 5.51 ms (5.96 ms)
– All three together: 12.39 ms (13.32 ms)

At 12.4 ms per event, one thread scores about 80 events a second. The two model files take about 1.5 MB. The only slow step is the explanation, 7.1 seconds per call, at most once per session.

 

 

FINAL THOUGHTS: FLAG, EXPLAIN, REVIEW

 

The auditor does not decide who is guilty. It turns a silent stream of valid requests into a short list of sessions worth a person’s attention, each with a sentence that says why. In the live run that list held five sessions: four scripted attacks and one false alarm. An alert is a question for a person, not a verdict. A useful audit trail starts inside the application itself.

Flag, explain, review.

 

 


 

Author: Carla Spaczai, Developer

Curious and driven, Carla grew from intern to full-time developer through dedication and a genuine love of learning. She’s passionate about making technology more intuitive and human, and when she’s not coding, she’s usually exploring a new idea or skill to master.

SEE HOW WE WORK.

FOLLOW US