Skip to content

Commit 6db1a33

Browse files
committed
Security: Introduce Grunt task for updating Root Certificates.
The Root Certificate bundle maintained by Mozilla ships in WordPress to allow SSL certificates to be verified on hosts with incomplete, outdated, or invalid local SSL configurations. To date, updates have only been merged into Core when problems arise using a highly manual process. This introduces the `certificates:upgrade` Grunt task to automate the process of updating the included bundle with upstream changes using Composer to manage versioning. The legacy 1024bit certificates included for backwards compatibility are now maintained in a separate file that is prepended to the built version of the bundle during the relevant Grunt tasks. Some expired certificates from this list have been removed: - Cybertrust Global Root (expired 2021-12-15) - Thawte Server CA (expired 2020-12-31) - Thawte Premium Server CA (expired 2020-12-31) The Dependabot configuration has also been updated to open pull requests when new releases occur upstream. Going forward, the recommendation is to create a task ticket for updating these certificates with each release when an update is published. See #62811 for an example of this. Props johnbillion, desrosj, whyisjake, ayeshrajans, SergeyBiryukov, swissspidy, skithund, barry. Fixes #62812. See #62811, 50828. git-svn-id: https://develop.svn.wordpress.org/trunk@59740 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 439b172 commit 6db1a33

File tree

6 files changed

+4977
-1192
lines changed

6 files changed

+4977
-1192
lines changed

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,20 @@ updates:
1212
github-actions:
1313
patterns:
1414
- "*"
15+
16+
# Check for updates to Composer packages.
17+
- package-ecosystem: "composer"
18+
directory: "/"
19+
schedule:
20+
interval: "daily"
21+
open-pull-requests-limit: 10
22+
ignore:
23+
# These dependencies do not currently need to be managed with Dependabot.
24+
- dependency-name: "squizlabs/php_codesniffer"
25+
- dependency-name: "wp-coding-standards/wpcs"
26+
- dependency-name: "phpcompatibility/php-compatibility"
27+
- dependency-name: "yoast/phpunit-polyfills"
28+
groups:
29+
composer-packages:
30+
patterns:
31+
- "composer/ca-bundle"

Gruntfile.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ module.exports = function(grunt) {
211211
src: buildFiles.concat( [
212212
'!wp-includes/assets/**', // Assets is extracted into separate copy tasks.
213213
'!js/**', // JavaScript is extracted into separate copy tasks.
214+
'!wp-includes/certificates/cacert.pem*', // Exclude raw root certificate files that are combined into ca-bundle.crt.
215+
'!wp-includes/certificates/legacy-1024bit.pem',
214216
'!.{svn,git}', // Exclude version control folders.
215217
'!wp-includes/version.php', // Exclude version.php.
216218
'!**/*.map', // The build doesn't need .map files.
@@ -478,6 +480,10 @@ module.exports = function(grunt) {
478480
},
479481
src: '.github/workflows/*.yml',
480482
dest: './'
483+
},
484+
certificates: {
485+
src: 'vendor/composer/ca-bundle/res/cacert.pem',
486+
dest: SOURCE_DIR + 'wp-includes/certificates/cacert.pem'
481487
}
482488
},
483489
sass: {
@@ -859,6 +865,16 @@ module.exports = function(grunt) {
859865
WORKING_DIR + 'wp-includes/js/wp-emoji.min.js'
860866
],
861867
dest: WORKING_DIR + 'wp-includes/js/wp-emoji-release.min.js'
868+
},
869+
certificates: {
870+
options: {
871+
separator: '\n\n'
872+
},
873+
src: [
874+
SOURCE_DIR + 'wp-includes/certificates/legacy-1024bit.pem',
875+
SOURCE_DIR + 'wp-includes/certificates/cacert.pem'
876+
],
877+
dest: SOURCE_DIR + 'wp-includes/certificates/ca-bundle.crt'
862878
}
863879
},
864880
patch:{
@@ -1528,6 +1544,34 @@ module.exports = function(grunt) {
15281544
'usebanner'
15291545
] );
15301546

1547+
grunt.registerTask( 'certificates:update', 'Updates the Composer package responsible for root certificate updates.', function() {
1548+
var done = this.async();
1549+
var flags = this.flags;
1550+
var args = [ 'update' ];
1551+
1552+
grunt.util.spawn( {
1553+
cmd: 'composer',
1554+
args: args,
1555+
opts: { stdio: 'inherit' }
1556+
}, function( error ) {
1557+
if ( flags.error && error ) {
1558+
done( false );
1559+
} else {
1560+
done( true );
1561+
}
1562+
} );
1563+
} );
1564+
1565+
grunt.registerTask( 'build:certificates', [
1566+
'concat:certificates'
1567+
] );
1568+
1569+
grunt.registerTask( 'certificates:upgrade', [
1570+
'certificates:update',
1571+
'copy:certificates',
1572+
'build:certificates'
1573+
] );
1574+
15311575
grunt.registerTask( 'build:files', [
15321576
'clean:files',
15331577
'copy:files',
@@ -1655,9 +1699,11 @@ module.exports = function(grunt) {
16551699
grunt.task.run( [
16561700
'build:js',
16571701
'build:css',
1702+
'build:certificates'
16581703
] );
16591704
} else {
16601705
grunt.task.run( [
1706+
'build:certificates',
16611707
'build:files',
16621708
'build:js',
16631709
'build:css',

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"ext-dom": "*"
1818
},
1919
"require-dev": {
20+
"composer/ca-bundle": "1.5.5",
2021
"squizlabs/php_codesniffer": "3.10.3",
2122
"wp-coding-standards/wpcs": "~3.1.0",
2223
"phpcompatibility/phpcompatibility-wp": "~2.1.3",

0 commit comments

Comments
 (0)