The expiry time for a login is determined when a user first logs in, to be 30 days (by default) from that first login. This does not change even if the user returns to the site within those 30 days. I'd like it if the expiry time could be reset to a further 30 days every time the user returns to the site.

I've managed to implement this by changing a single line of code in _persistent_login_create_cookie(). This was line 417 in the 6.x-1.4 release. Originally, it read:

$expires = (isset($edit['pl_expires']) ? $edit['pl_expires'] : (($days > 0) ? time() + $days * 86400 : 0));

I changed it to:

$expires = (($days > 0) ? time() + $days * 86400 : 0);

Is there any unforseen security risk that I've introduced by doing this? Would it be possible to add this change as an optional feature?

Comments

gapple’s picture

Version: 6.x-1.4 » 6.x-1.x-dev

This could potentially increase the time during which an attacker could continue to access another user's account.

If the session is only valid for a fixed time, the attacker will only have that amount of time where they can continue to access the user's account. Once that period is up, their session key will no longer be valid.
If the session expiry is continually moved forward, the attacker could continue to access the other user's account indefinitely as long as they continue to re-visit the site before the new session period expires.

I think having this behaviour configurable is suitable feature request, as long as the consequences are well explained. I would recommend that if the persistent login's validity is extended upon use, that the period be shortened.

gapple’s picture

Assigned: Unassigned » gapple
Status: Active » Needs review
StatusFileSize
new3.06 KB

I've attached a patch that should make this work (also available from my github repository https://github.com/gapple/persistent_login/tree/issue/735004-extend-expiry).

I'd very much appreciate a review on the logic to determine the expiry period to make sure I'm not missing something.

gapple’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Needs work

Bumping version; needs 7.x-1.x patch

gapple’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes

Bumping to 8.x.

Not sure if this will get backported to 7.x, probably won't be added to 6.x since it's reaching the end of its support life soon.

hargobind’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.62 KB

Here's a forwardport of the patch in #2 for 7.x. I know that it's standard practice to create a patch for the latest core version first, but my immediate need was for 7.x.

Status: Needs review » Needs work

The last submitted patch, 5: persistent_login-7.x-735004-5.patch, failed testing. View results

hargobind’s picture

Status: Needs work » Needs review

Ignore the testbot as there doesn't seem to be a way to test with 7.x.

hargobind’s picture

StatusFileSize
new2.85 KB

Resubmitting a patch for the latest 7.x-1.x branch.

gapple’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

  • gapple committed bd3b5e72 on 8.x-1.x
    Issue #735004: Allow extending expiry of tokens
    
gapple’s picture

Status: Needs review » Fixed
hargobind’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Needs review

Any chance you could commit the 7.x patch from #8?

gapple’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Fixed

Closing out 7.x issues

Status: Fixed » Closed (fixed)

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