Skip to content

Commit f5b7d1d

Browse files
adriendupuisglyemnocon
authored
How to handle security advisories (#3302)
* How to handle security advisories (#3278) * Add security_advisories.md * Use security_advisories.md * Update docs/infrastructure_and_maintenance/security/security_checklist.md * install_ibexa_dxp.md: Rm Php82HideDeprecationsErrorHandler * install_ibexa_dxp.md: Why ~E_DEPRECATED * code_samples.yaml: mv to config.policy.advisories.ignore-id --------- Co-authored-by: Gunnstein Lye <289744+glye@users.noreply.github.com> Co-authored-by: Marek Nocoń <mnocon@users.noreply.github.com>
1 parent b4842f8 commit f5b7d1d

5 files changed

Lines changed: 131 additions & 58 deletions

File tree

docs/getting_started/install_ibexa_dxp.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ month_change: false
1313

1414
!!! note "Installing [[= product_name_oss =]]"
1515

16-
This installation guide shows in details how to install [[= product_name =]] for users who have a subscription agreement with [[= product_name_base =]].
16+
This installation guide shows in detail how to install [[= product_name =]] for users who have a subscription agreement with [[= product_name_base =]].
1717
If you want to install [[= product_name_oss =]], you don't need authentication tokens or an account on updates.ibexa.co, but must adapt the steps shown here to the product edition and the `ibexa/oss-skeleton` repository.
1818

1919
## Prepare work environment
@@ -29,7 +29,7 @@ Additional requirements:
2929

3030
For production, you need to [configure an HTTP server](#configure-an-http-server), Apache or nginx (Apache is used as an example below).
3131

32-
Before getting started, make sure you review other [requirements](requirements.md) to see the systems that is supported and used for testing.
32+
Before getting started, make sure you review other [requirements](requirements.md) to see the systems that are supported and used for testing.
3333

3434
### Get Composer
3535

@@ -68,12 +68,12 @@ Log in to your Service portal on [support.ibexa.co](https://support.ibexa.co/),
6868
1. Select **Create token** (this requires the **Portal administrator** access level).
6969
2. Fill in a label describing the use of the token.
7070
This allows you to revoke access later.
71-
3. Save the password, **you aren't able to access it again**.
71+
3. Save the password. **You won't be able to access it again**.
7272

7373
!!! tip "Save the authentication token in `auth.json` to avoid re-typing it"
7474

7575
Composer asks whether you want to save the token every time you perform an update.
76-
If you prefer, you can decline and create an `auth.json` file globally in [`COMPOSER_HOME`](https://getcomposer.org/doc/03-cli.md#composer-home) directory for machine-wide use:
76+
If you prefer, you can decline and create an `auth.json` file globally in the [`COMPOSER_HOME`](https://getcomposer.org/doc/03-cli.md#composer-home) directory for machine-wide use:
7777

7878
``` bash
7979
composer config --global http-basic.updates.ibexa.co <installation-key> <token-password>
@@ -162,7 +162,11 @@ To use Composer to instantly create a project in the current folder with all the
162162

163163
<a id="authentication-token"></a>If you added credentials to the `COMPOSER_AUTH` variable, at this point add this variable to `auth.json` (for example, by running `echo $COMPOSER_AUTH > auth.json`).
164164

165-
!!! tip
165+
!!! caution "Security advisories"
166+
167+
If you encounter security advisories that prevent the install, see [Package security advisories](security_advisories.md#package-security-advisories).
168+
169+
!!! tip "Version constraint"
166170

167171
You can set [different version constraints](https://getcomposer.org/doc/articles/versions.md), for example, specific tag (`[[= latest_tag_5_0 =]]`), version range (`~5.0.1`), or stability (`^5.0@rc`):
168172

@@ -193,7 +197,7 @@ git init; git add . > /dev/null; git commit -m "init" > /dev/null
193197

194198
### Change installation parameters
195199

196-
At this point configure your database via the `DATABASE_URL` in the `.env` file, depending of the database you're using:
200+
At this point, configure your database via the `DATABASE_URL` in the `.env` file, depending on the database you're using:
197201

198202
`DATABASE_URL=mysql://user:password@host:port/database_name`.
199203

@@ -217,7 +221,7 @@ It's used by Symfony when generating [CSRF tokens]([[= symfony_doc =]]/security/
217221

218222
The app secret is crucial to the security of your installation.
219223
Be careful about how you generate it, and how you store it.
220-
Here's one way to generate a 64 characters long, secure random string as your secret, from command line:
224+
Here's one way to generate a secure random string of 64 characters as your secret, from the command line:
221225

222226
``` bash
223227
php -r "print bin2hex(random_bytes(32));"
@@ -227,13 +231,13 @@ It's used by Symfony when generating [CSRF tokens]([[= symfony_doc =]]/security/
227231
If you have any suspicion that the secret may have been exposed, replace it with a new one.
228232
The same goes for other secrets, like database password, Varnish invalidate token, JWT passphrase, and more.
229233

230-
After changing the app secret, make sure that you clear the application cache and log out all the users.
234+
After changing the app secret, make sure that you clear the application cache and log out all users.
231235

232236
For more information, see [Symfony documentation]([[= symfony_doc =]]/reference/configuration/framework.html#secret).
233237

234-
It's recommended to store the database credentials in your `.env.local` file and not commit it to the Version Control System.
238+
It's recommended that you store the database credentials in your `.env.local` file, and not commit that file to the Version Control System.
235239

236-
In `DATABASE_VERSION` you can also configure the database server version (for a MariaDB database, prefix the value with `mariadb-`).
240+
In `DATABASE_VERSION`, you can also configure the database server version (for a MariaDB database, prefix the value with `mariadb-`).
237241

238242
!!! tip "Using PostgreSQL"
239243

@@ -267,11 +271,22 @@ You may choose to replace the [default search engine](legacy_search_overview.md)
267271

268272
Install [[= product_name =]] and create a database with:
269273

270-
``` bash
271-
php bin/console ibexa:install
272-
```
274+
=== "PHP 8.4"
275+
276+
Deprecation warnings must be suppressed when using PHP 8.4, otherwise the installation fails due to errors such as "headers have already been sent".
277+
278+
``` bash
279+
php -d error_reporting=`php -r 'echo E_ALL & ~E_DEPRECATED;'` bin/console ibexa:install
280+
php bin/console ibexa:graphql:generate-schema
281+
```
282+
283+
=== "PHP 8.3 and older"
284+
285+
``` bash
286+
php bin/console ibexa:install
287+
```
273288

274-
Before executing the command make sure that the database user has sufficient permissions.
289+
Before executing the command, make sure that the database user has sufficient permissions.
275290

276291
The installer will prompt you for a new password for the `admin` user.
277292
Make sure to use a [strong password](security_checklist.md#strong-passwords) meeting all the default [password rules](passwords.md#password-rules):
@@ -306,7 +321,7 @@ For development you can use the built-in PHP server.
306321
php -S 127.0.0.1:8000 -t public
307322
```
308323

309-
Your PHP web server is accessible at `http://127.0.0.1:8000`
324+
Your PHP web server is accessible at `http://127.0.0.1:8000`.
310325

311326
You can also use [Symfony CLI](https://symfony.com/download):
312327

@@ -316,7 +331,7 @@ symfony serve
316331

317332
## Prepare installation for development
318333

319-
Consider adding the Symfony DebugBundle which fixes memory outage when dumping objects with circular references.
334+
Consider adding the Symfony DebugBundle, which prevents running out of memory when dumping objects with circular references.
320335
The DebugBundle contains the [VarDumper]([[= symfony_doc =]]/components/var_dumper.html) and [its Twig integration]([[= symfony_doc =]]/components/var_dumper.html#debugbundle-and-twig-integration).
321336

322337
``` bash
@@ -329,7 +344,7 @@ For detailed information about request treatment, you can also install [Symfony
329344
composer require --dev symfony/profiler-pack
330345
```
331346

332-
To get both features in one go use:
347+
To get both features in one go, use:
333348

334349
``` bash
335350
composer require --dev symfony/debug-pack
@@ -341,7 +356,7 @@ To use [[= product_name =]] with an HTTP server, you need to [set up directory p
341356

342357
### Set up permissions
343358

344-
For development needs, the web user can be made the owner of all your files (for example with the `www-data` web user):
359+
For development needs, the web user can be made the owner of all your files (for example, with the `www-data` web user):
345360

346361
``` bash
347362
chown -R www-data:www-data <your installation directory>
@@ -352,7 +367,7 @@ Future files and directories created by these two users need to inherit those pe
352367

353368
!!! caution
354369

355-
For security reasons, in production, the web server cannot have write access to other directories than `var`.
370+
For security reasons, in production, the web server mustn't have write access to any directory other than `var`.
356371
Skip the step above and follow the link below for production needs instead.
357372

358373
You must also make sure that the web server cannot interpret the files in the `var` directory through PHP.
@@ -386,18 +401,18 @@ Prepare a [virtual host configuration](https://en.wikipedia.org/wiki/Virtual_hos
386401

387402
Finally, restart the Apache server.
388403
The command may vary depending on your Linux distribution.
389-
For example, on Ubuntu use:
404+
For example, on Ubuntu, use:
390405

391406
``` bash
392407
service apache2 restart
393408
```
394409

395410
=== "nginx"
396411

397-
You can use [this example vhost file](https://raw.githubusercontent.com/ibexa/post-install/5.0/resources/templates/nginx/vhost.template) and modify it to fit your project. You also need the `ibexa_params.d` files that should reside in a subdirectory below where the main file is, [as is shown here](https://github.com/ibexa/post-install/tree/5.0/resources/templates/nginx).
412+
You can use [this example vhost file](https://raw.githubusercontent.com/ibexa/post-install/5.0/resources/templates/nginx/vhost.template) and modify it to fit your project. You also need the `ibexa_params.d` files, which should reside in a subdirectory below the main file, [as shown here](https://github.com/ibexa/post-install/tree/5.0/resources/templates/nginx).
398413

399414
Specify `/<your installation directory>/public` as the `root`, or ensure `BASEDIR` is set in the environment.
400-
Ensure `APP_ENV` is set to `prod` or `dev` in the environment, depending on the environment that you're configuring, and uncomment the line that starts with `#if[APP_ENV`.
415+
Ensure `APP_ENV` is set to `prod` or `dev` in the environment, depending on which environment you're configuring, and uncomment the line that starts with `#if [APP_ENV]`.
401416

402417
When the virtual host file is ready, enable the virtual host and disable the default.
403418
Finally, restart the nginx server.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
description: Find [[= product_name_base =]] security advisories, and learn how to handle Composer package security advisories.
3+
month_change: true
4+
---
5+
6+
# Security advisories
7+
8+
## [[= product_name_base =]] security advisories
9+
10+
[[= product_name_base =]] security advisories are released via [your Service portal](https://support.ibexa.co/), and via [Security advisories](https://developers.ibexa.co/security-advisories). The latter is available to non-subscribers.
11+
12+
## Package security advisories
13+
14+
Overall, it's recommended to keep your Composer packages up to date.
15+
16+
You can run the following command to check for available updates without installing them:
17+
18+
```bash
19+
composer update --dry-run
20+
```
21+
22+
When a security issue is discovered in a Composer package, a security advisory is issued, and the affected versions of the package become blocked from installation unless you take action.
23+
24+
When installing or updating, Composer avoids installing packages that are affected by security advisories.
25+
However, this can create constraint issues that make installation or updates impossible.
26+
For example, security fixes might not be available for [unsupported PHP versions](https://www.php.net/supported-versions.php).
27+
28+
Example of a Composer output about a package with security issues when trying to install:
29+
30+
```text
31+
- Root composer.json requires twig/cssinliner-extra v3.11.0 (exact version match),
32+
found twig/cssinliner-extra[v3.11.0] but these were not loaded, because they are
33+
affected by security advisories ("PKSA-fs5b-x5k4-1h39").
34+
```
35+
36+
Composer's output doesn't always mention that a security advisory is blocking installation or updates.
37+
38+
For example, when trying to install [[= product_name =]] 4.6 on PHP 7.4 you might see an error like the following one:
39+
40+
```text
41+
- ibexa/user[v4.6.0, ..., v4.6.31] require twig/twig ^3.0 -> satisfiable by twig/twig[v3.27.0, v3.27.1, v3.28.0].
42+
- twig/twig[v3.27.0, ..., v3.28.0] require php >=8.1.0 -> your php version (7.4.33) does not satisfy that requirement.
43+
```
44+
45+
To gather more information, check package information on [Packagist](https://packagist.org/) and try installing a specific version of the package blocking installation.
46+
47+
In this case, trying to install [`twig/twig:3.11.3`](https://packagist.org/packages/twig/twig#v3.11.3) shows explicitly that this version is blocked by a security advisory:
48+
49+
```terminal
50+
% composer require twig/twig:3.11.3
51+
Your requirements could not be resolved to an installable set of packages.
52+
53+
Problem 1
54+
- Root composer.json requires twig/twig 3.11.3 (exact version match: 3.11.3 or 3.11.3.0),
55+
found twig/twig[v3.11.3] but these were not loaded, because they are affected by
56+
security advisories ("PKSA-8zx5-v2nz-58pb").
57+
```
58+
59+
It's highly recommended that you not install the affected package, and instead meet the requirements of the fixed version.
60+
61+
You can use the [Packagist Security Advisories database](https://packagist.org/security-advisories/) to learn more about a security advisory, such as the affected packages and versions, a detailed description of the issue, and other possible reference IDs for the advisory: PKSA (Packagist Security Advisory), GHSA (GitHub Security Advisories), and CVE (Common Vulnerabilities and Exposures).
62+
63+
If you need to, upgrade PHP and migrate your custom code to be compatible with the newer PHP version, for example by using [Rector](https://github.com/rectorphp/rector).
64+
65+
If updating the affected package isn't possible, carefully review the security issue and assess the risk.
66+
If you choose to implement countermeasures instead of upgrading, you can ignore the security advisory.
67+
Use Composer's [`config.policy.advisories.ignore-id`](https://getcomposer.org/doc/06-config.md#ignore-id) setting, providing for each entry the reason why you consider it safe to ignore.
68+
This way, you'll still be warned if the package is affected by a new security advisory.
69+
70+
```json
71+
{
72+
"config": {
73+
"policy": {
74+
"advisories": {
75+
"ignore-id": {
76+
"PKSA-fs5b-x5k4-1h39": "Description of the countermeasures you've implemented causing this one to be safe to ignore.",
77+
"PKSA-8zx5-v2nz-58pb": "Description of the countermeasures you've implemented causing this one to be safe to ignore."
78+
}
79+
}
80+
}
81+
}
82+
}
83+
```

docs/infrastructure_and_maintenance/security/security_checklist.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ When getting ready to go live with your project for the first time, or when re-l
88

99
!!! caution
1010

11-
Security is an ongoing process. After going live, you should pay attention to security advisories released via [your Service portal](https://support.ibexa.co/), or via [Security advisories](https://developers.ibexa.co/security-advisories) if you're not a subscriber.
11+
Security is an ongoing process. After going live, you should pay attention to Ibexa security advisories released via [your Service portal](https://support.ibexa.co/), or via [Security advisories](https://developers.ibexa.co/security-advisories) if you're not a subscriber.
1212

1313
## [[= product_name =]]
1414

1515
### Carefully select admin users
1616

1717
Make sure Admin users and other privileged users who have access to System Information and setup in the back end are vetted and fully trustworthy.
1818

19-
As administrator you have access to full information about the system through the `setup/system_info` policy, and also to user data, role editing, and many other critical aspects.
19+
As administrator, you have access to full information about the system through the `setup/system_info` policy, and also to user data, role editing, and many other critical aspects.
2020

2121
The users in your organization who have backend access must be kept up-to-date.
2222
Any user leaving the organization must be disabled without delay.
@@ -323,6 +323,7 @@ Those steps aren't needed when using [[= product_name_cloud =]], where the provi
323323

324324
- Run servers on a recent operating system and install security patches for dependencies.
325325
- Configure servers to alert you about security updates from vendors. Pay special attention to dependencies used by your project directly, or by PHP. The provider of the operating system usually has a service for this.
326+
- Update your Composer packages regularly. Don't underestimate [package security advisories](security_advisories.md#package-security-advisories) and update your dependencies so you can install the fixed versions. Also consider the risk of [supply chain attacks](https://en.wikipedia.org/wiki/Supply_chain_attack) which could be mitigated by adopting a policy of waiting a minimum amount of time before using new releases.
326327
- Enable [GitHub Dependabot](https://docs.github.com/en/code-security/concepts/supply-chain-security/dependabot-security-updates)
327328
to receive notifications when a security fix is released in a GitHub-hosted dependency.
328329
- If you're not using GitHub for your project, you can create a dummy project on GitHub with the same dependencies as your real project, and enable Dependabot notifications for that.

0 commit comments

Comments
 (0)