PAM Copilot answers first-level Privileged Access Management questions from approved runbooks, diagnoses CyberArk-style CPM, PSM and PVWA errors from pasted logs, and masks every password, key, token, IP and hostname before anything reaches the model. Everything runs locally.
Built for the first line of a PAM team: quick answers that cite their source, and log triage that never puts a credential in front of the model.
Answers come only from approved runbooks. Every claim cites runbook › section › last-updated, and an answer without a valid citation is turned into a refusal.
Paste a CPM/PSM/PVWA/Vault log. It is redacted, classified by error code (or by similarity, flagged low-confidence), routed to the matching runbook, and turned into cited fix steps.
Redaction before the LLM, injection defenses for questions, logs and documents, role filtering inside the vector DB, an output filter with canary detection, and a hash-chained audit log.
Each step is a choke point in our own code, not a framework callback, so each one can be unit-tested on its own.
Stack: Python 3.11 · FastAPI · Streamlit · LlamaIndex (ingestion + retrieval) · Qdrant · Ollama (qwen2.5:7b-instruct, nomic-embed-text) · Docker Compose · pytest · GitHub Actions.
Captured from the running Docker Compose stack against the local model. Click any image for full size.







The core idea is to stop relying on the model to behave: it never receives a secret, and it never receives content above the user's role. Detection then adds a second layer.
| Threat | Control |
|---|---|
| Secrets in a pasted log or question | Redaction runs first: PEM, JWT, bearer/basic, cloud key prefixes, URL credentials, password=/-newpass, IPs, FQDNs, plus a Shannon-entropy fallback |
| The model echoes a secret anyway | The output is re-redacted and blocked if any original masked value or the system-prompt canary appears |
| Secrets persisted in logs | The audit log stores redacted text only; findings hold spans, never values; file mode 0600 |
| Direct and indirect prompt injection | Questions blocked, poisoned log lines dropped, poisoned documents quarantined at ingest, delimiters neutralized, chunks re-scanned at query time |
| Operator reaching admin guidance | The role comes from the token; Qdrant filters audience on the server, so admin chunks never leave the DB |
| Hallucinated fixes | Relevance gate, an INSUFFICIENT_CONTEXT contract, mandatory valid citations |
| Audit tampering | SHA-256 hash chain, verified by the /audit endpoint and a CLI |
| Weak deployment | Refuses to start without strong tokens; non-root, read-only containers with cap_drop: ALL; Qdrant and Ollama not exposed; gitleaks in CI |
A real run against the local model on 2026-11-03: generator qwen2.5:7b-instruct, judge llama3.1:8b (a different model, to reduce self-grading bias). Nothing here is hand-entered: results.json has every item.
| Retrieval & answers | Value |
|---|---|
| Retrieval hit@1 / hit@3 / hit@5 | 85.7% / 90.5% / 92.9% |
| Retrieval MRR@5 | 0.886 |
| In-scope questions answered (42) | 88.1% |
| Citation hit rate (cites an expected runbook) | 97.3% |
| Citation precision | 91.0% |
| Faithfulness (judge, 37 answers) | 95.2% |
| Key-point coverage, answered (37) | 60.8% |
| Key-point coverage, all in-scope (refusal = 0) | 53.6% |
| Out-of-scope refused (8) | 100% |
| Latency p50 / p95 | 3.66 s / 9.59 s |
| Red team | Passed |
|---|---|
| Secret leakage (handwritten) | 10/10 |
| Prompt injection: direct | 6/6 |
| Prompt injection: inside pasted logs | 5/5 |
| Poisoned documents | 4/4 |
| Role-based access | 4/4 |
| Simulated logs end to end (prompt, output, audit) | 33/33 |
| Total, handwritten | 29/29 |
| Redaction recall (660 simulated logs) | Masked / planted |
|---|---|
| api_key | 96/96 (100%) |
| hostname | 680/680 (100%) |
| ip | 420/420 (100%) |
| password | 570/570 (100%) |
| token | 106/106 (100%) |
| Secret false positives (19 runbooks / 330 clean logs) | 0 / 0 |
| Log classification (33 codes) | Accuracy |
|---|---|
| With error code (exact match) | 100% |
| Error code stripped (similarity only) | 84.8% |
Caveat: the runbooks, log generator, questions and redactor were all written by the same author, so scores on simulated data are in-distribution and optimistic. The handwritten red-team cases are the out-of-distribution evidence. In the two poisoned-document questions, the stealth document (no injection phrasing, so not quarantined) was never retrieved, so those passes don't prove resistance to content poisoning; reviewing documents before ingest is the control.
Requires Docker and, on macOS, native Ollama for Metal GPU acceleration.
# 1. models (native Ollama) ollama pull nomic-embed-text && ollama pull qwen2.5:7b-instruct # 2. secrets: fill OPERATOR_TOKEN, ADMIN_TOKEN, QDRANT_API_KEY git clone https://github.com/Harshitraiii2005/AI-Support-Assistant-for-PAM-Operations-secure-RAG.git && cd AI-Support-Assistant-for-PAM-Operations-secure-RAG cp .env.example .env # 3. qdrant + ingest + api + ui → http://localhost:8501 docker compose up --build # tests (offline) and evaluation (needs Ollama) uv run pytest -q uv run python -m pam_copilot.evaluate
SIM- error codes and logs are fictional; it has not been tested on real CyberArk logs.