diff --git a/docs/configuration.md b/docs/configuration.md index 2b97dec6..6bf59529 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -262,7 +262,15 @@ See the [information providers]({% link usage/information_provider_system.md %}) * `TRUSTED_PROXIES` (env only): Set the IP addresses (or IP blocks) of trusted reverse proxies here. This is needed to get correct IP information (see [here](https://symfony.com/doc/current/deployment/proxies.html) for more info). * `TRUSTED_HOSTS` (env only): To prevent `HTTP Host header attacks` you can set a regex containing all host names via which Part-DB - should be accessible. If accessed via the wrong hostname, an error will be shown. + should be accessible. If accessed via a hostname not matching the regex, an error page will be shown instead. By default this + is empty, meaning Part-DB accepts requests for any host name, which is not recommended for production use. + + For example, if Part-DB should only be reachable under `part-db.example.invalid`, set: + ``` + TRUSTED_HOSTS='^(part-db\.example\.invalid)$' + ``` + You can specify multiple host names separated by `|`, e.g. `^(localhost|part-db\.example\.invalid)$`. + Part-DB displays a warning on the homepage (visible to administrators only) as long as this value is not set. * `DEMO_MODE` (env only): Set Part-DB into demo mode, which forbids users to change their passwords and settings. Used for the demo instance. This should not be needed for normal installations. * `NO_URL_REWRITE_AVAILABLE` (allowed values `true` or `false`) (env only): Set this value to true, if your webserver does not diff --git a/docs/installation/installation_docker.md b/docs/installation/installation_docker.md index 97b1e662..0d5f8a8b 100644 --- a/docs/installation/installation_docker.md +++ b/docs/installation/installation_docker.md @@ -84,7 +84,11 @@ services: # If you use a reverse proxy in front of Part-DB, you must configure the trusted proxies IP addresses here (see reverse proxy documentation for more information): # - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 - + + # To prevent HTTP Host header attacks, set this to a regex matching all host names Part-DB should be reachable under. + # By default (unset) Part-DB accepts requests for any host name, which is not recommended for production use. + # - TRUSTED_HOSTS=^(part-db\.example\.invalid)$ + # If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here: # The packages will be installed automatically when the container starts # - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer @@ -96,7 +100,10 @@ services: ```bash openssl rand -hex 32 ``` -6. Inside the folder, run +6. Uncomment and set the `TRUSTED_HOSTS` variable to a regex matching the host name(s) Part-DB should be reachable under + (e.g. `^(part-db\.example\.invalid)$`), to prevent HTTP Host header attacks. See [Configuration]({% link configuration.md %}) + for more information. +7. Inside the folder, run ```bash docker-compose up -d @@ -107,7 +114,7 @@ openssl rand -hex 32 > Otherwise Part-DB console might use the wrong configuration to execute commands. -7. Create the initial database with +8. Create the initial database with ```bash docker exec --user=www-data partdb php bin/console doctrine:migrations:migrate @@ -115,7 +122,7 @@ docker exec --user=www-data partdb php bin/console doctrine:migrations:migrate and watch for the password output -8. Part-DB is available under `http://localhost:8080` and you can log in with the username `admin` and the password shown +9. Part-DB is available under `http://localhost:8080` and you can log in with the username `admin` and the password shown before The docker image uses a SQLite database and all data (database, uploads, and other media) is put into folders relative to @@ -171,7 +178,11 @@ services: # Override value if you want to show a given text on homepage. # When this is commented out the webUI can be used to configure the banner #- BANNER=This is a test banner
with a line break - + + # To prevent HTTP Host header attacks, set this to a regex matching all host names Part-DB should be reachable under. + # By default (unset) Part-DB accepts requests for any host name, which is not recommended for production use. + # - TRUSTED_HOSTS=^(part-db\.example\.invalid)$ + # If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here: # - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer diff --git a/docs/installation/installation_guide-debian.md b/docs/installation/installation_guide-debian.md index 2915adbb..9729d772 100644 --- a/docs/installation/installation_guide-debian.md +++ b/docs/installation/installation_guide-debian.md @@ -145,6 +145,16 @@ A full list of configuration options can be found [here](../configuration.md). > ``` > or edit the file with a text editor and add a new value for `APP_SECRET` (you can generate a random value with `openssl rand -hex 32`). +{: .important } +> **Set `TRUSTED_HOSTS` before going live.** By default Part-DB accepts requests for any host name, which makes it +> vulnerable to `HTTP Host header attacks`. Edit your `.env.local` with a text editor and set `TRUSTED_HOSTS` to a +> regex matching all host names Part-DB should be reachable under, e.g. if Part-DB should only be reachable via +> `part-db.example.invalid`: +> ``` +> TRUSTED_HOSTS='^(part-db\.example\.invalid)$' +> ``` +> See the [configuration options](../configuration.md) page for more information about `TRUSTED_HOSTS`. + Please check that the configured base currency matches your mainly used currency, as this can not be changed after creating price information. diff --git a/docs/installation/reverse-proxy.md b/docs/installation/reverse-proxy.md index 605b93fa..24d502b4 100644 --- a/docs/installation/reverse-proxy.md +++ b/docs/installation/reverse-proxy.md @@ -22,6 +22,16 @@ TRUSTED_PROXIES=192.168.2.10 Set the `DEFAULT_URI` environment variable to the URL of your Part-DB installation, available from the outside (so via the reverse proxy). +You should also set the `TRUSTED_HOSTS` environment variable to a regex matching the host name(s) Part-DB is reachable +under via the reverse proxy, to prevent `HTTP Host header attacks`. For example, if Part-DB is reachable via +`part-db.example.invalid`, set: + +``` +TRUSTED_HOSTS='^(part-db\.example\.invalid)$' +``` + +See the [configuration options](../configuration.md) page for more information about `TRUSTED_HOSTS`. + ## Part-DB in a subpath via reverse proxy If you put Part-DB into a subpath via the reverse proxy, you have to configure your webserver to include `X-Forwarded-Prefix` in the request headers.