Firefox configuration hardening
A user.js configuration file for Mozilla Firefox designed to harden browser settings and make it more secure.
This is a default template with every possible hardening measure enforced. See the relaxed branch for a variant providing more usability
There are several parts to all this and they are:
user.js file.user.js to adapt it to your web browser usage.Different download methods are available:
git clone https://github.com/pyllyukko/user.jsuser.js directlyDo note that these settings alter your browser behaviour quite a bit, so it is recommended to either create a completely new profile for Firefox or backup your existing profile directory before putting the user.js file in place.
To enable the Profile Manager, run Firefox with command-line arguments: firefox --no-remote -P
Copy user.js in your current user profile directory, or (recommended) to a fresh, newly created Firefox profile directory.
The file should be located at:
| OS | Path |
|---|---|
| Windows 7 | %APPDATA%\Mozilla\Firefox\Profiles\XXXXXXXX.your_profile_name\user.js |
| Linux | ~/.mozilla/firefox/XXXXXXXX.your_profile_name/user.js |
| OS X | ~/Library/Application Support/Firefox/Profiles/XXXXXXXX.your_profile_name |
| Android | /data/data/org.mozilla.firefox/files/mozilla/XXXXXXXX.your_profile_name and see issue #14 |
| Sailfish OS + Alien Dalvik | /opt/alien/data/data/org.mozilla.firefox/files/mozilla/XXXXXXXX.your_profile_name |
| Windows (portable) | [firefox directory]\Data\profile\ |
With this installation method, if you change any of user.js settings through about:config or Firefox preferences dialogs, they will be reset to the user.js defined values after you restart Firefox. This makes sure they're always back to secure defaults when starting the browser. However this prevents persistently changing settings you don't consider appropriate. Either edit user.js directly, or use the system-wide installation method described below.
Generate a file suitable for system-wide installation, by running make with one of the following targets:
systemwide_user.js: (the value will be used as default value for all Firefox Profiles where it is not explicitly set, it can be changed in about:config and is kept across browser sessions)locked_user.js: (the value will be used as default value on Firefox profile creation, will be locked and can't be changed) in user.js or in Firefox's about:config or settings.debian_locked.js: Debian specific. Users are not able to override preferences. See #415.Copy the produced file to the Firefox installation directory. The file should be located at:
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg |
| Linux | /etc/firefox/syspref.js, for older versions: /etc/firefox/firefox.js |
| Linux (Debian) | /etc/firefox-esr/firefox-esr.js |
| Linux (Gentoo, Archlinux) | /usr/lib/firefox/mozilla.cfg, might also be /usr/lib32/ or /usr/lib64/ |
| OS X | /Applications/Firefox.app/Contents/Resources/mozilla.cfg |
Create local-settings.js in Firefox installation directory, with the following contents:
pref("general.config.obscure_value", 0);
pref("general.config.filename", "mozilla.cfg");
This file should be located at:
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\defaults\pref\ |
| OS X | /Applications/Firefox.app/Contents/Resources/defaults/pref |
| Linux (Gentoo, Archlinux) | /usr/lib/firefox/defaults/pref/, might also be /usr/lib32/ or /usr/lib64/ |
If mozilla.cfg still fails to load, you must add a blank comment to the top of mozilla.cfg like so:
//
Not all Firefox settings can be changed through user.js - some must be set in a separate policies.json file [1]. These policies apply system-wide.
To install policies.json from this repository, simply copy it to the appropriate directory (create it if it does not exist):
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\distribution\ |
| OS X | /Applications/Firefox.app/distribution\ |
| Linux (Debian) | /etc/firefox-esr/policies/ |
Note that JSON does not support comments, hence settings are documented in custom *_comment keys. Mozilla maintains a list of available policies: [1] [2](https://github.com/mozilla/policy-templates). The Enterprise Policy Generator add-on can be used to generate policies.json files from a graphical interface.
For any of the above methods, you can keep your browser's user.js with the latest version available here: Clone the repository, and create a symbolic link from the appropriate location to the user.js file in the repository. Just run git pull in the repository when you want to update, then restart Firefox:
cd ~/.mozilla/firefox
git clone 'https://github.com/pyllyukko/user.js.git'
cd XXXXXXXX.your_profile_name
ln -s ${HOME}/.mozilla/firefox/user.js/user.js user.js
Verify that the settings are effective from about:support (check the "Important Modified Preferences" and "user.js Preferences" sections).
Verify that policies are effective from about:policies.
There's a whole lot of settings that this modifies and they are divided in the following sections.
Some of the settings in this user.js file might seem redundant, as some of them are already set to the same values by default. We chose to explicitely set their values, which ensures these settings are enforced if a future Firefox update changes the default value.
HTML5 / APIs / DOM related settings. Mozilla is keen to implement every new HTML5 feature, which have had unforeseen security or privacy implications. This section disables many of those new and yet to be proven technologies.
Settings that do not belong to other sections or are user specific preferences.
Harden preferences related to external plugins
Disable Firefox integrated metrics/reporting/experiments, disable potentially insecure/invasive/undesirable features
Prevents the browser from auto-connecting to some Mozilla services, and from predictively opening connections to websites during browsing.
HTTP protocol related entries. This affects cookies, the user agent, referer and others.
Enable and configure private browsing mode, don't store information locally during the browsing session
Improve visibility of security-related elements, mitigate shoulder-surfing
TLS protocol related settings
This section tweaks the cipher suites used by Firefox. The idea is to support only the strongest ones with emphasis on forward secrecy, but without compromising compatibility with all those sites on the internet. As new crypto related flaws are discovered quite often, the cipher suites can be tweaked to mitigate these newly discovered threats.
This is not enough! Here's some other tips how you can further harden Firefox:
TZ environment variable (see here) to reduce it's value in browser fingerprintinguser.js and is left for the user to decide (see #11)Here is a list of the most essential security and privacy enhancing add-ons that you should consider using:
Additional add-ons that you might consider using or reading about:
Hardening your often implies a trade-off with ease-of-use and comes with reduced functionality. Here is a list of known problems/limitations:
security.OCSP.require will make the connection fail when the OCSP responder is unavailablesecurity.OCSP.require is known to break browsing on some captive portalsIn addition see the current issues. You can use the web console to investigate what causes websites to break.
Does this user.js file fix all security problems?
No. Please read Known problems and limitations, the project's issue tracker, and report new issues there. Please open separate issues for each individual problem/question you may have.
Why are obsolete/deprecated entries included in the user.js file?
This project is aimed at Firefox versions between the current ESR and the latest Firefox release. We will wait for widespread deployment of the current ESR (eg. adoption in major Linux distributions) before removing deprecated/obsolete preferences. Presence of deprecated entries causes no known problems.
Installing the user.js file breaks xyz plugin/addon/extension, how can I fix it?
See https://github.com/pyllyukko/user.js/issues/100
Will there be an official addon/an android version/feature xyz?
Search the project issues.
How can I lock my preferences to prevent Firefox overwriting them?
See lockPref in System-wide installation.
Yes please! All issues and pull requests are more than welcome. Please try
to break down your pull requests or commits into small / manageable entities,
so they are easier to process. All the settings in the user.js file
should have some official references to them, so the effect of those settings
can be easily verified from Mozilla's documentation.
Feel free to follow the latest commits RSS feed and other interesting feeds from the References section.
You may also reach other contributors through IRC (#user.js on Freenode) or Gitter.
For more information, see CONTRIBUTING
Run make help to get a list of makefile targets used for frequent maintenance operations.
$ make help
locked_user.js generate a locked configuration file
systemwide_user.js generate a system-wide configuration file
debian_locked.js generate a locked, system-wide configuration file
policies.json generate policy file (https://github.com/mozilla/policy-templates/blob/master/README.md)
tests run all tests
test-acorn validate user.js syntax
test-shellcheck check/lint shell scripts
000-tor-browser.js download Tor Browser custom configuration reference
diff-tbb differences between values from this user.js and tor browser's values
diff-tbb-2 differences between values from this user.js and tor browser's values (alternate method)
diff-tbb-missing-from-user.js preferences that are present in tor browser's defaults, but not in this user.js
diff-sourceprefs.js download and sort all known preferences files from Firefox (mozilla-central) source
diff-upstream-duplicates preferences with common values with default Firefox configuration
diff-upstream-missing-from-user.js preferences present in firefox source but not covered by user.js
diff-upstream-deprecated preferences in hardened user.js that are no longer present in firefox source
diff-stats count preferences number, various stats
clean clean automatically generated files/build/test artifacts
doc-whatdoesitdo generate the README "What does it do?" section
doc-toc generate the README table of contents
help generate list of targets with descriptions
(top 24 of 48)
50 followers · starred Jul 2018
1,673 followers · starred Mar 2026
326 followers · starred Jan 2022
749 followers · starred Apr 2025
Firefox configuration hardening
A user.js configuration file for Mozilla Firefox designed to harden browser settings and make it more secure.
This is a default template with every possible hardening measure enforced. See the relaxed branch for a variant providing more usability
There are several parts to all this and they are:
user.js file.user.js to adapt it to your web browser usage.Different download methods are available:
git clone https://github.com/pyllyukko/user.jsuser.js directlyDo note that these settings alter your browser behaviour quite a bit, so it is recommended to either create a completely new profile for Firefox or backup your existing profile directory before putting the user.js file in place.
To enable the Profile Manager, run Firefox with command-line arguments: firefox --no-remote -P
Copy user.js in your current user profile directory, or (recommended) to a fresh, newly created Firefox profile directory.
The file should be located at:
| OS | Path |
|---|---|
| Windows 7 | %APPDATA%\Mozilla\Firefox\Profiles\XXXXXXXX.your_profile_name\user.js |
| Linux | ~/.mozilla/firefox/XXXXXXXX.your_profile_name/user.js |
| OS X | ~/Library/Application Support/Firefox/Profiles/XXXXXXXX.your_profile_name |
| Android | /data/data/org.mozilla.firefox/files/mozilla/XXXXXXXX.your_profile_name and see issue #14 |
| Sailfish OS + Alien Dalvik | /opt/alien/data/data/org.mozilla.firefox/files/mozilla/XXXXXXXX.your_profile_name |
| Windows (portable) | [firefox directory]\Data\profile\ |
With this installation method, if you change any of user.js settings through about:config or Firefox preferences dialogs, they will be reset to the user.js defined values after you restart Firefox. This makes sure they're always back to secure defaults when starting the browser. However this prevents persistently changing settings you don't consider appropriate. Either edit user.js directly, or use the system-wide installation method described below.
Generate a file suitable for system-wide installation, by running make with one of the following targets:
systemwide_user.js: (the value will be used as default value for all Firefox Profiles where it is not explicitly set, it can be changed in about:config and is kept across browser sessions)locked_user.js: (the value will be used as default value on Firefox profile creation, will be locked and can't be changed) in user.js or in Firefox's about:config or settings.debian_locked.js: Debian specific. Users are not able to override preferences. See #415.Copy the produced file to the Firefox installation directory. The file should be located at:
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg |
| Linux | /etc/firefox/syspref.js, for older versions: /etc/firefox/firefox.js |
| Linux (Debian) | /etc/firefox-esr/firefox-esr.js |
| Linux (Gentoo, Archlinux) | /usr/lib/firefox/mozilla.cfg, might also be /usr/lib32/ or /usr/lib64/ |
| OS X | /Applications/Firefox.app/Contents/Resources/mozilla.cfg |
Create local-settings.js in Firefox installation directory, with the following contents:
pref("general.config.obscure_value", 0);
pref("general.config.filename", "mozilla.cfg");
This file should be located at:
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\defaults\pref\ |
| OS X | /Applications/Firefox.app/Contents/Resources/defaults/pref |
| Linux (Gentoo, Archlinux) | /usr/lib/firefox/defaults/pref/, might also be /usr/lib32/ or /usr/lib64/ |
If mozilla.cfg still fails to load, you must add a blank comment to the top of mozilla.cfg like so:
//
Not all Firefox settings can be changed through user.js - some must be set in a separate policies.json file [1]. These policies apply system-wide.
To install policies.json from this repository, simply copy it to the appropriate directory (create it if it does not exist):
| OS | Path |
|---|---|
| Windows | C:\Program Files (x86)\Mozilla Firefox\distribution\ |
| OS X | /Applications/Firefox.app/distribution\ |
| Linux (Debian) | /etc/firefox-esr/policies/ |
Note that JSON does not support comments, hence settings are documented in custom *_comment keys. Mozilla maintains a list of available policies: [1] [2](https://github.com/mozilla/policy-templates). The Enterprise Policy Generator add-on can be used to generate policies.json files from a graphical interface.
For any of the above methods, you can keep your browser's user.js with the latest version available here: Clone the repository, and create a symbolic link from the appropriate location to the user.js file in the repository. Just run git pull in the repository when you want to update, then restart Firefox:
cd ~/.mozilla/firefox
git clone 'https://github.com/pyllyukko/user.js.git'
cd XXXXXXXX.your_profile_name
ln -s ${HOME}/.mozilla/firefox/user.js/user.js user.js
Verify that the settings are effective from about:support (check the "Important Modified Preferences" and "user.js Preferences" sections).
Verify that policies are effective from about:policies.
There's a whole lot of settings that this modifies and they are divided in the following sections.
Some of the settings in this user.js file might seem redundant, as some of them are already set to the same values by default. We chose to explicitely set their values, which ensures these settings are enforced if a future Firefox update changes the default value.
HTML5 / APIs / DOM related settings. Mozilla is keen to implement every new HTML5 feature, which have had unforeseen security or privacy implications. This section disables many of those new and yet to be proven technologies.
Settings that do not belong to other sections or are user specific preferences.
Harden preferences related to external plugins
Disable Firefox integrated metrics/reporting/experiments, disable potentially insecure/invasive/undesirable features
Prevents the browser from auto-connecting to some Mozilla services, and from predictively opening connections to websites during browsing.
HTTP protocol related entries. This affects cookies, the user agent, referer and others.
Enable and configure private browsing mode, don't store information locally during the browsing session
Improve visibility of security-related elements, mitigate shoulder-surfing
TLS protocol related settings
This section tweaks the cipher suites used by Firefox. The idea is to support only the strongest ones with emphasis on forward secrecy, but without compromising compatibility with all those sites on the internet. As new crypto related flaws are discovered quite often, the cipher suites can be tweaked to mitigate these newly discovered threats.
This is not enough! Here's some other tips how you can further harden Firefox:
TZ environment variable (see here) to reduce it's value in browser fingerprintinguser.js and is left for the user to decide (see #11)Here is a list of the most essential security and privacy enhancing add-ons that you should consider using:
Additional add-ons that you might consider using or reading about:
Hardening your often implies a trade-off with ease-of-use and comes with reduced functionality. Here is a list of known problems/limitations:
security.OCSP.require will make the connection fail when the OCSP responder is unavailablesecurity.OCSP.require is known to break browsing on some captive portalsIn addition see the current issues. You can use the web console to investigate what causes websites to break.
Does this user.js file fix all security problems?
No. Please read Known problems and limitations, the project's issue tracker, and report new issues there. Please open separate issues for each individual problem/question you may have.
Why are obsolete/deprecated entries included in the user.js file?
This project is aimed at Firefox versions between the current ESR and the latest Firefox release. We will wait for widespread deployment of the current ESR (eg. adoption in major Linux distributions) before removing deprecated/obsolete preferences. Presence of deprecated entries causes no known problems.
Installing the user.js file breaks xyz plugin/addon/extension, how can I fix it?
See https://github.com/pyllyukko/user.js/issues/100
Will there be an official addon/an android version/feature xyz?
Search the project issues.
How can I lock my preferences to prevent Firefox overwriting them?
See lockPref in System-wide installation.
Yes please! All issues and pull requests are more than welcome. Please try
to break down your pull requests or commits into small / manageable entities,
so they are easier to process. All the settings in the user.js file
should have some official references to them, so the effect of those settings
can be easily verified from Mozilla's documentation.
Feel free to follow the latest commits RSS feed and other interesting feeds from the References section.
You may also reach other contributors through IRC (#user.js on Freenode) or Gitter.
For more information, see CONTRIBUTING
Run make help to get a list of makefile targets used for frequent maintenance operations.
$ make help
locked_user.js generate a locked configuration file
systemwide_user.js generate a system-wide configuration file
debian_locked.js generate a locked, system-wide configuration file
policies.json generate policy file (https://github.com/mozilla/policy-templates/blob/master/README.md)
tests run all tests
test-acorn validate user.js syntax
test-shellcheck check/lint shell scripts
000-tor-browser.js download Tor Browser custom configuration reference
diff-tbb differences between values from this user.js and tor browser's values
diff-tbb-2 differences between values from this user.js and tor browser's values (alternate method)
diff-tbb-missing-from-user.js preferences that are present in tor browser's defaults, but not in this user.js
diff-sourceprefs.js download and sort all known preferences files from Firefox (mozilla-central) source
diff-upstream-duplicates preferences with common values with default Firefox configuration
diff-upstream-missing-from-user.js preferences present in firefox source but not covered by user.js
diff-upstream-deprecated preferences in hardened user.js that are no longer present in firefox source
diff-stats count preferences number, various stats
clean clean automatically generated files/build/test artifacts
doc-whatdoesitdo generate the README "What does it do?" section
doc-toc generate the README table of contents
help generate list of targets with descriptions
(top 24 of 48)
50 followers · starred Jul 2018
1,673 followers · starred Mar 2026
326 followers · starred Jan 2022
749 followers · starred Apr 2025