PHP vulnerability

I am in the process of rolling out the fix for the recent PHP vulnerability. So far, so good. I hope to have my websites back online soon. Sorry for the interruption.

-------------------
Thu Oct 22 03:11:44 [bash:5.2.15 jobs:0 error:0 time:1289]
root@commitment:/home/jj5
# apt update && apt-cache policy php8.2-common
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://security.debian.org/debian-security bookworm-security InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Hit:4 https://packages.broadcom.com/artifactory/saltproject-deb stable InRelease
Reading package lists... Done                          
Building dependency tree... Done
Reading state information... Done
12 packages can be upgraded. Run 'apt list --upgradable' to see them.
php8.2-common:
  Installed: 8.2.34-1~deb12u1
  Candidate: 8.2.35-1~deb12u1
  Version table:
     8.2.35-1~deb12u1 500
        500 http://security.debian.org/debian-security bookworm-security/main amd64 Packages
 *** 8.2.34-1~deb12u1 100
        100 /var/lib/dpkg/status
     8.2.32-1~deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
-------------------
Thu Oct 22 03:11:49 [bash:5.2.15 jobs:0 error:0 time:1294]
root@commitment:/home/jj5
# apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libapache2-mod-php8.2 php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-imap php8.2-intl php8.2-mbstring php8.2-mysql
  php8.2-opcache php8.2-readline php8.2-sqlite3
12 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,351 kB of archives.
After this operation, 111 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-sqlite3 amd64 8.2.35-1~deb12u1 [30.3 kB]
Get:2 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-readline amd64 8.2.35-1~deb12u1 [12.5 kB]
Get:3 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-opcache amd64 8.2.35-1~deb12u1 [346 kB]
Get:4 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-mysql amd64 8.2.35-1~deb12u1 [118 kB]
Get:5 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-mbstring amd64 8.2.35-1~deb12u1 [443 kB]
Get:6 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-intl amd64 8.2.35-1~deb12u1 [138 kB]
Get:7 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-imap amd64 8.2.35-1~deb12u1 [32.6 kB]
Get:8 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-curl amd64 8.2.35-1~deb12u1 [35.9 kB]
Get:9 http://security.debian.org/debian-security bookworm-security/main amd64 libapache2-mod-php8.2 amd64 8.2.35-1~deb12u1 [1,695 kB]
Get:10 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-cli amd64 8.2.35-1~deb12u1 [1,756 kB]
Get:11 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2-common amd64 8.2.35-1~deb12u1 [693 kB]
Get:12 http://security.debian.org/debian-security bookworm-security/main amd64 php8.2 all 8.2.35-1~deb12u1 [50.2 kB]
Fetched 5,351 kB in 1s (6,681 kB/s)
Reading changelogs... Done
(Reading database ... 233436 files and directories currently installed.)
Preparing to unpack .../00-php8.2-sqlite3_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-sqlite3 (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../01-php8.2-readline_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-readline (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../02-php8.2-opcache_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-opcache (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../03-php8.2-mysql_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-mysql (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../04-php8.2-mbstring_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-mbstring (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../05-php8.2-intl_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-intl (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../06-php8.2-imap_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-imap (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../07-php8.2-curl_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-curl (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../08-libapache2-mod-php8.2_8.2.35-1~deb12u1_amd64.deb ...
Unpacking libapache2-mod-php8.2 (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../09-php8.2-cli_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-cli (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../10-php8.2-common_8.2.35-1~deb12u1_amd64.deb ...
Unpacking php8.2-common (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Preparing to unpack .../11-php8.2_8.2.35-1~deb12u1_all.deb ...
Unpacking php8.2 (8.2.35-1~deb12u1) over (8.2.34-1~deb12u1) ...
Setting up php8.2-common (8.2.35-1~deb12u1) ...
Setting up php8.2-imap (8.2.35-1~deb12u1) ...
Setting up php8.2-mysql (8.2.35-1~deb12u1) ...
Setting up php8.2-opcache (8.2.35-1~deb12u1) ...
Setting up php8.2-readline (8.2.35-1~deb12u1) ...
Setting up php8.2-mbstring (8.2.35-1~deb12u1) ...
Setting up php8.2-intl (8.2.35-1~deb12u1) ...
Setting up php8.2-curl (8.2.35-1~deb12u1) ...
Setting up php8.2-cli (8.2.35-1~deb12u1) ...
Setting up php8.2-sqlite3 (8.2.35-1~deb12u1) ...
Setting up libapache2-mod-php8.2 (8.2.35-1~deb12u1) ...
libapache2-mod-php8.2: not switching MPM - already enabled
Setting up php8.2 (8.2.35-1~deb12u1) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for php8.2-cli (8.2.35-1~deb12u1) ...
Processing triggers for libapache2-mod-php8.2 (8.2.35-1~deb12u1) ...
Scanning processes...                                                                                                        
Scanning candidates...                                                                                                       
Scanning processor microcode...                                                                                              
Scanning linux images...                                                                                                     

Running kernel seems to be up-to-date.

The processor microcode seems to be up-to-date.

Restarting services...
 systemctl restart apache2.service libvirtd.service virtlogd.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
-------------------
Thu Oct 22 03:13:25 [bash:5.2.15 jobs:0 error:0 time:1390]
root@commitment:/home/jj5
# php -v
PHP 8.2.35 (cli) (built: Oct 21 2026 06:29:51) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.35, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.35, Copyright (c), by Zend Technologies
-------------------

Spiral

My friend sent me this:

a bunch of hardcoded print statement which spiral a counter

It pretty much forced me to write spiral.php and spiral.sh to generate this:

print('1')

print('7 8 9')
print('6 1 2')
print('5 4 3')

print('21 22 23 24 25')
print('20  7  8  9 10')
print('19  6  1  2 11')
print('18  5  4  3 12')
print('17 16 15 14 13')

print('43 44 45 46 47 48 49')
print('42 21 22 23 24 25 26')
print('41 20  7  8  9 10 27')
print('40 19  6  1  2 11 28')
print('39 18  5  4  3 12 29')
print('38 17 16 15 14 13 30')
print('37 36 35 34 33 32 31')

print('73 74 75 76 77 78 79 80 81')
print('72 43 44 45 46 47 48 49 50')
print('71 42 21 22 23 24 25 26 51')
print('70 41 20  7  8  9 10 27 52')
print('69 40 19  6  1  2 11 28 53')
print('68 39 18  5  4  3 12 29 54')
print('67 38 17 16 15 14 13 30 55')
print('66 37 36 35 34 33 32 31 56')
print('65 64 63 62 61 60 59 58 57')

print('111 112 113 114 115 116 117 118 119 120 121')
print('110  73  74  75  76  77  78  79  80  81  82')
print('109  72  43  44  45  46  47  48  49  50  83')
print('108  71  42  21  22  23  24  25  26  51  84')
print('107  70  41  20   7   8   9  10  27  52  85')
print('106  69  40  19   6   1   2  11  28  53  86')
print('105  68  39  18   5   4   3  12  29  54  87')
print('104  67  38  17  16  15  14  13  30  55  88')
print('103  66  37  36  35  34  33  32  31  56  89')
print('102  65  64  63  62  61  60  59  58  57  90')
print('101 100  99  98  97  96  95  94  93  92  91')

print('157 158 159 160 161 162 163 164 165 166 167 168 169')
print('156 111 112 113 114 115 116 117 118 119 120 121 122')
print('155 110  73  74  75  76  77  78  79  80  81  82 123')
print('154 109  72  43  44  45  46  47  48  49  50  83 124')
print('153 108  71  42  21  22  23  24  25  26  51  84 125')
print('152 107  70  41  20   7   8   9  10  27  52  85 126')
print('151 106  69  40  19   6   1   2  11  28  53  86 127')
print('150 105  68  39  18   5   4   3  12  29  54  87 128')
print('149 104  67  38  17  16  15  14  13  30  55  88 129')
print('148 103  66  37  36  35  34  33  32  31  56  89 130')
print('147 102  65  64  63  62  61  60  59  58  57  90 131')
print('146 101 100  99  98  97  96  95  94  93  92  91 132')
print('145 144 143 142 141 140 139 138 137 136 135 134 133')

print('211 212 213 214 215 216 217 218 219 220 221 222 223 224 225')
print('210 157 158 159 160 161 162 163 164 165 166 167 168 169 170')
print('209 156 111 112 113 114 115 116 117 118 119 120 121 122 171')
print('208 155 110  73  74  75  76  77  78  79  80  81  82 123 172')
print('207 154 109  72  43  44  45  46  47  48  49  50  83 124 173')
print('206 153 108  71  42  21  22  23  24  25  26  51  84 125 174')
print('205 152 107  70  41  20   7   8   9  10  27  52  85 126 175')
print('204 151 106  69  40  19   6   1   2  11  28  53  86 127 176')
print('203 150 105  68  39  18   5   4   3  12  29  54  87 128 177')
print('202 149 104  67  38  17  16  15  14  13  30  55  88 129 178')
print('201 148 103  66  37  36  35  34  33  32  31  56  89 130 179')
print('200 147 102  65  64  63  62  61  60  59  58  57  90 131 180')
print('199 146 101 100  99  98  97  96  95  94  93  92  91 132 181')
print('198 145 144 143 142 141 140 139 138 137 136 135 134 133 182')
print('197 196 195 194 193 192 191 190 189 188 187 186 185 184 183')

PHP shutdown handlers and exit codes

I was in bed trying to get to sleep but my brain wanted to know the answer to this question. So I was forced out of bed to write this experiment:

function main( $argv ) {

  register_shutdown_function( 'shutdown_1' );
  register_shutdown_function( 'shutdown_2' );

  exit( 0 );

}

function shutdown_1() {

  exit( 1 );

}

function shutdown_2() {

  exit( 2 );

}

main( $argv );

With this PHP code, what do you expect is the resultant error level?

The answer is ‘1’. After main() calls exit( 0 ) the shutdown function shutdown_1() is invoked. When shutdown_1() calls exit( 1 ) the process exists and shutdown_2() is never called.

I’m glad we cleared that up. Back to bed.