|
9 | 9 | <category term="frontpage" label="PHP.net frontpage news"/>
|
10 | 10 | <content type="xhtml">
|
11 | 11 | <div xmlns="http://www.w3.org/1999/xhtml">
|
| 12 | + <p>EDIT 2024-04-25: Clarified when a PHP application is vulnerable to this bug.</p> |
12 | 13 | <p>Recently, a bug in <strong>glibc</strong> version 2.39 and older (<a
|
13 | 14 | href="https://nvd.nist.gov/vuln/detail/CVE-2024-2961">CVE-2024-2961</a>) was uncovered
|
14 | 15 | where a buffer overflow in character set conversions <strong>to</strong>
|
15 | 16 | the ISO-2022-CN-EXT character set can result in remote code execution.
|
16 | 17 | </p>
|
17 | 18 |
|
18 |
| - <p>This specific buffer overflow in glibc is exploitable through PHP, |
19 |
| - which uses the iconv functionality in glibc to do character set |
20 |
| - conversions. Although the bug is exploitable in the context of the PHP |
21 |
| - Engine, the bug is not in PHP. It is also not directly exploitable |
22 |
| - remotely.</p> |
| 19 | + <p> |
| 20 | + This specific buffer overflow in glibc is exploitable through PHP, |
| 21 | + which exposes the iconv functionality of glibc to do character set |
| 22 | + conversions via the <a href="https://www.php.net/manual/en/function.iconv.php">iconv extension</a>. |
| 23 | + Although the bug is exploitable in the context of the PHP |
| 24 | + Engine, the bug is not in PHP. It is also not directly exploitable |
| 25 | + remotely. |
| 26 | + </p> |
| 27 | + |
| 28 | + <p> |
| 29 | + The bug is exploitable, <strong>if and only if</strong>, |
| 30 | + the PHP application calls iconv <a href="https://www.php.net/manual/en/ref.iconv.php">functions</a> |
| 31 | + or <a href="https://www.php.net/manual/en/filters.convert.php#filters.convert.iconv">filters</a> |
| 32 | + with user-supplied character sets. |
| 33 | + </p> |
| 34 | + |
| 35 | + <p> |
| 36 | + Applications are <strong>not</strong> vulnerable if: |
| 37 | + </p> |
| 38 | + |
| 39 | + <ul> |
| 40 | + <li>Glibc security updates from the distribution have been installed</li> |
| 41 | + <li>Or the iconv extension is not loaded</li> |
| 42 | + <li>Or the vulnerable character set has been removed from gconv-modules-extra.conf</li> |
| 43 | + <li>Or the application passes only specifically allowed character sets to iconv.</li> |
| 44 | + </ul> |
| 45 | + |
| 46 | + <p> |
| 47 | + Moreover, when using a user-supplied character set, |
| 48 | + it is good practice for applications to accept only |
| 49 | + specific charsets that have been explicitly allowed by the application. |
| 50 | + One example of how this can be done is by using an allow-list and the |
| 51 | + <a href="https://www.php.net/manual/en/function.array-search"><code>array_search()</code></a> function |
| 52 | + to check the encoding before passing it to iconv. |
| 53 | + For example: <code>array_search($charset, $allowed_list, true)</code> |
| 54 | + </p> |
23 | 55 |
|
24 | 56 | <p>There are numerous reports online with titles like "Mitigating the
|
25 | 57 | iconv Vulnerability for PHP (CVE-2024-2961)" or "PHP Under Attack". These
|
26 | 58 | titles are misleading as this is <strong>not</strong> a bug in PHP itself.</p>
|
27 | 59 |
|
28 |
| - <p>Currently there is no fix for this issue, but there is a workaround |
29 |
| - described in <a |
30 |
| - href="https://rockylinux.org/news/glibc-vulnerability-april-2024/">GLIBC |
31 |
| - Vulnerability on Servers Serving PHP</a>. It explains a way how to remove |
32 |
| - the problematic character set from glibc. Perform this procedure for every |
33 |
| - gconv-modules-extra.conf file that is available on your system.</p> |
| 60 | + <p> |
| 61 | + If your PHP application is vulnerable, we first recommend to check if your Linux distribution |
| 62 | + has already published patched variants of glibc. |
| 63 | + <a href="https://security-tracker.debian.org/tracker/CVE-2024-2961">Debian</a>, |
| 64 | + CentOS, and others, have already done so, and please upgrade as soon as possible. |
| 65 | + </p> |
34 | 66 |
|
35 |
| - <p>Additionally it is also good practice for applications to accept only |
36 |
| - specific charsets, with an allow-list.</p> |
| 67 | + <p>Once an update is available in glibc, updating that package on your |
| 68 | + Linux machine will be enough to alleviate the issue. You do not need to |
| 69 | + update PHP, as glibc is a dynamically linked library.</p> |
37 | 70 |
|
38 |
| - <p>Some Linux distributions such as <a |
39 |
| - href="https://security-tracker.debian.org/tracker/CVE-2024-2961">Debian</a>, |
40 |
| - CentOS, and others, already have published patched variants of glibc. |
41 |
| - Please upgrade as soon as possible.</p> |
| 71 | + <p> |
| 72 | + If your Linux distribution has not published a patched version of glibc, |
| 73 | + there is no fix for this issue. However, there exists a workaround described in |
| 74 | + <a href="https://rockylinux.org/news/glibc-vulnerability-april-2024/">GLIBC |
| 75 | + Vulnerability on Servers Serving PHP</a> which explains a way on how to remove |
| 76 | + the problematic character set from glibc. Perform this procedure for every |
| 77 | + gconv-modules-extra.conf file that is available on your system.</p> |
42 | 78 |
|
43 | 79 | <p>Once an update is available in glibc, updating that package on your
|
44 | 80 | Linux machine will be enough to alleviate the issue. You do not need to
|
45 | 81 | update PHP, as glibc is a dynamically linked library.</p>
|
46 | 82 |
|
47 |
| - <p>PHP users on Windows are not affected.</p> |
| 83 | + <p>PHP users on Windows are not affected. This is because the iconv extension is not available on Windows.</p> |
48 | 84 |
|
49 | 85 | <p>There will therefore also not be a new version of PHP for this
|
50 | 86 | vulnerability.</p>
|
|
0 commit comments