WAF: jetpack_waf_blocklog is created without the site's charset and collation
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
Open projects/packages/waf/src/class-waf-blocklog-manager.php and read create_blocklog_table() around lines 99-116, where the CREATE TABLE string is assembled. Append $wpdb->get_charset_collate() after the closing parenthesis, as WordPress core does, then check the package's existing tests under projects/packages/waf/tests/php/ for the blocklog manager and run them. Done means the table is created with the site's collation and the tests still pass.
Written by the indexing model from the issue text.
Description
Impacted plugin
Jetpack, Protect
Quick summary
Waf_Blocklog_Manager::create_blocklog_table() builds its CREATE TABLE without $wpdb->get_charset_collate(), so wp_jetpack_waf_blocklog gets the database's default charset and collation instead of the site's. Every WordPress core table and most plugin tables are created with get_charset_collate(), so the block log ends up in a different collation from the rest of the site - or, on a database whose default is still utf8/utf8mb3, in a three-byte charset that cannot store 4-byte characters.
Source (trunk): projects/packages/waf/src/class-waf-blocklog-manager.php, create_blocklog_table(), lines 99-116.
Steps to reproduce
- Use a site whose database default collation differs from WordPress' choice, e.g. a database created with
utf8mb4_unicode_ciwhile WordPress picksutf8mb4_unicode_520_ci(DB_COLLATEempty, MariaDB 12). - Activate the firewall (Jetpack Protect → Firewall, or Jetpack's WAF module), which creates the block log table.
- Compare the collations:
SELECT table_name, table_collation FROM information_schema.tables WHERE table_schema = DATABASE();
Expected: wp_jetpack_waf_blocklog uses the same collation as the other WordPress tables (utf8mb4_unicode_520_ci here).
Actual: it uses the database default (utf8mb4_unicode_ci).
Seen with Jetpack 16.4 and Jetpack Protect 7.0.0 on WordPress 7.1.5, MariaDB 12.3, on four sites.
Suggested fix: append the site's charset/collation, as core does:
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE {$wpdb->prefix}jetpack_waf_blocklog ( ... ) $charset_collate;";
Site owner impact
Fewer than 20% of the total website/platform users
Severity
Minor
What other impact(s) does this issue have?
No revenue impact
If a workaround is available, please outline it here.
Convert the table by hand: ALTER TABLE wp_jetpack_waf_blocklog CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci; (use the site's own collation from $wpdb->get_charset_collate()).
Platform (Simple and/or Atomic)
Self-hosted
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 910
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 777
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/jetpack
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/jetpack#55517 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Automattic/jetpack#55385 · 1 comment ·
Maintainers usually reply within 1 day
-
Sharing Buttons: Text styles are white on white on dark backgroundsPossibly taken @KarunyaChavan claimed this 3 days ago. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/jetpack#55253 ·
Maintainers usually reply within 1 day
-
[Package] Stats Admin [Type] Bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Automattic/jetpack#54188 ·
Maintainers usually reply within 1 day
-
Bug Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/jetpack#53467 ·
Maintainers usually reply within 1 day
All issues in Automattic/jetpack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
taskforcesh/bullmq#5238 ·
Maintainers usually reply within 1 day
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itPossibly taken @bfs2021 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
area/import type/enhancement when/later
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Jeffallan/claude-skills#347 ·
Maintainers usually reply within 1 day