Webform Leet Speak Filter (WLF) validates Webform submissions for abusive
language, including evasion techniques such as leet speak character
substitutions, homoglyphs, and repeated character padding.

Project link

https://www.drupal.org/project/wlsf

Comments

nikky171091 created an issue. See original summary.

vishal.kadam’s picture

Issue summary: View changes
brian@graith’s picture

Code review at commit fa42b93. Full manual read of all files, phpcs (Drupal + DrupalPractice), and — because the normalizer class is dependency-free — I executed it directly, so every behavioural claim below is verified rather than inferred.

Verdict up front

The core matching algorithm is broken in both directions: it blocks everyday innocent input with the module's own shipped default configuration, and it fails to catch the evasions the project description advertises. Verified by running LeetspeakNormalizer:

  • "as soon as possible" with bad word assBLOCKED (both normalize to as)
  • "meeting at 45" with assBLOCKED (4→a, 5→s, so "45" → as)
  • "contact bob" with boobBLOCKED (repeat-collapse turns "boob" into "bob")
  • "hello :) how are you" with バカBLOCKED (both normalize to the empty string)
  • "f*ck this" with fuckpasses — the advertised example is not caught (* is stripped, "fck" ≠ "fuck")
  • "a** hole" with asspasses — the settings form's own help table claims this is caught

The default config ships ass in the word list with real-time JS enabled, so out of the box any webform user typing "as" or "45" gets an error.

Major issues

  1. Repeated-character collapse creates systematic false positives. normalize() collapses all repeated letters to one (assas, boobbob), so every bad word with double letters equals a shorter innocent word; digit mapping makes number tokens match too. The vu mapping mangles ordinary words ("love"→"loue"). Consider collapsing runs of 3+ to 2 (catches elongation without merging legitimate doubles), applying digit/symbol maps only inside mixed alphanumeric tokens, and testing against a corpus of innocent text.
  2. The multilingual feature does not work. normalize() strips everything outside [a-z], so non-Latin lists (the form's own examples: ja|バカ, ar|كلب) normalize to ''. The server-side findBadWord() lacks the empty-string guard the JS has, so a configured Japanese/Arabic word never matches its real occurrence and instead matches any punctuation-only token (":)" triggers a block).
  3. The JS applies to every webform on the site. hook_webform_submission_form_alter() only checks the global enable_js_realtime toggle (default TRUE) and never checks whether the webform has this handler attached. Client-side blocking (including a submit guard) is enforced on all webforms while server-side validation runs only where the handler exists — JS users are hard-blocked on forms never configured for filtering; JS-off users pass on the same forms. The hook must check $webform->getHandlers().
  4. The full bad-word list is published to every visitor via drupalSettings in the page source of every webform, anonymous included, by default. That hands evasion-testers the exact list, and many sites won't want their moderation vocabulary readable in source. Needs prominent documentation at minimum; better, make real-time checking server-backed or opt-in.

Moderate

  • Multi-value/composite bypass: validateForm() skips any non-string value, so multi-value textfields and composite elements (name, address) are never validated — a trivial bypass. Needs recursive traversal.
  • Dead permission: administer webform leetspeak is defined but the settings route requires administer webform instead.
  • Variable passed to t(): $this->t($errorMessage, ...) on admin-configured text; only literals should go through t() — use FormattableMarkup for the token replacement.
  • Unjustified static calls: the handler comments claim \Drupal:: statics avoid "property redeclaration conflicts with WebformHandlerBase" while using inherited $this->configFactory lines later. There is no conflict; use normal DI via create().
  • Performance: findBadWord() re-normalizes every bad word for every word of every field, twice (two passes), in both PHP and JS. Pre-normalize the list once.
  • Leftover development narration in shipped code — the normalizer contains "Wait — fuk doesn't match fuck. We collapse then check.", and the settings form ships help tables whose rows are demonstrably wrong (one documents assas without noticing that makes the word "as" a false positive). The documentation needs regenerating from tested behaviour.

Minor

  • Project machine name (wlsf) ≠ module machine name (webform_leetspeak) — the packaged tarball/composer package will be wlsf with a differently-named module inside; rename one before release.
  • LICENSE.txt must not be committed — drupal.org packaging adds it.
  • Both README.md and README.txt present with duplicate content; keep one.
  • Hard dependency on drupal:language is unnecessary (languageManager() exists in core without it) and forces the module's installation.
  • core_version_requirement: ^9 — Drupal 9 is EOL; suggest ^10.3 || ^11.
  • JS isExcluded() uses substring matching (excluding name also excludes first_name) while PHP uses exact in_array() — inconsistent semantics.
  • Violation logging records client IPs by default — worth a privacy note in the README.
  • phpcs: 36 errors / 4 warnings, all auto-fixable with phpcbf.
  • No tests and no .gitlab-ci.yml. LeetspeakNormalizer is pure static and trivially unit-testable — a small test suite would have caught every major finding above.

Security

No injection/XSS found: the JS inserts messages via text:, drupalSettings encoding is core-handled, watchdog uses placeholders. The serious concerns are functional and disclosure-related (#3, #4), not classic vulnerabilities.

Summary

Clean intentions and reasonable structure (separate normalizer class, PHP/JS mirror), but the module fails its own advertised examples and false-blocks ordinary English with the shipped defaults — verified by execution. It needs an algorithm redesign, unit tests for the normalizer, scoping of the JS to handler-enabled webforms, and a documentation rewrite before production use.

nikky171091’s picture

Thank you @brian.willows — this is exactly the kind of review the module needed. Every finding is valid, and I appreciate that you executed the normaliser directly rather than reading it statically. I'll address each point:

avpaderno’s picture

Thank you for applying!

Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review. See also Policy on the use of AI when contributing to Drupal, which is valid when contributing to Drupal, either by committing code in a project, or by creating a merge request for an existing project.

The important notes are the following.

  • For the purposes of this application, it is not necessary to create releases or pre-releases. It is better to make commits only on a branch, and possibly in the same branch used from the start.
  • If you have not done it yet, you should enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
  • For the time this application is open, only your commits are allowed.
  • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

    Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
  • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
  • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

To the reviewers

Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.

The important notes are the following.

  • It is preferable to wait for a project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • It may be best to have the applicant fix things before further review.

For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.

solideogloria’s picture

Status: Needs review » Needs work

Status should be Needs Work after comment #3

vishal.kadam’s picture

1. FILE: README.md

The README file is missing the required sections - Requirements.

2. FILE: README.txt

Remove README.txt since README.md is already prsent.

3. FILE: webform_leetspeak.info.yml

core_version_requirement: ^9 || ^10 || ^11

Projects used for these applications should not declare itself compatible with a Drupal release that is no longer supported. No site should be using Drupal 8 nor Drupal 9, and people should not be encouraged to use those Drupal releases.

dependencies:
  - drupal:webform

The dependencies follow the format <project name>:<module name>. What used for the Webform module is not correct.

4. FILE: webform_leetspeak.module

For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
It would require increasing the minimum Drupal 10 version supported, but Drupal 10.1 is no longer supported.

5. FILE: src/Form/WebformLeetspeakSettingsForm.php

With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.
For this change, it is necessary to require at least Drupal 10.3, but that is not an issue, since Drupal 10.2.x is no longer supported.

vishal.kadam’s picture

Priority: Normal » Minor

I am changing priority as per Issue priorities.