fortitool: A Tool for Decrypting and Analyzing FortiOS Firmware

Tools2026-08-27, 08:04
fortitool: A Tool for Decrypting and Analyzing FortiOS Firmware
Ali Mosajjal has published fortitool, an open-source Go tool for decrypting and unpacking Fortinet FortiOS firmware. It combines the capabilities of several existing utilities and requires no runtime dependencies such as Python, OpenSSL, or binwalk. A single command automatically detects the firmware format and processes the entire chain — from outer-layer encryption of .out files to filesystem extraction: fortitool decrypt -o outdir image.out There is no need to specify the FortiOS version, device model, or architecture.
• Firmware decryption fortitool supports the FortiOS encryption schemes known to the author, including XOR, ChaCha20 + RSA + AES-CTR, XOR + RSA + FORT-RC4, and modified RC4. It also supports gzip/tar/xz, ext2/3/4 filesystems, and qcow2 disk images. Key material is recovered directly from the kernel image: the 32-byte seed and obfuscated RSA public key are located using the known ASN.1 DER prefix of the reconstructed key, while the rootfs encryption algorithm is identified by attempting decryption and checking for the gzip magic bytes. As a result, manual analysis in Ghidra is not required for most stages.
• FortiOS secret decryption The fortitool config decrypt command decrypts ENC <base64> values from configuration backups. For versions prior to 7.4, it uses the static AES-128 key associated with CVE-2019-6693. Contrary to common belief, the author confirmed that it was not replaced in FortiOS 6.2 and continued to work at least through 7.2.3. Starting with FortiOS 7.4 build 2731, a new static AES-256-CBC key is used; the author recovered it by reverse engineering /bin/init and verified it against real backups. The practical takeaway: FortiOS configuration backups should be treated as plaintext-adjacent unless private-data-encryption with a passphrase is enabled.
Support varies across firmware generations: ARM 7.4.x and several other formats have been validated against real firmware, while some 7.6.x, 8.0, x86_64, and VM/qcow2 paths are currently based on prior research and synthetic tests and still require validation against real images.
Vulnerabilities
7.8
CVE-2019-6693
Vendors
Fortinet
Products
Fortios
Fortitool