Inspiration
I've spent 10+ years as a network security engineer working with Cisco ISE, Palo Alto and enterprise wireless. Every config review hits the same wall: AI could make it ten times faster, but a running config holds enable secrets, SNMP communities, VPN pre-shared keys, public IPs, and customer names, employees and circuit IDs hidden in interface descriptions. Pasting that into a cloud chatbot breaks most security policies. So engineers either skip the review or spend an hour sanitising by hand, and still miss things.
Hybrid inference fits this problem exactly. A small model on the device does the part that needs privacy. A large model in the cloud does the part that needs depth.
What it does
ConfigShield is a web app that audits Cisco IOS/IOS-XE/ASA, Palo Alto PAN-OS, Juniper Junos and Fortinet FortiOS configs in a five-stage pipeline:
- Rule-based redaction (local): 29 keyword-anchored rules plus hash, PEM/certificate, e-mail, phone and IPv4/IPv6 detectors. Tokens stay consistent (
<HOST_1>,<IP_PUB_2>), and netmasks and wildcards are kept so the audit still makes sense. Default or short secrets such aspublicorcisco123become<WEAKSECRET_n>, so the auditor can flag them without ever seeing them. - Contextual redaction with Gemini Nano (on-device only): finds what rules can't, like "Desk of Priya Raman – Treasury" or a site name buried in an interface description. Output is JSON-schema constrained, and a value is masked only if it appears verbatim in the config. If Nano is unavailable, a strict free-text scrub masks every non-generic description instead.
- Leak gate (local): re-runs every rule and checks every vault value. It fails closed: one surviving secret blocks the cloud call.
- Deep audit with Gemini (cloud-preferred, on-device fallback): management plane, AAA, SNMP, crypto, any/any rules, logging and NTP. Each finding has severity, evidence, why it matters, a vendor-specific CLI fix and a compliance reference.
- Cross-check and re-hydration (local): 32 deterministic baseline checks, mapped to NIST SP 800-53 and PCI DSS v4.0, mark AI findings rule-confirmed and add anything the AI missed. Every cited evidence line is verified against the config. The engineer can reveal real values from an in-memory vault, which the cloud and the database never see.
A privacy receipt states exactly how much sanitized text crossed to the cloud, or "Nothing left this device". Air-gapped mode runs the entire audit on Gemini Nano for sites where nothing may leave the machine. Even with no AI available at all, the baseline audit still produces a report.
How we built it
Firebase AI Logic (firebase/ai, GoogleAIBackend) with three hybrid model configurations, each with its own InferenceMode chosen for a reason:
| Model | Mode | Why |
|---|---|---|
| Redactor | ONLY_ON_DEVICE |
Raw config must never leave the device, so cloud fallback is deliberately disabled. A runtime check aborts if response.inferenceSource is ever not on_device |
| Auditor | PREFER_IN_CLOUD |
Best audit quality in the cloud, with automatic fallback to Gemini Nano when offline |
| Air-gapped auditor | ONLY_ON_DEVICE |
Fully local, with prompts chunked to fit Nano's 9,216-token window |
- One structured contract on both paths: the same JSON schema goes to
onDeviceParams.promptOptions.responseConstraintand toinCloudParams.generationConfig.responseJsonSchema. initializeDeviceModel()starts inside the click gesture (a Chrome requirement), with a download progress bar.response.inferenceSourcedrives the live ON-DEVICE / CLOUD badge on every stage.- App Check (reCAPTCHA Enterprise on the live site), Anonymous Auth (private history with no signup), Cloud Firestore (sanitized reports only, enforced by field allow-list security rules) and Remote Config (cloud model, Nano chunk size, findings cap, and a kill switch that forces on-device auditing), deployed on Firebase Hosting.
- Vite + strict TypeScript, no framework. 55 Vitest tests, including pipeline tests that mock the models and assert the cloud prompt contains none of the samples' passwords, IPs, people or circuit IDs. CI runs on GitHub Actions.
Challenges we ran into
- A fallback direction for each task. "Prefer on-device" is wrong for redaction: a silent cloud fallback would leak the very data we protect. Each stage needed its own
InferenceMode. - Gemini Nano corrupting placeholders. In a live run, Nano echoed fragments of existing tokens (like
SECRET_1) as "sensitive values". Re-masking them turned<SECRET_1>into<<OTHER_1>>. The leak gate correctly failed closed and blocked the upload. We now reject any candidate that only occurs inside an existing token, with regression tests. - Nano's context window. Configs run 50–200 KB, so we chunk on line boundaries and keep tokens consistent through one shared vault.
- Over-redaction vs. a useful audit. Masking too much destroys the audit. We keep masks, wildcards, encryption-type digits and syntax words, and tag IPs as private or public so exposure can still be judged.
- Trusting the model. LLM audits can invent evidence, so every cited line is checked and deterministic rules cross-check the findings.
Accomplishments that we're proud of
- The weak-secret signal: the cloud model reports "SNMP community is a vendor default" without ever seeing
public. - A leak gate that fails closed, and graceful degradation: cloud → on-device → rules-only, never a blank screen.
- Hallucination checks you can see: rule-confirmed and evidence verified badges on every finding.
- Firestore rules that make storing a raw config impossible, even from a modified client.
What we learned
On-device AI isn't only a cost or latency win. For regulated industries it is the thing that makes cloud AI usable at all. Choosing the inference mode per task, not per app, is the real design decision in hybrid AI.
What's next for ConfigShield
- A Chrome side-panel extension that audits configs straight from web consoles (Meraki, Panorama, vManage).
- Full CIS benchmark packs, selected through the existing
audit_policy_packRemote Config parameter. - Config diffing for change-request reviews.
- An Android companion for field engineers, with Gemini Nano via ML Kit.
Built With
- chrome-prompt-api
- cloud-firestore
- css3
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-hosting
- firebase-remote-config
- gemini
- gemini-nano
- github-actions
- html5
- typescript
- vite
- vitest