Forbid use of 'A-z' pattern in regular expressions

Created on 15 May 2017, over 7 years ago
Updated 10 September 2024, 2 months ago

Problem/Motivation

A-z pattern (from upper 'A' to lower 'z') includes such non-obvious characters as:
[ \ ] ^ _ `
See ascii table:

Such an implicit extension of valid characters can lead to undesirable consequences (including security problems). Let's avoid this.

Proposed resolution

  • Replace A-z pattern on A-Za-z (or a-zA-Z) in all cases.
  • Forbid A-z pattern via code standards.

Remaining tasks

Searching by 'A-z' (with match case regim) found two safe cases:

  • core/lib/Drupal/Core/Theme/ThemeInitialization.php (line 283)
  • core/modules/views/src/Plugin/views/filter/FilterPluginBase.php (line 705)

In both cases, security is provided by additional restrictions:

  • innocuous key in FilterPluginBase
  • bound by list of extensions in ThemeInitialization

But I still added a security tag, because I think that this change will help to improve the security of drupal.

User interface changes

API changes

Data model changes

📌 Task
Status

Closed: outdated

Version

11.0 🔥

Component
Other 

Last updated about 1 hour ago

Created by

Live updates comments and jobs are added and updated live.
  • Security

    It is used for security vulnerabilities which do not need a security advisory. For example, security issues in projects which do not have security advisory coverage, or forward-porting a change already disclosed in a security advisory. See Drupal’s security advisory policy for details. Be careful publicly disclosing security vulnerabilities! Use the “Report a security vulnerability” link in the project page’s sidebar. See how to report a security issue for details.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    There are no instances of this in core. Also removing the coding standards tag. If anyone wants to discuss making this a standard, open an issue in the coding standards project.

    $ git grep -r "^.*A-z"
    $ 
    
Production build 0.71.5 2024