Raw $_GET and $_POST variables should never be accessed and used directly because they pose a risk of SQL injection, or other potential forms of exploitation using carefully crafted URLs and GET/POST parameters. The request service provides a security layer to help sanitize and ensure that these variables are safe to use.

Regardless of whether or not this is deemed a security issue in this particular case, it goes against Drupal coding standards and best practices. When using PHPCS to lint code against Drupal standards, this error message is produced:

The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('g-recaptcha-response') instead.

All modules should comply with the Drupal coding standards, especially when it comes to potential security issues, to minimize vulnerabilities in the platform.

CommentFileSizeAuthor
#2 3124353-2.patch963 bytesswatichouhan012

Issue fork recaptcha-3124353

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

swatichouhan012 created an issue. See original summary.

swatichouhan012’s picture

Assigned: swatichouhan012 » Unassigned
Status: Active » Needs review
StatusFileSize
new963 bytes

Kindly review patch.

roderik de langen’s picture

Confirmed that the above fix works

anybody’s picture

Version: 8.x-2.5 » 8.x-3.x-dev
Status: Needs review » Needs work

@swatichouhan012 thank you very much, but could you please update the issue summary with details, why this should be done and where this is documented?

Tests look good. Also it would be better to have this as MR against 3.x and 4.x

teknocat’s picture

Issue summary: View changes

anybody’s picture

Status: Needs work » Needs review

As of https://symfony.com/doc/current/introduction/http_fundamentals.html the solution is correct, we please need some community feedback, if this works, then we can merge it soon.

roderik de langen’s picture

Status: Needs review » Reviewed & tested by the community

Tested the patch again!

  • Anybody committed 5df6bb83 on 8.x-3.x authored by teknocat
    Issue #3124353 by swatichouhan012, Roderik de Langen, Anybody: Use...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @Roderik de Langen merged! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.