r/fortinet • • Aug 22 '26

FortiGate / FortiOS Fortinet Using Hardcoded Backup Key

13 Upvotes

21 comments sorted by

24

u/FantaFriday NSE 8 Aug 22 '26

In a non private encryption scenario, the ability to recover encrypted material has been a feature since it's existence. How else did people think you could share a config between devices and with tac.

Anyway, the tool itself is a nice piece of rwsearch and handy for recovering keys.

31

u/HappyVlane r/Fortinet - Members of the Year Aug 22 '26 edited Aug 22 '26

I don't really get the point of the article. It's not a secret that only enabling Private Data Encryption solves the issue with the hardcoded key.

If the tool can crack a file with PDE enabled then it's a story, but that's not what the article does.

Also, it doesn't say if this works for admin passwords using the enhanced admin password security from 7.4.8+.

9

u/RUMD1 NSE 7 Aug 22 '26

Yeap, I don't see the point either lol...

7

u/code0 Aug 22 '26

If I'm not mistaken, PDE is just replacing the built-in key with a unique key (and IIRC, stored in the TPM in newer models). It throws a wrench into things like restoring backups, using FortiManager, etc, so I don't think I've ever seen it used.

That said, the encryption key is meant to obfuscate secrets in the configuration - NOT encrypt them.

As far as the admin password enhancements, that was just the introduction of PBKDF2 (PB2 prefix). Previously it was SHA1 (AK1) or SHA256 (SH2) with a salt. The PBKDF2 implementation isn't perfect, but definitely an improvement over the previous generations (and... admin passwords are HASHED rather than encrypted, so the bar was always higher anyway).

1

u/Wasteway Aug 24 '26

As you pointed out, this primarily impacts older FortOS versions which IS good.

Looking at the hardening section in the 8.0 firmware guide you shared, it states the following:

When a device has private-data-encryption enabled in FortiOS 7.6.1 and later, and the hardware malfunctions, you must disable private-data-encryption and back up the configuration. Then you can restore the configuration backup on a replacement unit with private-data-encryption disabled. After restoring the configuration backup, you can enable the private-data-encryption setting on the replacement unit.

Depending on the reason the hardware malfunctioned, you may be unable to complete this operation*. Therefore, consider this risk when you enable private-data-encryption.*

https://docs.fortinet.com/document/fortigate/8.0.0/best-practices/555436/hardening#ipt-to-configure-your-own-private-encryption-key

This honestly makes me nervous. Need to do some additional research.

As I'm still on 7.4.12 due to 7.6 stability and compatibility issues, if I use the onboard TPM and set the key the same on both of my HA units as described here:

https://docs.fortinet.com/document/fortigate/7.4.12/administration-guide/893277/trusted-platform-module-support

And I carefully store that same key, I should be able to RMA to an identical until, use the stored key to configure the TPM on the replacement and restore without issue?

1

u/Wasteway Aug 24 '26 edited Aug 24 '26

Based on what I'm reading, because 7.6.1+ generates its own key (unknown to the user), it IS able to synchronize this in a HA config, but you couldn't port it to a new cluster without one of the prior members. Losing both members is unlikely, but I wish there was a way to backup the key.

2

u/HappyVlane r/Fortinet - Members of the Year Aug 24 '26

Yes.

-7

u/Wasteway Aug 22 '26

The re-use of keys is what is disturbing. Main obvious take away is to be running latest 7 stable firmware you can. Being on 7.2 or low 7.4 versions is a serious risk. Those of us who pay attention already know this, but this provides concrete examples as to why. I notice he didn’t explore 8 due to, I assume his hardware not supporting it. Also points out need to keep tract of, and securely store your config back ups. I will be doing some auditing on Monday regarding that.

9

u/WolfiejWolf FCX - Fortinet Certified Expert Aug 22 '26

Risk of what exactly?

The reuse of keys they are referring to in the article, is in two parts, the ability to decrypt the firmware, and the encryption of secrets in the config. The first was covered by BishopFox in 2023, the 2nd was discovered back in I believe 2019.

On the ability to decrypt the firmware, itis hardly surprising since FortiOS, and the FortiGate BIOS need to decrypt the firmware, so it can load it. You can argue that its weak, and there's possibly better ways of doing things, but its not thats it not understandable. Also, their commentary around versions completely ignores the fact that the BishopFox finding was in 2023. At that time 6.0, 6.2, 7.0, 7.2 and 7.4 were all actively supported. So this "finding" of theirs is meant to be surprising somehow?! Also, how does someone decrypting the images actually affect a FortiGate administrator? Malicious actors are most likely already doing this, and poking the code for vulnerabilities. The situation hasn't really changed.

With regard to the hardcoded key for encrypting fields in the config, this has been well known for a long time (the password was even published a long time ago). What the author "discovered" is that it was replaced with a new key. But as Vlane pointed everyone who has been paying attention already knew that. Private Data Encryption (PDE) is designed to remediate that issue by encrypting those fields with the PDE key. which has been in a FortiGate since 5.4.0. Additionally, configurations can (and should) be encrypted with a user defined password when performing backups. Which means, knowing the hardcoded key is pretty much worthless.

-1

u/Wasteway Aug 22 '26

Well some of us who wear multiple hats missed that, so hopefully others can learn, as I have today, that I need to leverage that feature. Thanks for adding color to the discussion.

-7

u/Wasteway Aug 22 '26

Also my guess is few if any people use the PDE option. I have to admit, I wasn’t and will be exploring this with our configs.

12

u/HappyVlane r/Fortinet - Members of the Year Aug 22 '26

Then you're not following Fortinet best practices and you got lots to cover.

https://docs.fortinet.com/document/fortigate/8.0.0/best-practices/555436/hardening

0

u/Wasteway Aug 22 '26

You’re not wrong but we all have lots to cover. I spend quite a bit of time reviewing things like this, but somehow missed it. Thanks for sharing. Will make sure we utilize this going forward.

2

u/Qwireca Aug 22 '26

While it is best practice, it also seems like it will making backups a manuall, or scripted thing? From 7.6 documentations. "When enabling private-data-encryption, instead of asking users to input a 32 digit hexadecimal string as the master-encryption-password, the FortiGate will generate a random password itself. This increases security as the master-encryption-password is not known and cannot be stolen or leaked.

As such, a configuration that is backed up while private-data-encryption is enabled cannot be restored when private-data-encryption is disabled or when private-data-encryption is re-enabled with a different random key."
I read it as private-data-encryption must be disabled before each backup, and then re-enabled again or you will not be able to restore the config to a backup unit, or same unit if re-imaged. Hopefully I'm wrong.

2

u/HappyVlane r/Fortinet - Members of the Year Aug 22 '26

You're not wrong.

0

u/Wasteway Aug 22 '26

Ugh.

Here’s the fun part though: in every single case, the key material FortiOS hides in the kernel image can be found without ever opening a disassembler. The recovered RSA key always decrypts to the same ASN.1 DER prefix, so you scan the kernel for byte windows satisfying that constraint. Then you take each candidate, try every rootfs cipher against a probe block, and look for gzip magic bytes in the output. When it comes out right, you have the cipher and the key at once.

-14

u/not-a-co-conspirator Aug 22 '26

Hahahaha what moron at a security company would make that decision?

3

u/Internet-of-cruft Aug 22 '26

I know we make jest of this, but it seems like every major networking & security company has done something stupid like this in the last 20 years.

Not that it makes OK, but this is a frighteningly common problem.

-4

u/Wasteway Aug 22 '26

Reading deeper, it is like most things these days. Strong design decisions coupled with a few poor ones.

-13

u/HappyDadOfFourJesus FCF - Fortinet Certified Fundamentals Aug 22 '26

How long until we see a firmware update that resolves this security exposure?

15

u/lokkkks FCX - Fortinet Certified Expert Aug 22 '26

Already released. Use Private-data-encryption.