Problem/Motivation

TFA does not process the destination parameter correctly when it contains query parameters.

The Zendesk module, when doing SSO with Zendesk, involves a redirect to:

user?destination=services/zendesk%3Fbrand_id%3D123456%26locale_id%3D1%26return_to%3Dhttps%253A//example.zendesk.com/agent/tickets/123

When the TFA process intervenes, and the user enters the correct code, it generates a redirect to:

services/zendesk%3Fbrand_id%3D123456%26locale_id%3D1%26return_to%3Dhttps%253A//example.zendesk.com/agent/tickets/123

That results in a 404 error, of course, because the query parameters are erroneously URL-encoded.

Proposed resolution

Fix _tfa_form_get_destination() to separate the query from the path in ?destination - in other words, make it behave a bit more like drupal_goto() in its processing of ?destination.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pjcdawkins created an issue. See original summary.

pjcdawkins’s picture

Status: Active » Needs review
FileSize
2.62 KB

This patch

  • adds checking and parsing of the '?destination', similar to drupal_goto()
  • renames the local variable $destination to $path to avoid confusion.
  • removes a call to drupal_get_query_parameters() because it wasn't doing anything helpful.
  • removes an array_merge() which seemed intended to (always) pass along the entire current query to the redirect, which seemed wrong
pjcdawkins’s picture

Issue summary: View changes
drumm’s picture

frederickjh’s picture

pjcdawkins’s picture

Assigned: pjcdawkins » Unassigned

FWIW, we've used this patch in production for 6 months.

frederickjh’s picture

Hi pjcdawkins!

Thanks for that information about the patch that fixes this.

drumm is unwilling to patch this module on drupal.org before the patch is commited to this module. I am guessing before you do this the security team will not review the updated version of the module nor the patch.

I can understand drumm's point of view. If you think that this patch fixes this issue in the correct manner then I would urge you to commit it and release a new version of the TFA module so that the security team can review it and allow the drupal.org webmasters to update and fix the issue there.

Thanks for your help and understanding in this matter!
Frederick

pjcdawkins’s picture

Hi Frederick, there's some misunderstanding here. I am not a TFA module maintainer; I don't have the authority nor the permission to commit my patch.

frederickjh’s picture

My apologies @pjcdawkins! I should have check that and not assumed you were a maintainer. Thanks for the patch and the update on how it is working.

I previous comments then about committing a patch for this issue and pushing a new release should be redirected to the module maintainers.

petar.kolicov’s picture

Hi @pjcdawkins,

When FTA is enable and user try to reset password, TFA redirect is not working correct because $options['query'] = $destination['query']; overwrites 'pass-reset-token' in query. I add one change to your patch ($options['query'] = array_merge($options['query'], $destination['query'])).

petar.kolicov’s picture

Sorry, I found one mistake in my code.

The last submitted patch, 10: tfa-2687021-10.patch, failed testing.

frederickjh’s picture

Priority: Normal » Major

Hi!
I am changing this issue to major as it affects all users on drupal.org that use two-factor authentication. In the related issue drumm, one of the web admins for drupal.org says that until this code in commit and released so that the security team reviews it he is unwilling to patch drupal.org. I think that this constitutes being a major bug by the fact that it reflects badly on the drupal community and that it affects users willing to improve the security of their drupal.org account by enabling two-factor authentication.

pjcdawkins’s picture

Status: Needs review » Reviewed & tested by the community

@petar.kolicov's modification to my earlier patch is a good one.

Setting patch #11 RTBC.

DamienMcKenna’s picture

DamienMcKenna’s picture

jcnventura’s picture

I've undone the $destination -> $path rename as it made it a bit harder to review the patch, and it changed a lot of code in places that really didn't need to be changed.

  • jcnventura authored 3554d4a on 7.x-2.x
    Issue #2687021 by petar.kolicov, jcnventura, pjcdawkins: TFA redirects...
jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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