Repository navigation
Expand file tree
/
Copy pathphp2shell-check.sh
More file actions
executable file
·1056 lines (1036 loc) · 42 KB
/
Copy pathphp2shell-check.sh
File metadata and controls
executable file
·1056 lines (1036 loc) · 42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# PHP2Shell package checker. Runtime: Bash >= 4.2 and standard Unix tools.
if ((BASH_VERSINFO[0] < 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 2))); then
printf '%s\n' 'php2shell-check requires Bash 4.2 or newer.' >&2
exit 2
fi
export LC_ALL=C
# BEGIN GENERATED RULES
# Generated by tools/gen-rules.py; edit data/php2shell-data.json instead.
UPDATED="2026-10-30"
MIN_AFFECTED="5.4.0"
declare -A FIXED_UPSTREAM=() RULE_FIXED=() GPS_BRANCH=()
FIXED_UPSTREAM["8.2"]="8.2.35"
FIXED_UPSTREAM["8.3"]="8.3.36"
FIXED_UPSTREAM["8.4"]="8.4.27"
FIXED_UPSTREAM["8.5"]="8.5.12"
declare -a R_ID=()
declare -a R_VENDOR=()
declare -a R_TYPE=()
declare -a R_NAME=()
declare -a R_RELEASE=()
declare -a R_UPSTREAM=()
declare -a R_VERDICT=()
declare -a R_MODE=()
declare -a R_NOTE=()
declare -a R_EOL_NOTE=()
declare -a R_FIX=()
R_ID[0]="gps-el7-scl"
R_VENDOR[0]="GetPageSpeed (CentOS 7, software collection)"
R_TYPE[0]="rpm"
R_NAME[0]="^php(54|56|70|71|72|73|74|80|81|82|83|84|85)-php(-[a-z0-9_-]+)?\$"
R_RELEASE[0]="^[0-9]+\\.el7\$"
R_UPSTREAM[0]=""
R_VERDICT[0]=""
R_MODE[0]=""
R_NOTE[0]=""
R_EOL_NOTE[0]=""
R_FIX[0]="yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum upgrade '{scl}-php*'
systemctl restart {scl}-php-fpm"
RULE_FIXED["0|5.4.45"]="5.4.45-20.el7"
RULE_FIXED["0|5.6.40"]="5.6.40-43.el7"
RULE_FIXED["0|7.0.33"]="7.0.33-45.el7"
RULE_FIXED["0|7.1.33"]="7.1.33-35.el7"
RULE_FIXED["0|7.2.34"]="7.2.34-30.el7"
RULE_FIXED["0|7.3.33"]="7.3.33-23.el7"
RULE_FIXED["0|7.4.33"]="7.4.33-32.el7"
RULE_FIXED["0|8.0.30"]="8.0.30-24.el7"
RULE_FIXED["0|8.1"]="8.1.34-7.el7"
RULE_FIXED["0|8.2"]="8.2.35-2.el7"
RULE_FIXED["0|8.3"]="8.3.36-2.el7"
RULE_FIXED["0|8.4"]="8.4.27-3.el7"
RULE_FIXED["0|8.5"]="8.5.12-1.el7"
R_ID[1]="gps-el7-base"
R_VENDOR[1]="GetPageSpeed (CentOS 7)"
R_TYPE[1]="rpm"
R_NAME[1]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[1]="^[0-9]+\\.el7\$"
R_UPSTREAM[1]=""
R_VERDICT[1]=""
R_MODE[1]=""
R_NOTE[1]=""
R_EOL_NOTE[1]=""
R_FIX[1]="yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum --enablerepo=getpagespeed-extras-php{nodot} upgrade 'php-*'
systemctl restart php-fpm"
RULE_FIXED["1|5.4.45"]="5.4.45-20.el7"
RULE_FIXED["1|5.6.40"]="5.6.40-42.el7"
RULE_FIXED["1|7.0.33"]="7.0.33-43.el7"
RULE_FIXED["1|7.1.33"]="7.1.33-35.el7"
RULE_FIXED["1|7.2.34"]="7.2.34-30.el7"
RULE_FIXED["1|7.3.33"]="7.3.33-25.el7"
RULE_FIXED["1|7.4.33"]="7.4.33-33.el7"
RULE_FIXED["1|8.0.30"]="8.0.30-22.el7"
RULE_FIXED["1|8.1"]="8.1.34-7.el7"
RULE_FIXED["1|8.2"]="8.2.35-2.el7"
RULE_FIXED["1|8.3"]="8.3.36-2.el7"
RULE_FIXED["1|8.4"]="8.4.27-1.el7"
RULE_FIXED["1|8.5"]="8.5.12-1.el7"
R_ID[2]="gps-el6-base"
R_VENDOR[2]="GetPageSpeed (CentOS 6)"
R_TYPE[2]="rpm"
R_NAME[2]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[2]="^[0-9]+\\.el6\$"
R_UPSTREAM[2]=""
R_VERDICT[2]=""
R_MODE[2]=""
R_NOTE[2]=""
R_EOL_NOTE[2]=""
R_FIX[2]="yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum --enablerepo=getpagespeed-extras-php{nodot} upgrade 'php*'
service php-fpm restart; service httpd restart"
RULE_FIXED["2|5.3.3"]="5.3.3-51.el6"
RULE_FIXED["2|7.0.33"]="7.0.33-49.el6"
RULE_FIXED["2|7.1.33"]="7.1.33-40.el6"
R_ID[3]="remi-el7"
R_VENDOR[3]="Remi (CentOS 7)"
R_TYPE[3]="rpm"
R_NAME[3]="^(php(54|56|70|71|72|73|74|80|81|82|83)-)?php(-[a-z0-9_-]+)?\$"
R_RELEASE[3]="\\.el7\\.remi\$"
R_UPSTREAM[3]=""
R_VERDICT[3]="vulnerable"
R_MODE[3]=""
R_NOTE[3]="Remi stopped building for CentOS 7 in June 2024, so every Remi EL7 build predates the fix."
R_EOL_NOTE[3]=""
R_FIX[3]="# No patched Remi build exists for CentOS 7. Move to the GetPageSpeed PHP 8.4 stack:
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum-config-manager --enable getpagespeed-extras-php84
yum install php84-getpagespeed-stack"
GPS_BRANCH["3|5.4"]="gps-el7"
GPS_BRANCH["3|5.6"]="gps-el7"
GPS_BRANCH["3|7.0"]="gps-el7"
GPS_BRANCH["3|7.1"]="gps-el7"
GPS_BRANCH["3|7.2"]="gps-el7"
GPS_BRANCH["3|7.3"]="gps-el7"
GPS_BRANCH["3|7.4"]="gps-el7"
GPS_BRANCH["3|8.0"]="gps-el7"
GPS_BRANCH["3|8.1"]="gps-el7"
GPS_BRANCH["3|8.2"]="gps-el7"
GPS_BRANCH["3|8.3"]="gps-el7"
R_ID[4]="centos7-base"
R_VENDOR[4]="CentOS 7 base"
R_TYPE[4]="rpm"
R_NAME[4]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[4]="^[0-9]+\\.el7(_[0-9]+)?(\\.centos)?\$"
R_UPSTREAM[4]="^5\\.4\\."
R_VERDICT[4]="vulnerable"
R_MODE[4]=""
R_NOTE[4]="CentOS 7 is end-of-life and its stock PHP 5.4.16 will never get this fix from CentOS. The GetPageSpeed main repository replaces it in place with a patched 5.4.45 (same package names, extensions and ionCube keep working), so a plain yum update applies it."
R_EOL_NOTE[4]=""
R_FIX[4]="yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum upgrade php 'php-*'
systemctl restart httpd php-fpm"
R_ID[5]="centos6-base"
R_VENDOR[5]="CentOS 6 base"
R_TYPE[5]="rpm"
R_NAME[5]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[5]="^[0-9]+\\.el6(_[0-9]+)?(\\.centos)?\$"
R_UPSTREAM[5]="^5\\.3\\."
R_VERDICT[5]="vulnerable"
R_MODE[5]=""
R_NOTE[5]="CentOS 6 is end-of-life and its stock PHP 5.3.3 will never get this fix. The GetPageSpeed base repository replaces it in place with a patched 5.3.3 (same package names and extensions)."
R_EOL_NOTE[5]=""
R_FIX[5]="yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum upgrade 'php*'
service php-fpm restart; service httpd restart"
R_ID[6]="remi-el8plus-eol"
R_VENDOR[6]="Remi (EL8 and newer)"
R_TYPE[6]="rpm"
R_NAME[6]="^(php[0-9][0-9]-)?php(-[a-z0-9_-]+)?\$"
R_RELEASE[6]="\\.el(8|9|10)(_[0-9]+)?\\.remi\$|module_php\\.[0-9.]+\\.el[0-9]+\\.remi\$"
R_UPSTREAM[6]=""
R_VERDICT[6]=""
R_MODE[6]=""
R_NOTE[6]=""
R_EOL_NOTE[6]=""
R_FIX[6]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
RULE_FIXED["6|7.4.33"]="7.4.33-31"
RULE_FIXED["6|8.0.30"]="8.0.30-21"
R_ID[7]="remi-el8plus"
R_VENDOR[7]="Remi (EL8 and newer)"
R_TYPE[7]="rpm"
R_NAME[7]="^(php[0-9][0-9]-)?php(-[a-z0-9_-]+)?\$"
R_RELEASE[7]="\\.el(8|9|10)(_[0-9]+)?\\.remi\$|module_php\\.[0-9.]+\\.el[0-9]+\\.remi\$"
R_UPSTREAM[7]=""
R_VERDICT[7]=""
R_MODE[7]="upstream"
R_NOTE[7]=""
R_EOL_NOTE[7]="Remi has not published a PHP2Shell backport for this branch. Check rpm -q --changelog for CVE-2026-109618, or move to PHP 8.2 or newer."
R_FIX[7]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
R_ID[8]="rhel8-php74"
R_VENDOR[8]="RHEL 8, AlmaLinux 8, Rocky 8 (php:7.4)"
R_TYPE[8]="rpm"
R_NAME[8]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[8]="module[+_]el8\\.10"
R_UPSTREAM[8]=""
R_VERDICT[8]=""
R_MODE[8]=""
R_NOTE[8]=""
R_EOL_NOTE[8]=""
R_FIX[8]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
RULE_FIXED["8|7.4.33"]="7.4.33-8"
R_ID[9]="rhel88-e4s-php74"
R_VENDOR[9]="RHEL 8.8 E4S/TUS (php:7.4)"
R_TYPE[9]="rpm"
R_NAME[9]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[9]="module\\+el8\\.8\\.0"
R_UPSTREAM[9]=""
R_VERDICT[9]=""
R_MODE[9]=""
R_NOTE[9]=""
R_EOL_NOTE[9]=""
R_FIX[9]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
RULE_FIXED["9|7.4.33"]="7.4.33-1.module+el8.8.0+25148+55cf9df9.2"
R_ID[10]="rhel86-aus-php74"
R_VENDOR[10]="RHEL 8.6 AUS (php:7.4)"
R_TYPE[10]="rpm"
R_NAME[10]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[10]="module\\+el8\\.6\\.0"
R_UPSTREAM[10]=""
R_VERDICT[10]=""
R_MODE[10]=""
R_NOTE[10]=""
R_EOL_NOTE[10]=""
R_FIX[10]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
RULE_FIXED["10|7.4.19"]="7.4.19-4.module+el8.6.0+25157+c2ff122e.3"
R_ID[11]="rhel9-php80"
R_VENDOR[11]="RHEL 9, AlmaLinux 9, Rocky 9 (base php 8.0)"
R_TYPE[11]="rpm"
R_NAME[11]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[11]="^[0-9]+\\.el9(_[0-9]+)?(\\.[0-9]+)?\$"
R_UPSTREAM[11]=""
R_VERDICT[11]=""
R_MODE[11]=""
R_NOTE[11]=""
R_EOL_NOTE[11]=""
R_FIX[11]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
RULE_FIXED["11|8.0.30"]="8.0.30-8.el9_8.1"
R_ID[12]="rhel9-php84-module"
R_VENDOR[12]="RHEL 9 (php:8.4 module)"
R_TYPE[12]="rpm"
R_NAME[12]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[12]="module[+_]el9"
R_UPSTREAM[12]="^8\\.4\\.([0-9]|1[0-9]|2[0-6])\$"
R_VERDICT[12]="vulnerable"
R_MODE[12]=""
R_NOTE[12]="On October 23, 2026 Red Hat still listed the php:8.4 stream on RHEL 9 as affected with no fix available. Switch to the fixed php:8.3 stream or watch dnf updateinfo list --cve CVE-2026-109618."
R_EOL_NOTE[12]=""
R_FIX[12]="sudo dnf module switch-to php:8.3
sudo systemctl restart php-fpm httpd"
R_ID[13]="rhel-family"
R_VENDOR[13]="RHEL, AlmaLinux, Rocky, Oracle Linux"
R_TYPE[13]="rpm"
R_NAME[13]="^php(8\\.[0-9])?(-[a-z0-9_-]+)?\$"
R_RELEASE[13]="\\.(module[+_])?el(8|9|10)"
R_UPSTREAM[13]=""
R_VERDICT[13]=""
R_MODE[13]="upstream"
R_NOTE[13]=""
R_EOL_NOTE[13]="Red Hat's advisories cover only some streams of this branch. Ask dnf directly: dnf updateinfo list --cve CVE-2026-109618"
R_FIX[13]="sudo dnf upgrade 'php*'
sudo systemctl restart php-fpm httpd"
R_ID[14]="cloudlinux-ea-php-el7"
R_VENDOR[14]="CloudLinux ea-php for cPanel (CloudLinux 7)"
R_TYPE[14]="rpm"
R_NAME[14]="^ea-php[0-9][0-9]-php(-[a-z0-9_-]+)?\$"
R_RELEASE[14]="\\.el7\\.cloudlinux"
R_UPSTREAM[14]=""
R_VERDICT[14]=""
R_MODE[14]=""
R_NOTE[14]="CloudLinux backports the fix and keeps a lower PHP version number than php.net. Its builds come from the cl-ea4 repository, which must be enabled next to the cPanel EA4 repository."
R_EOL_NOTE[14]=""
R_FIX[14]="yum clean all && yum update 'ea-php*'
/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd"
RULE_FIXED["14|5.2"]="5.2.17-27.el7.cloudlinux.67"
RULE_FIXED["14|5.3"]="5.3.29-29.el7.cloudlinux.69"
RULE_FIXED["14|5.4"]="5.4.45-82.el7.cloudlinux.9"
RULE_FIXED["14|5.5"]="5.5.38-64.el7.cloudlinux.10"
RULE_FIXED["14|5.6"]="5.6.40-25.el7.cloudlinux.18"
RULE_FIXED["14|7.0"]="7.0.33-29.el7.cloudlinux.17"
RULE_FIXED["14|7.1"]="7.1.33-20.el7.cloudlinux.17"
RULE_FIXED["14|7.2"]="7.2.34-12.el7.cloudlinux.18"
RULE_FIXED["14|7.3"]="7.3.33-15.el7.cloudlinux.18"
RULE_FIXED["14|7.4"]="7.4.33-18.el7.cloudlinux.13"
RULE_FIXED["14|8.0"]="8.0.30-11.el7.cloudlinux.1"
RULE_FIXED["14|8.1"]="8.1.34-4.el7.cloudlinux.1"
RULE_FIXED["14|8.2"]="8.2.34-2.el7.cloudlinux.1"
RULE_FIXED["14|8.3"]="8.3.35-2.el7.cloudlinux.2"
RULE_FIXED["14|8.4"]="8.4.26-2.el7.cloudlinux.1"
RULE_FIXED["14|8.5"]="8.5.11-2.el7.cloudlinux.1"
R_ID[15]="cloudlinux-ea-php-el8"
R_VENDOR[15]="CloudLinux ea-php for cPanel (CloudLinux 8)"
R_TYPE[15]="rpm"
R_NAME[15]="^ea-php[0-9][0-9]-php(-[a-z0-9_-]+)?\$"
R_RELEASE[15]="\\.el8\\.cloudlinux"
R_UPSTREAM[15]=""
R_VERDICT[15]=""
R_MODE[15]=""
R_NOTE[15]="CloudLinux backports the fix and keeps a lower PHP version number than php.net. Its builds come from the cl-ea4 repository, which must be enabled next to the cPanel EA4 repository."
R_EOL_NOTE[15]=""
R_FIX[15]="dnf clean all && dnf update 'ea-php*'
/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd"
RULE_FIXED["15|5.2"]="5.2.17-27.el8.cloudlinux.67"
RULE_FIXED["15|5.3"]="5.3.29-29.el8.cloudlinux.69"
RULE_FIXED["15|5.4"]="5.4.45-82.el8.cloudlinux.9"
RULE_FIXED["15|5.5"]="5.5.38-64.el8.cloudlinux.10"
RULE_FIXED["15|5.6"]="5.6.40-25.el8.cloudlinux.18"
RULE_FIXED["15|7.0"]="7.0.33-29.el8.cloudlinux.17"
RULE_FIXED["15|7.1"]="7.1.33-20.el8.cloudlinux.17"
RULE_FIXED["15|7.2"]="7.2.34-12.el8.cloudlinux.18"
RULE_FIXED["15|7.3"]="7.3.33-15.el8.cloudlinux.18"
RULE_FIXED["15|7.4"]="7.4.33-18.el8.cloudlinux.13"
RULE_FIXED["15|8.0"]="8.0.30-11.el8.cloudlinux.1"
RULE_FIXED["15|8.1"]="8.1.34-4.el8.cloudlinux.1"
RULE_FIXED["15|8.2"]="8.2.34-2.el8.cloudlinux.1"
RULE_FIXED["15|8.3"]="8.3.35-2.el8.cloudlinux.2"
RULE_FIXED["15|8.4"]="8.4.26-2.el8.cloudlinux.1"
RULE_FIXED["15|8.5"]="8.5.11-2.el8.cloudlinux.1"
R_ID[16]="cloudlinux-ea-php-el9"
R_VENDOR[16]="CloudLinux ea-php for cPanel (CloudLinux 9)"
R_TYPE[16]="rpm"
R_NAME[16]="^ea-php[0-9][0-9]-php(-[a-z0-9_-]+)?\$"
R_RELEASE[16]="\\.el9\\.cloudlinux"
R_UPSTREAM[16]=""
R_VERDICT[16]=""
R_MODE[16]=""
R_NOTE[16]="CloudLinux backports the fix and keeps a lower PHP version number than php.net. Its builds come from the cl-ea4 repository, which must be enabled next to the cPanel EA4 repository."
R_EOL_NOTE[16]=""
R_FIX[16]="dnf clean all && dnf update 'ea-php*'
/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd"
RULE_FIXED["16|5.2"]="5.2.17-27.el9.cloudlinux.67"
RULE_FIXED["16|5.3"]="5.3.29-29.el9.cloudlinux.69"
RULE_FIXED["16|5.4"]="5.4.45-82.el9.cloudlinux.9"
RULE_FIXED["16|5.5"]="5.5.38-64.el9.cloudlinux.10"
RULE_FIXED["16|5.6"]="5.6.40-25.el9.cloudlinux.18"
RULE_FIXED["16|7.0"]="7.0.33-29.el9.cloudlinux.17"
RULE_FIXED["16|7.1"]="7.1.33-20.el9.cloudlinux.17"
RULE_FIXED["16|7.2"]="7.2.34-12.el9.cloudlinux.18"
RULE_FIXED["16|7.3"]="7.3.33-15.el9.cloudlinux.18"
RULE_FIXED["16|7.4"]="7.4.33-18.el9.cloudlinux.13"
RULE_FIXED["16|8.0"]="8.0.30-11.el9.cloudlinux.1"
RULE_FIXED["16|8.1"]="8.1.34-4.el9.cloudlinux.1"
RULE_FIXED["16|8.2"]="8.2.34-2.el9.cloudlinux.1"
RULE_FIXED["16|8.3"]="8.3.35-2.el9.cloudlinux.2"
RULE_FIXED["16|8.4"]="8.4.26-2.el9.cloudlinux.1"
RULE_FIXED["16|8.5"]="8.5.11-2.el9.cloudlinux.1"
R_ID[17]="cloudlinux-ea-php-el10"
R_VENDOR[17]="CloudLinux ea-php for cPanel (CloudLinux 10)"
R_TYPE[17]="rpm"
R_NAME[17]="^ea-php[0-9][0-9]-php(-[a-z0-9_-]+)?\$"
R_RELEASE[17]="\\.el10\\.cloudlinux"
R_UPSTREAM[17]=""
R_VERDICT[17]=""
R_MODE[17]=""
R_NOTE[17]="CloudLinux backports the fix and keeps a lower PHP version number than php.net. Its builds come from the cl-ea4 repository, which must be enabled next to the cPanel EA4 repository."
R_EOL_NOTE[17]=""
R_FIX[17]="dnf clean all && dnf update 'ea-php*'
/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd"
RULE_FIXED["17|5.2"]="5.2.17-27.el10.cloudlinux.67"
RULE_FIXED["17|5.3"]="5.3.29-29.el10.cloudlinux.69"
RULE_FIXED["17|5.4"]="5.4.45-82.el10.cloudlinux.9"
RULE_FIXED["17|5.5"]="5.5.38-64.el10.cloudlinux.10"
RULE_FIXED["17|5.6"]="5.6.40-25.el10.cloudlinux.18"
RULE_FIXED["17|7.0"]="7.0.33-29.el10.cloudlinux.17"
RULE_FIXED["17|7.1"]="7.1.33-20.el10.cloudlinux.17"
RULE_FIXED["17|7.2"]="7.2.34-12.el10.cloudlinux.18"
RULE_FIXED["17|7.3"]="7.3.33-15.el10.cloudlinux.18"
RULE_FIXED["17|7.4"]="7.4.33-18.el10.cloudlinux.13"
RULE_FIXED["17|8.0"]="8.0.30-11.el10.cloudlinux.1"
RULE_FIXED["17|8.1"]="8.1.34-4.el10.cloudlinux.1"
RULE_FIXED["17|8.2"]="8.2.34-2.el10.cloudlinux.1"
RULE_FIXED["17|8.3"]="8.3.35-2.el10.cloudlinux.2"
RULE_FIXED["17|8.4"]="8.4.26-2.el10.cloudlinux.1"
RULE_FIXED["17|8.5"]="8.5.11-2.el10.cloudlinux.1"
R_ID[18]="cpanel-ea-php"
R_VENDOR[18]="cPanel EasyApache 4"
R_TYPE[18]="rpm"
R_NAME[18]="^ea-php[0-9][0-9]-php(-[a-z0-9_-]+)?\$"
R_RELEASE[18]="\\.cpanel\$"
R_UPSTREAM[18]=""
R_VERDICT[18]=""
R_MODE[18]=""
R_NOTE[18]="cPanel backported the fix to ea-php74, ea-php80 and ea-php81 in EasyApache 4 25.91 without changing the PHP version number. The cPanel and WHM version says nothing about ea-php: check the ea-php package itself."
R_EOL_NOTE[18]=""
R_FIX[18]="yum update 'ea-php*'
/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd"
RULE_FIXED["18|7.4"]="7.4.33-19"
RULE_FIXED["18|8.0"]="8.0.30-12"
RULE_FIXED["18|8.1"]="8.1.34-5"
RULE_FIXED["18|8.2"]="8.2.35"
RULE_FIXED["18|8.3"]="8.3.36"
RULE_FIXED["18|8.4"]="8.4.27"
RULE_FIXED["18|8.5"]="8.5.12"
R_ID[19]="cpanel-ea-php-eol"
R_VENDOR[19]="cPanel EasyApache 4"
R_TYPE[19]="rpm"
R_NAME[19]="^ea-php(5[0-9]|7[0-3])-php(-[a-z0-9_-]+)?\$"
R_RELEASE[19]="\\.cpanel\$"
R_UPSTREAM[19]=""
R_VERDICT[19]="vulnerable"
R_MODE[19]=""
R_NOTE[19]="cPanel patched only ea-php74 and newer. Its ea-php5x to ea-php73 builds will not get this fix."
R_EOL_NOTE[19]=""
R_FIX[19]="# Move every site on this version to a patched one (ea-php82 or newer) in
# WHM > MultiPHP Manager, then remove it:
yum remove '{pkg}'"
R_ID[20]="cloudlinux-alt-php"
R_VENDOR[20]="CloudLinux alt-php"
R_TYPE[20]="rpm"
R_NAME[20]="^alt-php[0-9][0-9](-[a-z0-9_-]+)?\$"
R_RELEASE[20]="\\.el[789]"
R_UPSTREAM[20]=""
R_VERDICT[20]=""
R_MODE[20]=""
R_NOTE[20]="CloudLinux backports the fix into every alt-php branch, so the PHP version can stay below the php.net release."
R_EOL_NOTE[20]=""
R_FIX[20]="yum clean all && yum update 'alt-php*'
# then restart Apache, PHP-FPM or LiteSpeed (pkill lsphp)"
RULE_FIXED["20|5.2"]="5.2.17-242"
RULE_FIXED["20|5.3"]="5.3.29-220"
RULE_FIXED["20|5.4"]="5.4.45-203"
RULE_FIXED["20|5.5"]="5.5.38-183"
RULE_FIXED["20|5.6"]="5.6.40-147"
RULE_FIXED["20|7.0"]="7.0.33-148"
RULE_FIXED["20|7.1"]="7.1.33-114"
RULE_FIXED["20|7.2"]="7.2.34-97"
RULE_FIXED["20|7.3"]="7.3.33-82"
RULE_FIXED["20|7.4"]="7.4.33-81"
RULE_FIXED["20|8.0"]="8.0.30-69"
RULE_FIXED["20|8.1"]="8.1.34-39"
RULE_FIXED["20|8.2"]="8.2.34-7"
RULE_FIXED["20|8.3"]="8.3.35-6"
RULE_FIXED["20|8.4"]="8.4.26-5"
RULE_FIXED["20|8.5"]="8.5.11-5"
R_ID[21]="gps-amzn2-scl"
R_VENDOR[21]="GetPageSpeed (Amazon Linux 2, software collection)"
R_TYPE[21]="rpm"
R_NAME[21]="^php72-php(-[a-z0-9_-]+)?\$"
R_RELEASE[21]="^[0-9]+\\.amzn2\$"
R_UPSTREAM[21]=""
R_VERDICT[21]=""
R_MODE[21]=""
R_NOTE[21]=""
R_EOL_NOTE[21]=""
R_FIX[21]="sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y update getpagespeed-extras-release
sudo amazon-linux-extras install -y epel
sudo yum upgrade 'php72-php*'
sudo systemctl restart php72-php-fpm
# Details: https://www.getpagespeed.com/server-setup/php/php2shell-on-amazon-linux-2"
RULE_FIXED["21|7.2"]="7.2.34-33.amzn2"
R_ID[22]="gps-amzn2"
R_VENDOR[22]="Amazon Linux 2, PHP 7.2"
R_TYPE[22]="rpm"
R_NAME[22]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[22]="^[0-9]+\\.amzn2\$"
R_UPSTREAM[22]="^7\\.2\\."
R_VERDICT[22]=""
R_MODE[22]=""
R_NOTE[22]="AWS has no fix for the php7.2 extras topic. The GetPageSpeed 7.2.34-33.amzn2 build upgrades it in place. Free to install; commercial production use requires GetPageSpeed Ultra, or GetPageSpeed Fleet for servers that host client websites."
R_EOL_NOTE[22]=""
R_FIX[22]="sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y update getpagespeed-extras-release
sudo amazon-linux-extras install -y epel
sudo yum --enablerepo=getpagespeed-extras-php72 upgrade 'php-*'
sudo systemctl restart php-fpm
# Details: https://www.getpagespeed.com/server-setup/php/php2shell-on-amazon-linux-2"
RULE_FIXED["22|7.2"]="7.2.34-33.amzn2"
R_ID[23]="gps-amzn2-php74-scl"
R_VENDOR[23]="GetPageSpeed (Amazon Linux 2, software collection)"
R_TYPE[23]="rpm"
R_NAME[23]="^php74-php(-[a-z0-9_-]+)?\$"
R_RELEASE[23]="^[0-9]+\\.amzn2\$"
R_UPSTREAM[23]=""
R_VERDICT[23]=""
R_MODE[23]=""
R_NOTE[23]=""
R_EOL_NOTE[23]=""
R_FIX[23]="sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y update getpagespeed-extras-release
sudo amazon-linux-extras install -y epel
sudo yum upgrade 'php74-php*'
sudo systemctl restart php74-php-fpm
# Details: https://www.getpagespeed.com/server-setup/php/php2shell-on-amazon-linux-2"
RULE_FIXED["23|7.4"]="7.4.33-40.amzn2"
R_ID[24]="gps-amzn2-php74"
R_VENDOR[24]="Amazon Linux 2, PHP 7.4"
R_TYPE[24]="rpm"
R_NAME[24]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[24]="^[0-9]+\\.amzn2\$"
R_UPSTREAM[24]="^7\\.4\\."
R_VERDICT[24]=""
R_MODE[24]=""
R_NOTE[24]="AWS has no fix for the php7.4 extras topic. The GetPageSpeed 7.4.33-40.amzn2 build upgrades it in place, and is a drop-in upgrade for Remi's remi-php74 packages. Free to install; commercial production use requires GetPageSpeed Ultra, or GetPageSpeed Fleet for servers that host client websites."
R_EOL_NOTE[24]=""
R_FIX[24]="sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y update getpagespeed-extras-release
sudo amazon-linux-extras install -y epel
sudo yum --enablerepo=getpagespeed-extras-php74 upgrade 'php-*'
sudo systemctl restart php-fpm
# Details: https://www.getpagespeed.com/server-setup/php/php2shell-on-amazon-linux-2"
RULE_FIXED["24|7.4"]="7.4.33-40.amzn2"
R_ID[25]="amazon-2-eol"
R_VENDOR[25]="Amazon Linux 2"
R_TYPE[25]="rpm"
R_NAME[25]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[25]="\\.amzn2(\\.|\$)"
R_UPSTREAM[25]="^(5|7|8\\.[01])\\."
R_VERDICT[25]="vulnerable"
R_MODE[25]=""
R_NOTE[25]="AWS fixed only the php8.2 extras topic on Amazon Linux 2. Core PHP 5.4 is \"No Fix Planned\" and the php7.3 to php8.1 topics have no fix."
R_EOL_NOTE[25]=""
R_FIX[25]="# AWS ships no fix for this PHP on Amazon Linux 2. Move to the fixed php8.2
# extras topic, or ask GetPageSpeed for a patched build of this version:
# https://www.getpagespeed.com/server-setup/php/php2shell-on-amazon-linux-2"
R_ID[26]="amazon-2"
R_VENDOR[26]="Amazon Linux 2"
R_TYPE[26]="rpm"
R_NAME[26]="^php(-[a-z0-9_-]+)?\$"
R_RELEASE[26]="\\.amzn2(\\.|\$)"
R_UPSTREAM[26]=""
R_VERDICT[26]=""
R_MODE[26]="upstream"
R_NOTE[26]=""
R_EOL_NOTE[26]="AWS fixed only the php8.2 extras topic on Amazon Linux 2 (ALAS2PHP8.2-2026-015)."
R_FIX[26]="sudo yum update 'php*'
sudo systemctl restart php-fpm httpd"
R_ID[27]="amazon-2023"
R_VENDOR[27]="Amazon Linux 2023"
R_TYPE[27]="rpm"
R_NAME[27]="^php8\\.[0-9](-[a-z0-9_-]+)?\$"
R_RELEASE[27]="amzn2023"
R_UPSTREAM[27]=""
R_VERDICT[27]=""
R_MODE[27]="upstream"
R_NOTE[27]=""
R_EOL_NOTE[27]="Amazon Linux 2023 fixed php8.2 to php8.5 only."
R_FIX[27]="sudo dnf upgrade --releasever=latest 'php*'
sudo systemctl restart php-fpm httpd"
R_ID[28]="gps-deb"
R_VENDOR[28]="GetPageSpeed (Ubuntu 20.04/18.04, Debian 10)"
R_TYPE[28]="deb"
R_NAME[28]="^(php[0-9]\\.[0-9]|libapache2-mod-php[0-9]\\.[0-9])(-[a-z0-9_-]+)?\$"
R_RELEASE[28]="\\+gps[0-9]+\\+"
R_UPSTREAM[28]=""
R_VERDICT[28]=""
R_MODE[28]=""
R_NOTE[28]="Free to install; commercial production use requires GetPageSpeed Ultra, or GetPageSpeed Fleet for servers that host client websites."
R_EOL_NOTE[28]=""
R_FIX[28]="wget https://extras.getpagespeed.com/release-latest.deb
sudo apt install ./release-latest.deb
sudo apt update && sudo apt upgrade 'php{branch}-*'
sudo systemctl restart php{branch}-fpm"
RULE_FIXED["28|7.2.34"]="7.2.34-66+gps1"
RULE_FIXED["28|7.3.33"]="7.3.33-35+gps1"
RULE_FIXED["28|7.4.33"]="7.4.33-31+gps1"
RULE_FIXED["28|8.0.30"]="8.0.30-25+gps1"
RULE_FIXED["28|8.1.34"]="8.1.34-9+gps1"
RULE_FIXED["28|8.2.35"]="8.2.35-1+gps1"
RULE_FIXED["28|8.3.36"]="8.3.36-1+gps1"
RULE_FIXED["28|8.4.27"]="8.4.27-1+gps1"
R_ID[29]="ubuntu"
R_VENDOR[29]="Ubuntu"
R_TYPE[29]="deb"
R_NAME[29]="^(php[0-9](\\.[0-9])?|libapache2-mod-php[0-9](\\.[0-9])?)(-[a-z0-9_-]+)?\$"
R_RELEASE[29]="ubuntu"
R_UPSTREAM[29]=""
R_VERDICT[29]=""
R_MODE[29]=""
R_NOTE[29]="Ubuntu backports the fix and keeps the original PHP version number."
R_EOL_NOTE[29]=""
R_FIX[29]="sudo apt update
sudo apt install --only-upgrade \$(dpkg -l 'php*' | awk '/^ii/{print \$2}')
sudo systemctl restart 'php*-fpm.service' apache2"
RULE_FIXED["29|8.5.9"]="8.5.9-0ubuntu2.1"
RULE_FIXED["29|8.5.4"]="8.5.4-0ubuntu1.5"
RULE_FIXED["29|8.3.6"]="8.3.6-0ubuntu0.24.04.13"
RULE_FIXED["29|8.1.2"]="8.1.2-1ubuntu2.28"
RULE_FIXED["29|7.4.3"]="7.4.3-4ubuntu2.29+esm5"
RULE_FIXED["29|7.2.24"]="7.2.24-0ubuntu0.18.04.17+esm14"
RULE_FIXED["29|7.0.33"]="7.0.33-0ubuntu0.16.04.16+esm22"
RULE_FIXED["29|5.5.9"]="5.5.9+dfsg-1ubuntu4.29+esm18"
R_ID[30]="sury"
R_VENDOR[30]="Ondřej Surý packages"
R_TYPE[30]="deb"
R_NAME[30]="^(php[0-9]\\.[0-9]|libapache2-mod-php[0-9]\\.[0-9])(-[a-z0-9_-]+)?\$"
R_RELEASE[30]="deb\\.sury\\.org|\\+0~20[0-9]{6}"
R_UPSTREAM[30]=""
R_VERDICT[30]=""
R_MODE[30]="upstream"
R_NOTE[30]=""
R_EOL_NOTE[30]="As of October 25, 2026 the Surý packages for this branch had no confirmed PHP2Shell entry in their changelog. Check apt changelog for CVE-2026-109618, or move to PHP 8.2 or newer."
R_FIX[30]="sudo apt update
sudo apt install --only-upgrade \$(dpkg -l 'php*' | awk '/^ii/{print \$2}')
sudo systemctl restart 'php*-fpm.service' apache2
# Ubuntu 20.04/18.04 and Debian 10 are no longer built by the PPA. Use the GetPageSpeed build instead:
# wget https://extras.getpagespeed.com/release-latest.deb && sudo apt install ./release-latest.deb && sudo apt update && sudo apt upgrade 'php*'"
RULE_FIXED["30|5.6.40"]="5.6.40-104"
RULE_FIXED["30|7.2.34"]="7.2.34-66"
RULE_FIXED["30|7.3.33"]="7.3.33-35"
RULE_FIXED["30|7.4.33"]="7.4.33-31"
RULE_FIXED["30|8.0.30"]="8.0.30-25"
RULE_FIXED["30|8.1.34"]="8.1.34-9"
R_ID[31]="debian"
R_VENDOR[31]="Debian"
R_TYPE[31]="deb"
R_NAME[31]="^(php[0-9](\\.[0-9])?|libapache2-mod-php[0-9](\\.[0-9])?)(-[a-z0-9_-]+)?\$"
R_RELEASE[31]="~deb[0-9]+u[0-9]+|^[0-9][0-9.]*-[0-9]+\$"
R_UPSTREAM[31]=""
R_VERDICT[31]=""
R_MODE[31]="upstream"
R_NOTE[31]=""
R_EOL_NOTE[31]="Debian has published no PHP2Shell fix for this release yet. Check apt changelog for CVE-2026-109618, or move to PHP 8.2 or newer."
R_FIX[31]="sudo apt update
sudo apt install --only-upgrade \$(dpkg -l 'php*' | awk '/^ii/{print \$2}')
sudo systemctl restart 'php*-fpm.service' apache2"
R_ID[32]="alpine"
R_VENDOR[32]="Alpine Linux"
R_TYPE[32]="apk"
R_NAME[32]="^php[0-9][0-9](-[a-z0-9_]+)*\$"
R_RELEASE[32]="^r[0-9]+\$"
R_UPSTREAM[32]=""
R_VERDICT[32]=""
R_MODE[32]="upstream"
R_NOTE[32]=""
R_EOL_NOTE[32]="Alpine fixed only php82 to php85, and only on supported branches."
R_FIX[32]="apk update && apk upgrade
rc-service php-fpm83 restart # adjust to your version"
RULE_COUNT=33
# END GENERATED RULES
# Functions use explicit result variables to avoid subshells in the evaluator.
json_quote() {
local text=$1 char code i
text=${text//\\/\\\\}
text=${text//\"/\\\"}
for ((i=1; i<32; i++)); do
printf -v char '\\%03o' "$i"
printf -v char '%b' "$char"
printf -v code '\\u%04x' "$i"
text=${text//"$char"/"$code"}
done
JSON="\"$text\""
}
split_segments() {
local rest=$1
SEGMENTS=()
while [[ $rest =~ (~|\^|[0-9]+|[a-zA-Z]+) ]]; do
SEGMENTS+=("${BASH_REMATCH[1]}")
rest=${rest#*"${BASH_REMATCH[1]}"}
done
}
vercmp() {
local a=$1 b=$2 p q i n
local -a x y
CMP=0
[[ $a == "$b" ]] && return
split_segments "$a"; x=("${SEGMENTS[@]}")
split_segments "$b"; y=("${SEGMENTS[@]}")
n=${#x[@]}
((${#y[@]} > n)) && n=${#y[@]}
for ((i=0; i<n; i++)); do
p=${x[i]} q=${y[i]}
[[ $p == "$q" ]] && continue
if [[ $p == '~' ]]; then CMP=-1; return; fi
if [[ $q == '~' ]]; then CMP=1; return; fi
if [[ -z $p ]]; then CMP=-1; return; fi
if [[ -z $q ]]; then CMP=1; return; fi
if [[ $p =~ ^[0-9]+$ && $q =~ ^[0-9]+$ ]]; then
# awk uses the same double precision numeric comparison as JS.
CMP=$(awk -v p="$p" -v q="$q" 'BEGIN {print (p+0>q+0)?1:((p+0<q+0)?-1:0)}')
((CMP != 0)) && return
elif [[ $p =~ ^[0-9]+$ ]]; then CMP=1; return
elif [[ $q =~ ^[0-9]+$ ]]; then CMP=-1; return
elif [[ $p < $q ]]; then CMP=-1; return
else CMP=1; return
fi
done
return 0
}
upstream_of() {
U_FULL='' U_BRANCH=
if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
U_FULL=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}
U_BRANCH=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}
fi
}
upstream_status() {
upstream_of "$1"
STATUS=unknown ANCIENT=0 UP_FIXED=
[[ -z $U_FULL ]] && return
vercmp "$U_FULL" "$MIN_AFFECTED"
if ((CMP < 0)); then ANCIENT=1; return; fi
UP_FIXED=${FIXED_UPSTREAM[$U_BRANCH]}
if [[ -z $UP_FIXED ]]; then STATUS=eol; return; fi
vercmp "$U_FULL" "$UP_FIXED"
STATUS=vulnerable
((CMP >= 0)) && STATUS=fixed
return 0
}
parse_line() {
local line=$1 t regex noarch dver
P_TYPE='' P_NAME='' P_VERSION='' P_RELEASE='' P_FULL='' P_RAW=
# JS trims both ends of raw; dpkg descriptions remain part of raw.
t=${line#"${line%%[![:space:]]*}"}
t=${t%"${t##*[![:space:]]}"}
[[ -z $t ]] && return 1
P_RAW=$t
regex='^[Pp][Hh][Pp] ([0-9]+\.[0-9]+\.[0-9]+)[^[:space:]]*[[:space:]]+\(([Cc][Ll][Ii]|[Cc][Gg][Ii]-[Ff][Cc][Gg][Ii]|[Ff][Pp][Mm]-[Ff][Cc][Gg][Ii]|[Aa][Pp][Aa][Cc][Hh][Ee]2[Hh][Aa][Nn][Dd][Ll][Ee][Rr]|[Ll][Ii][Tt][Ee][Ss][Pp][Ee][Ee][Dd]|[Ff][Rr][Aa][Nn][Kk][Ee][Nn][Pp][Hh][Pp])'
if [[ $t =~ $regex ]]; then
P_TYPE=phpv P_NAME=php P_VERSION=${BASH_REMATCH[1]}
return 0
fi
regex='^[a-z][a-z][[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+[^[:space:]]+'
if [[ $t =~ $regex ]]; then
P_NAME=${BASH_REMATCH[1]%%:*} dver=${BASH_REMATCH[2]}
if [[ $P_NAME == php* ]]; then
[[ $dver =~ ^[0-9]+: ]] && dver=${dver#*:}
P_TYPE=deb P_VERSION=$dver P_FULL=$dver
return 0
fi
fi
regex='^(php[a-zA-Z0-9_.+-]*)(/[^[:space:]]+)?[[:space:]]+([0-9][^[:space:]]*)'
if [[ $t =~ $regex ]]; then
P_NAME=${BASH_REMATCH[1]} dver=${BASH_REMATCH[3]}
regex='[~+]|ubuntu|deb[0-9]|\<sury\>'
if [[ $dver =~ $regex ]]; then
[[ $dver =~ ^[0-9]+: ]] && dver=${dver#*:}
P_TYPE=deb P_VERSION=$dver P_FULL=$dver
return 0
fi
fi
regex='^(php[0-9]*(-[a-z0-9_]+)*)-([0-9]+\.[0-9]+\.[0-9]+[^-[:space:]]*)-(r[0-9]+)$'
if [[ $t =~ $regex ]]; then
P_TYPE=apk P_NAME=${BASH_REMATCH[1]} P_VERSION=${BASH_REMATCH[3]} P_RELEASE=${BASH_REMATCH[4]}
P_FULL=$P_VERSION-$P_RELEASE
return 0
fi
noarch=${t%%[[:space:]]*}
regex='\.(x86_64|aarch64|noarch|i686|i386|ppc64le|s390x|src)$'
[[ $noarch =~ $regex ]] && noarch=${noarch%"${BASH_REMATCH[0]}"}
# JS's lazy name match selects the first suffix satisfying version-release.
local suffix=$noarch prefix='' part
while [[ $suffix == *-* ]]; do
part=${suffix%%-*}
prefix=${prefix:+$prefix-}$part
suffix=${suffix#*-}
regex='^([0-9]+:)?([0-9][^-]*)-([^-]+)$'
if [[ $suffix =~ $regex ]]; then
P_NAME=$prefix P_VERSION=${BASH_REMATCH[2]} P_RELEASE=${BASH_REMATCH[3]}
regex='^(alt-|ea-|plesk-)?php'
if [[ $P_NAME =~ $regex ]]; then
P_TYPE=rpm P_FULL=$P_VERSION-$P_RELEASE
return 0
fi
return 1
fi
done
return 1
}
is_runtime() {
[[ $P_TYPE == phpv ]] && return 0
# Debian's version-less metapackages (php-common 2:93, php-fpm 2:8.2+93) only point at a
# php8.x package; the real runtime sits on its own line.
if [[ $P_TYPE == deb && $P_NAME =~ ^php(-[a-z]+)?$ ]]; then
upstream_of "$P_VERSION"
[[ -z $U_FULL ]] && return 1
fi
local excluded='pecl|pear|-ioncube|-imagick|-redis|-memcache|-apcu|-xdebug|-igbinary|-msgpack|-mcrypt|-oci8|-sodium'
[[ $P_NAME =~ $excluded ]] && return 1
local runtime='(^|-)php[0-9]*(-(fpm|cli|common|cgi|litespeed|embedded|dbg|devel))?$|^libapache2-mod-php|^php[0-9]+\.[0-9]+(-(fpm|cli|common|cgi|phpdbg))?$|^php[0-9]*-(fpm|cli|common|cgi|litespeed)$'
[[ $P_NAME =~ $runtime ]]
}
family_key() {
local regex='^((alt-|ea-|plesk-)?php[0-9]*(\.[0-9]+)?(-php)?)'
KEY=$P_NAME
[[ $P_NAME =~ $regex ]] && KEY=${BASH_REMATCH[1]}
KEY=$KEY'|'$P_TYPE
}
fill_fix() {
local template=$1 branch=$2 scl='' regex='^(php[0-9]+)-php'
[[ $P_NAME =~ $regex ]] && scl=${BASH_REMATCH[1]}
template=${template//\{scl\}/$scl}
template=${template//\{nodot\}/${branch/./}}
template=${template//\{branch\}/$branch}
FIX=${template//\{pkg\}/$P_NAME}
}
rule_by_id() {
local i
RULE_INDEX=-1
for ((i=0; i<RULE_COUNT; i++)); do
if [[ ${R_ID[i]} == "$1" ]]; then RULE_INDEX=$i; return; fi
done
}
gps_fix_for() {
local branch=$1 regex='^php[0-9]+-php'
if [[ $P_NAME =~ $regex ]]; then rule_by_id gps-el7-scl; else rule_by_id gps-el7-base; fi
FIX=
((RULE_INDEX >= 0)) && fill_fix "${R_FIX[RULE_INDEX]}" "$branch"
return 0
}
judge_with_rule() {
local i=$1 subject target installed
[[ ${R_TYPE[i]} == "$P_TYPE" && $P_NAME =~ ${R_NAME[i]} ]] || return 1
subject=$P_RELEASE
[[ $P_TYPE == deb ]] && subject=$P_FULL
[[ -z ${R_RELEASE[i]} || $subject =~ ${R_RELEASE[i]} ]] || return 1
[[ -z ${R_UPSTREAM[i]} || $P_VERSION =~ ${R_UPSTREAM[i]} ]] || return 1
upstream_of "$P_VERSION"
VENDOR=${R_VENDOR[i]} NOTE=${R_NOTE[i]} FIX='' FIXED_IN='' HAS_FIXED=0 HAS_FIX=0 HAS_BRANCH=0
if [[ ${R_VERDICT[i]} == vulnerable ]]; then
if [[ ${GPS_BRANCH["$i|$U_BRANCH"]} == gps-el7 ]]; then gps_fix_for "$U_BRANCH"
else fill_fix "${R_FIX[i]}" "$U_BRANCH"; fi
VERDICT=vulnerable HAS_FIX=1
return 0
fi
if [[ ${R_VERDICT[i]} == patched ]]; then VERDICT=patched; return 0; fi
# A vendor's explicit backport entry for this branch beats the generic
# upstream mode (mirrors judgeWithRule in vendor/php2shell.js: Surý
# rebases 8.2+ but backports the fix into EOL branches it still builds).
target=
if [[ -n $U_FULL ]]; then
target=${RULE_FIXED["$i|$U_FULL"]}
[[ -z $target ]] && target=${RULE_FIXED["$i|$U_BRANCH"]}
fi
if [[ -n $target ]]; then
installed=$P_VERSION-$P_RELEASE
[[ $P_TYPE == deb ]] && installed=$P_FULL
vercmp "$installed" "$target"
FIXED_IN=$target HAS_FIXED=1 VERDICT=patched
if ((CMP < 0)); then
VERDICT=vulnerable HAS_FIX=1
fill_fix "${R_FIX[i]}" "$U_BRANCH"
fi
return 0
fi
if [[ ${R_MODE[i]} == upstream ]]; then
upstream_status "$P_VERSION"
if [[ $STATUS == fixed ]]; then
VERDICT=patched FIXED_IN=$UP_FIXED HAS_FIXED=1
elif [[ $STATUS == vulnerable ]]; then
VERDICT=vulnerable FIXED_IN=$UP_FIXED HAS_FIXED=1 HAS_FIX=1
NOTE="PHP $P_VERSION predates the fix."
fill_fix "${R_FIX[i]}" "$U_BRANCH"
else
VERDICT=unknown NOTE=${R_EOL_NOTE[i]} HAS_FIX=1
fill_fix "${R_FIX[i]}" "$U_BRANCH"
fi
return 0
fi
return 1
}
generic_fix() {
case $P_TYPE in
deb) FIX="sudo apt update && sudo apt install --only-upgrade \$(dpkg -l 'php*' | awk '/^ii/{print \$2}')" ;;
apk) FIX='apk update && apk upgrade' ;;
rpm)
if [[ $P_NAME == ea-php* ]]; then
FIX="yum update 'ea-php*' && /scripts/restartsrv_apache_php_fpm"
elif [[ $P_NAME == alt-php* ]]; then
FIX="yum update 'alt-php*'"
elif [[ $P_NAME == plesk-php* ]]; then
FIX='plesk installer --select-release-current --upgrade-installed-components'
elif [[ $P_RELEASE == *.el7* ]]; then
FIX='yum-config-manager --enable getpagespeed-extras-php84 && yum install php84-getpagespeed-stack'
else FIX="sudo dnf upgrade 'php*'"; fi ;;
*) FIX='' ;;
esac
}
judge() {
local i
for ((i=0; i<RULE_COUNT; i++)); do
judge_with_rule "$i" && return 0
done
upstream_status "$P_VERSION"
VENDOR='' NOTE='' FIX='' FIXED_IN='' HAS_FIXED=0 HAS_FIX=0 HAS_BRANCH=0 BRANCH=$U_BRANCH
[[ -n $U_BRANCH ]] && HAS_BRANCH=1
if [[ $STATUS == fixed ]]; then
VERDICT=patched NOTE="PHP $P_VERSION carries the upstream fix (first fixed: $UP_FIXED)."
elif [[ $STATUS == unknown ]]; then
VERDICT=unknown NOTE='Could not read a PHP version from this line.'
if ((ANCIENT)); then
NOTE="PHP $P_VERSION is older than every branch the advisories assessed and has had no security fixes for years. Treat it as compromised-ready and replace it."
fi
elif [[ $P_TYPE == phpv ]]; then
VERDICT=unknown
if [[ $STATUS == eol ]]; then
NOTE="PHP $U_BRANCH got no upstream fix, so this build is vulnerable unless your vendor backported it, and php -v cannot show that. Paste your package list (rpm -qa or dpkg -l) for a definite answer."
else
NOTE="Upstream PHP $P_VERSION is vulnerable (fixed in $UP_FIXED), but distributions backport the fix without changing this number. Paste your package list (rpm -qa or dpkg -l) for a definite answer."
fi
else
VERDICT=unknown HAS_FIX=1
if [[ $STATUS == eol ]]; then NOTE="PHP $U_BRANCH got no upstream release with the fix."
else NOTE="Upstream $P_VERSION predates the fix ($UP_FIXED)."; fi
NOTE+=" This package comes from a vendor we have no rule for yet, so only its changelog can say whether the fix was backported: rpm -q --changelog $P_NAME | grep -E \"2026-10961[89]\" (or apt changelog $P_NAME)."
generic_fix
fi
return 0
}
# GetPageSpeed builds print "Built by GetPageSpeed LLC (<version>-<release>)" in
# php -v (mirrors gpsBanner in vendor/php2shell.js). Sets BANNER_VERSION/RELEASE.
gps_banner() {
local regex='Built by GetPageSpeed LLC \(([0-9]+\.[0-9]+\.[0-9]+)-([0-9][^[:space:]()]*)\)' restore=0
BANNER_VERSION='' BANNER_RELEASE=
shopt -q nocasematch || restore=1
shopt -s nocasematch
if [[ $1 =~ $regex ]]; then
BANNER_VERSION=${BASH_REMATCH[1]} BANNER_RELEASE=${BASH_REMATCH[2]}
fi
((restore)) && shopt -u nocasematch
return 0
}
# Judge the banner NVR with the GetPageSpeed rpm rules (mirrors judgeGpsBanner).
# The banner cannot tell the php package from a software collection (phpNN-php),
# whose thresholds differ per branch, so both shapes are judged and the stricter
# verdict wins. Returns 1 (state untouched) when no GetPageSpeed rule applies.
judge_gps_banner() {
local raw=$P_RAW shape rank best_rank=0 found=0 seen='' kinds=0 nodot shapes
local b_verdict b_vendor b_note b_fix b_fixed_in b_has_fixed b_has_fix b_has_branch b_branch
upstream_of "$BANNER_VERSION"
nodot=${U_BRANCH/./}
shapes=("php" "php$nodot-php")
for shape in "${shapes[@]}"; do
P_TYPE=rpm P_NAME=$shape P_VERSION=$BANNER_VERSION P_RELEASE=$BANNER_RELEASE P_FULL=$BANNER_VERSION-$BANNER_RELEASE P_RAW=$raw
judge
[[ -z $VENDOR ]] && continue
[[ $seen == *"|$VERDICT|"* ]] || { seen+="|$VERDICT|"; kinds=$((kinds+1)); }
case $VERDICT in vulnerable) rank=3 ;; unknown) rank=2 ;; *) rank=1 ;; esac
((rank > best_rank)) || continue
best_rank=$rank found=1
b_verdict=$VERDICT b_vendor=$VENDOR b_note=$NOTE b_fix=$FIX b_fixed_in=$FIXED_IN
b_has_fixed=$HAS_FIXED b_has_fix=$HAS_FIX b_has_branch=$HAS_BRANCH b_branch=${BRANCH-}
done
P_TYPE=phpv P_NAME=php P_VERSION=$BANNER_VERSION P_RELEASE=$BANNER_RELEASE P_FULL=$BANNER_VERSION-$BANNER_RELEASE P_RAW=$raw
((found)) || return 1
VERDICT=$b_verdict VENDOR=$b_vendor FIX=$b_fix FIXED_IN=$b_fixed_in
HAS_FIXED=$b_has_fixed HAS_FIX=$b_has_fix HAS_BRANCH=$b_has_branch BRANCH=$b_branch
NOTE=$b_note
[[ -n $NOTE ]] && NOTE+=' '
NOTE+="Judged from the build release in the php -v banner ($P_FULL)."
((kinds > 1)) && NOTE+=' The banner cannot tell the php package from a software collection, so the stricter threshold applies.'
return 0
}
package_json() {
json_quote "$P_TYPE"; PKG_JSON="{\"type\":$JSON"
json_quote "$P_NAME"; PKG_JSON+=",\"name\":$JSON"
json_quote "$P_VERSION"; PKG_JSON+=",\"version\":$JSON"
if [[ $P_TYPE != phpv || -n $P_RELEASE ]]; then
json_quote "$P_FULL"; PKG_JSON+=",\"full\":$JSON"
fi
if [[ $P_TYPE == rpm || $P_TYPE == apk || -n $P_RELEASE ]]; then
json_quote "$P_RELEASE"; PKG_JSON+=",\"release\":$JSON"
fi
json_quote "$P_RAW"; PKG_JSON+=",\"raw\":$JSON}"
}
result_json() {
package_json
json_quote "$VERDICT"; RESULT="{\"verdict\":$JSON,\"pkg\":$PKG_JSON"
json_quote "$VENDOR"; RESULT+=",\"vendor\":$JSON"
json_quote "$NOTE"; RESULT+=",\"note\":$JSON"
if ((HAS_BRANCH)); then json_quote "$BRANCH"; RESULT+=",\"branch\":$JSON"; fi
if ((HAS_FIXED)); then json_quote "$FIXED_IN"; RESULT+=",\"fixedIn\":$JSON"; fi
if ((HAS_FIX)); then json_quote "$FIX"; RESULT+=",\"fix\":$JSON"; fi
RESULT+='}'
}
usage() {
cat <<'HELP'
Usage: php2shell-check.sh [--json] [--file PATH|-]
Check installed PHP packages for PHP2Shell vendor fixes.
--file PATH Read rpm -qa, dpkg -l, apk info -v or php -v output
--json Emit the web checker's JSON report
--help Show this help
--version Show the rules update date
Exit: 0 all fixed; 1 vulnerable; 3 unknown or no PHP; 2 usage error.
https://www.getpagespeed.com/php2shell
HELP
}
main() {
local json_mode=0 file='' text line gps_built=0 rank key overall=none overall_rank=0 separator='' item tag
local -A ranks=() reports=() human=()
local -a order=()
while (($#)); do
case $1 in
--json) json_mode=1; shift ;;
--file)
if (($# < 2)) || [[ -z $2 ]]; then usage >&2; return 2; fi
file=$2; shift 2 ;;
--help) usage; return 0 ;;
--version) printf '%s\n' "$UPDATED"; return 0 ;;