Why is it even possible for 3rd party programs to change browser settings?
A program I recently installed was a malware and changed the search engine, home page and page for new tabs in Firefox and it was a hell to reset. Not even resetting to the default values in about:config worked until the malware was removed. these malwares are very common, including most of the free anti virus programs and a lot of Microsoft programs.
So, why is it even possible for 3rd party programs to change these settings or to install add-ons by themselves. Couldn't the Firefox files be encrypted or protected in some way?
Alle svar (3)
Yes, that would be possible, but it would also affect "legitimate" programs from interacting with Firefox. Mozilla has no way to separate programs that the user installs into "wanted features" and Malware, and specifically block the Malware - it doesn't come "flagged" as such.
If you had been running Malwarebytes or similar, (like Anti-Malware), and those programs were running all the time, it would provide a measure of protection against the hidden Malware installers that are sometimes packaged with seemingly legitimate programs. Anti-Malware programs specifically track garbage like that and prevent it from being installed; much like Anti-Virus programs track and prevent Viruses from getting into a PC.
I know a computer can't distinguish good from evil. However I've never seen a legitimate program trying to change these settings. Couldn't there be a confirm box in Firefox asking if the user wants these settings changed? I don't know if there's already an API these program uses or if they just write to Firefox's files directly.
If you do not keep changes after a restart or otherwise have problems with preferences, see:
You can rename or delete the prefs.js file and possible numbered prefs-##.js files and a possible user.js file to reset all prefs to the default value.