Fortinet FortiGate Scanner

Infrastructurev4.0.0

Live FortiOS REST API security scanner with 260+ rules, 30 MITRE ATT&CK resilience tests, 30 CVEs, 5 compliance frameworks, and multi-device fleet scanning

260+
rules
18
categories
30
cves
30
mitre

01Overview

The Fortinet FortiGate Security Scanner is a Python security-posture assessment tool that grades FortiGate next-gen firewalls against best-practice hardening, five compliance frameworks, real FortiOS CVEs, and MITRE ATT&CK resilience. It ships as two scanners that share the exact same rule engine: a live scanner that talks to the FortiOS REST API, and an offline scanner that parses an exported .conf backup with zero network access and zero third-party dependencies — purpose-built for OT, ICS, and air-gapped networks where you can't reach the firewall's management plane.

Under the hood it runs 260+ checks across 18 audit domains — admin access, firewall policy hygiene, SSL/IPsec VPN crypto, security profiles, logging, HA, certificates, network hardening, ZTNA/SD-WAN, wireless, backup/DR, and advanced FIPS-grade hardening. Beyond static config review, it does two things most config auditors don't: it matches the parsed firmware version against 66 known FortiOS CVEs (2019-2026, sourced from FortiGuard PSIRT) using train-based version logic across six release trains, and it runs 31 MITRE ATT&CK technique tests across 11 tactics to produce a 0-100% attacker-resilience score.

Every finding auto-resolves to CIS FortiGate, PCI-DSS 4.0, NIST 800-53 Rev 5, SOC 2, and HIPAA controls, and to a ready-to-paste FortiOS CLI remediation block — so the same scan feeds an auditor's evidence CSV and an engineer's fix script. It's a zero-agent, single-file design with a non-zero exit code on CRITICAL/HIGH for CI/CD gating and JSON inventory-driven fleet scanning across many firewalls at once.

It's built for firewall and network-security engineers, red/blue teams, OT/ICS security staff, and GRC auditors who need a repeatable, evidence-grade FortiGate review that works whether the box is online or locked behind an air gap.

02Key Capabilities

Dual live + offline scanning

One rule engine, two front doors: scan a live FortiGate over the REST API, or audit an exported .conf backup offline with no network and no pip install.

260+ checks across 18 domains

Eighteen dedicated check methods cover admin access, policy hygiene, VPN crypto, security profiles, logging, HA, certs, network hardening, wireless, ZTNA/SD-WAN, backup, and auth.

66 FortiOS CVE detection

Matches the parsed firmware against 66 FortiGuard PSIRT CVEs (2019-2026) using train-based version logic across six release trains, flagging known-exploited SSL VPN, fgfmd, and FortiJump bugs.

31-technique MITRE ATT&CK resilience

Tests 31 ATT&CK techniques across 11 tactics and emits a 0-100% resilience score showing how well the firewall's controls actually blunt real-world attacks.

Five-framework compliance mapping

Every finding auto-maps to CIS FortiGate, PCI-DSS 4.0, NIST 800-53 Rev 5, SOC 2, and HIPAA controls (76 rule-to-framework mappings) for instant audit evidence.

One-click remediation export

Exports 42 ready-to-paste FortiOS CLI config blocks tied to specific findings via --remediation, turning a scan into an actionable fix script.

Multi-device fleet scanning

Batch-scans an entire firewall fleet from a JSON inventory file and produces a unified summary and aggregated JSON report.

Air-gapped / OT mode

The offline scanner is stdlib-only so it runs on locked-down OT operator workstations, delivering the full 18-category audit from a config backup alone.

Six output formats

Console, JSON, dark-themed interactive HTML, compliance CSV, remediation script, and an ATT&CK resilience score cover engineers, auditors, and pipelines.

CI/CD-ready gating

Returns exit code 1 on any CRITICAL or HIGH finding so it drops straight into GitHub Actions or any pipeline as a security gate.

Zero-agent, read-only

Uses only a read-only FortiOS API token with no software installed on the target, keeping the assessment low-footprint and safe for production firewalls.

03Architecture

A single-file live engine (fortinet_scanner.py) holds all data (CVE list, compliance map, remediation commands) and logic (18 check methods, report mixin, multi-device orchestrator). A thin offline adapter (fortinet_offline_scanner.py) subclasses the engine and overrides only the data-access seam (_api_get), so a parsed .conf feeds the identical checks. Data flows Connect/Parse -> Collect -> Audit -> CVE match -> MITRE score -> Compliance resolve -> Report.

1
Data layer (FORTIOS_CVES / COMPLIANCE_MAP / REMEDIATION_COMMANDS)
Module-level structures: 66 CVE definitions with train/fixed versions, 76 rule-to-framework mappings, and 42 CLI remediation blocks, all keyed by rule ID.
2
Finding model
A __slots__-based class that on init auto-resolves each finding's compliance references and remediation command from the shared maps.
3
_ReportMixin
Rendering layer providing print_report, save_json, save_html (Catppuccin-Mocha dark theme), save_remediation, save_compliance_csv, summary, and severity filtering.
4
FortinetScanner engine
The core class (subclassing _ReportMixin) with 18 _check_* methods total — 16 configuration-domain audits plus _check_cves and _check_mitre_attack_resilience — driving 260+ possible findings.
5
_api_get data seam
The single swap point abstracting data retrieval — HTTP for live mode, a pre-parsed dict for offline mode — so every check runs unchanged across both.
6
Offline parser + adapter
FortiGateConfParser does recursive-descent parsing of config/edit/set/end blocks into API-shaped dicts, and OfflineFortinetScanner overrides _api_get to serve them.
7
MultiDeviceScanner
Fleet orchestrator that sequentially scans firewalls from a JSON inventory, aggregates results, prints a unified summary, and gates the exit code.
8
CLI (main)
argparse front end handling single-host and inventory modes, output flags, severity filtering, and CRITICAL/HIGH exit-code gating.

04Project Structure

fortinet_scanner.pyLive REST-API scanner and the shared rule engine (~5,587 lines): all 18 check methods, CVE/compliance/remediation data, report mixin, and multi-device scanner.
fortinet_offline_scanner.pyStdlib-only offline scanner (~506 lines): FortiGateConfParser plus OfflineFortinetScanner that reuses the live engine against a .conf backup.
README.mdFull documentation: capabilities table, architecture diagram, usage, CLI reference, MITRE and CVE breakdowns, CI/CD examples.
CLAUDE.mdEngineering guide: architecture internals, check-method table, compliance and MITRE mappings, offline-parser design, and dev conventions.
test_data/test_offline_parser.pyPytest suite (23 test functions) covering header parsing, section-to-API-path mapping, reference shaping, VDOM wrappers, malformed input, and an end-to-end smoke run.
test_data/sample_insecure.confIntentionally insecure mini-config that triggers ~115 findings across all 18 categories for smoke testing.
test_data/sample_74_outdated.confSample FortiOS 7.4 backup on an outdated build used to exercise CVE and version-train matching.
test_data/fortinet_report.jsonReference JSON report artifact produced by a scan run.
test_data/fortinet_report.htmlReference dark-themed HTML report artifact showing the interactive output.
banner.svgProject banner graphic used in the README header.
fortigate-scanner-medium-article.mdLong-form write-up / article about the scanner's design and use.
LICENSEMIT license.

05Security Controls

Admin & access hardening
24 admin checks (FORTIOS-ADMIN): HTTP admin exposure, idle timeout, password policy, MFA coverage, trusted hosts, API users, default admin — plus WAN management-interface exposure.
Firewall policy hygiene
16 policy checks flagging any/any/any rules, missing logging, absent security profiles, and weak egress filtering, backed by lateral-movement ATT&CK tests.
VPN cryptography
SSL VPN (14 checks: TLS version, ciphers, client cert, split tunneling, session limits) and IPsec VPN (12 checks: Phase 1/2 crypto, DH groups, DPD, PFS, key lifetime, IKE version).
Security profile enforcement
Verifies AV, IPS, WebFilter, Application Control, DLP, DNS filter, and SSL/SSH deep inspection are deployed on policies — the controls the MITRE tests probe.
66 FortiOS CVE checks
Train-based firmware matching (six trains 6.2-7.6) against 66 FortiGuard PSIRT CVEs: 16 CRITICAL, 27 HIGH, 23 MEDIUM, including KEV-listed SSL VPN/fgfmd RCEs, FortiJump, and xortigate.
MITRE ATT&CK resilience
31 technique tests across 11 tactics (Initial Access through Impact and Reconnaissance) verify FortiGate controls mitigate real attacks, yielding a 0-100% resilience score.
Logging, HA & certificates
18 logging checks (FortiAnalyzer/syslog/encryption/alerts), 8 HA checks (heartbeat auth/encryption, session pickup, firmware sync), and 11 cert checks (default/expiry/SHA-1/self-signed/CRL-OCSP).
Network & advanced hardening
18 network checks (DoS, SNMP, routing auth, NTP, IPv6, anti-spoofing, DNS encryption) plus ~15 advanced checks (FIPS 140-2, TCP timers, SSH grace, SCP).
Wireless, ZTNA/SD-WAN, backup & auth
Wireless (9: SSID security, WIDS, 802.11w/r, CAPWAP), ZTNA/SD-WAN (6: access proxy, client certs, SLA), backup/DR (5), and authentication (6: LDAP/RADIUS/SAML/MFA server verification).
Remediation & compliance evidence
Each finding auto-resolves to CIS/PCI-DSS/NIST/SOC2/HIPAA controls (76 mappings) and to one of 42 exportable FortiOS CLI fix blocks.

06Technology Stack

Language
Python 3.10+
Live dependency
requests (lazy-imported; only needed for REST-API mode)
Offline dependency
None — Python standard library only (stdlib re/argparse), runs on air-gapped hosts
Target API
FortiOS REST API v2 (cmdb + monitor endpoints), Bearer-token auth; FortiOS 6.x/7.x
Testing
pytest — 23 test functions in test_data/test_offline_parser.py plus sample .conf smoke fixtures
Reporting
Built-in JSON, dark-theme HTML (Catppuccin Mocha), compliance CSV, and CLI remediation exporters
Deployment
Single-file scanners, zero-agent, git clone; CI-ready via CRITICAL/HIGH exit-code gating

07Quick Start

$ git clone https://github.com/Krishcalin/Fortinet-Network-Security.git && cd Fortinet-Network-Security && pip install requests
$ python fortinet_scanner.py 10.1.1.1 --token <API-TOKEN>
$ python fortinet_scanner.py 10.1.1.1 --token <TOKEN> --json report.json --html report.html --compliance-csv audit.csv --remediation fix.txt
$ python fortinet_scanner.py --inventory devices.json --json unified_report.json
$ python fortinet_offline_scanner.py /path/to/fortigate.conf --json report.json --html report.html --severity HIGH
$ python -m pytest test_data/test_offline_parser.py -v

08Compliance & Frameworks

CIS FortiGate Benchmark
Maps findings to CIS FortiGate sections 2-14 covering admin, logging, policy, and hardening controls.
PCI-DSS 4.0
Maps to PCI-DSS requirements 1, 2, 4, 5, 6, 7, 8, 10, 11, and 12.
NIST 800-53 Rev 5
Maps to AC, AU, CM, CP, IA, RA, SC, and SI control families.
SOC 2 Type II
Maps to CC6 and CC7 trust-services criteria.
HIPAA Security Rule
Maps to 164.308 and 164.312 safeguard sections.
MITRE ATT&CK
31 Enterprise techniques across 11 tactics tested for control coverage with a 0-100% resilience score.

09Integrations & Outputs

FortiOS REST API v2 (cmdb + monitor endpoints, ~60 distinct calls)FortiGate .conf config backups (offline/air-gapped ingestion)FortiGuard PSIRT advisories (CVE source of truth)JSON report exportInteractive dark-theme HTML report exportCompliance CSV audit-evidence exportFortiOS CLI remediation script exportGitHub Actions / CI via CRITICAL-HIGH exit-code gating and JSON inventory fleet scans

Explore Fortinet FortiGate Scanner

Full source, documentation, and deployment guides live on GitHub.