Skip to content

[2.1] Ensure we set the cookie when presenting the login form#9167

Open
jdarwood007 wants to merge 6 commits intoSimpleMachines:release-2.1from
jdarwood007:fix9158
Open

[2.1] Ensure we set the cookie when presenting the login form#9167
jdarwood007 wants to merge 6 commits intoSimpleMachines:release-2.1from
jdarwood007:fix9158

Conversation

@jdarwood007
Copy link
Member

Fixes #9158

@sbulen, given my reproducibility instructions, are you able to confirm this works?

@jdarwood007
Copy link
Member Author

I should note that if bots hit the login page, they will generate cookies. This has to occur in order for session data to be able to carry over. There is no workaround for this. We can only limit the cookie generation to specific pages

@sbulen
Copy link
Contributor

sbulen commented Mar 22, 2026

I'll test later.

Pretty sure this won't work though. In the scenario discussed, sa=login is never invoked. The non-modal form directly invokes login2.

@jdarwood007
Copy link
Member Author

Well, that can be fixed by updating the KickGuest() logic.

However, this will essentially negate the fixes for bot improvements on sessions for forums with guest access disabled.

There is no simple workaround for this.

We would have to change the kick guest to not issue the login template, but rather provide a simple direct link to the login page.

This also affects maintenance mode.

@jdarwood007
Copy link
Member Author

So this fix actually is tackling 3 parts

First part is the login modal, in which I just ensure that when we hit action=login, we generate a cookie always. This can increase the abuse by bots, but there is no avoiding this. We need cookies to process a login. To avoid abuse of action=login, there is options in apache to do rate limiting that would be better than what we can in SMF.

The second fix is for the KickGuest action that occurs for guests who visit the forum, and guest access is disabled. If a cookie has not been set, it presents a link to the action=login. The action=login will set the cookie and allow them to proceed.

The last part is for InMaintenance, which is set when the forum is in Maintenance mode. This is similar to KickGuest, but with a side effect that even in maintenance mode, we don't truly run the login action. So if a cookie is still not present, they will just get the same page. I don't think its worth it in maintenance mode to run logic to figure out that out and provide any help.

@sbulen
Copy link
Contributor

sbulen commented Mar 22, 2026

A couple notes -

  • To the best of my knowledge, the issue has nothing to do with cookie creation. Extra cookies aren't the problem. Physical DB writes to the session cause issues, not cookies. In fact, the problem is almost the opposite: a couple of forums are not getting a new PHP cookie after the session is destroyed upon logout. The lack of the new PHP cookie with a fresh session ID for some folks is the issue.
  • PHP creates that cookie, not SMF.

Ideally, we'd find why those folks aren't getting new PHP session cookies upon logout. What is different about their config that is causing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants