The module is using the following code.

function honeypot_get_signed_timestamp($time) {
  $private_key = Drupal::service('private_key')->get();
  return $time . '|' . Crypt::hashBase64($time, $private_key);
}

Crypt::hashBase64() accepts just an argument: the data for which you need the hash. What requires two arguments is Crypt::hmacBase64().

The result is that the module is giving out in clear the hash of the timestamp together the timestamp. If spammers understand this, it would easier for them to forge a value.

The code should use Crypt::hmacBase64().

CommentFileSizeAuthor
#3 code_passes_two-2659766-3.patch1.13 KBgeerlingguy

Comments

kiamlaluno created an issue. See original summary.

geerlingguy’s picture

@kiamlaluno - You're correct! Thanks for the catch. I'll fix this soon...

geerlingguy’s picture

Status: Active » Needs review
StatusFileSize
new1.13 KB

Let the testbot do it's thing.

dmitryVL’s picture

Status: Needs review » Reviewed & tested by the community

Looks good for me, easy way for spam protection. Move to rtbc.

  • geerlingguy committed 4aeb7ef on 8.x-1.x
    Issue #2659766 by geerlingguy, kiamlaluno: Code passes two arguments to...
geerlingguy’s picture

Status: Reviewed & tested by the community » Fixed

It's fine in Drupal 7... must've just been a brain fart when I was porting the change to Drupal 8.

Status: Fixed » Closed (fixed)

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