-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulnerability: $_SESSION spoofing can give superadmin access #25
Comments
Thanks for the report. I haven't looked closely at it yet, but I just wanted to let you know that I have noticed it. I will respond in a few days. (When providing a fix, you should supply a patch or PR with minimal changes making the review easier. Other improvements should be a separate patch / PR.)
I totally agree it is an issue. PS! I would very much have preferred if you reported this to me / us privately so we could have a fix ready before you made the issue public. (In other words, we prefer private or responsible disclosure over full disclosure.) |
Thank you for the swift response. Sorry about the full disclosure 🙇 It's actually the first time I report any kind of vulnerability anywhere, I didn't really thought this through. Feel free to delete/hide the ticket if you feel that's safer. To be honest, I was uncertain if you'd actually prefer a PR over a ticket that you'd implement / oversight yourself. I can make a PR once my other PR on flat file db corruption gets reviewed. |
First, after reading this issue again, I think it's a non-issue:
Yes, and in most situations it should. Let me fist show you how this works and then we can discuss how and if we should tighten the security. In the Session class (in
If we use So, I assume you tested the following setup: example.org/sub1/pivotx where both PivotX installations had site URL set to '/' - meaning the session cookie lived at the root and hence both installations could see each others sessions. Final remarksI haven't had time to test if my description above is correct. I have just read the code. I would appreciate if you verified my findings by modifying the site URL and so on. And, I would prefer to continue to use PS! As you explain: A superadmin on one site can create a user with matching name, and spoof the session for a superadmin on the other site. |
I was working on two different instances of PivotX on a local server (Xampp).
I discovered that, login on one instance, would allow me to get access to the other instance's administration panel...
By instance I mean: two copies of PivotX in different folders placed in
/htdocs
.Even when the two versions have distinct user names, passwords etc.
It allows some level of accessibility in the unrelated instance.
Worse, using the same username gives you the same level of credential in the other instance.
Multisites scenarios on the same web server might be rare, but I think it is still a security issue.
It's also a bug since user sessions of different instances interferes with each other.
Cause
It turns out the function
isLoggedIn()
blindly trust$_SESSION
:It seems that
$_SESSION['user']['username']
only needs to be set to some value for pivotx to view the user as "logged in"(and this regardless of its actual value or checking anything else).
If the attacker finds out the username of the superadmin,
(for instance when the nickname is the same as the user name and displayed in a blog post),
he can get full privileges on the other instance without knowing its password.
If one finds a way to set
$_SESSION['user']['username']
by somehow executing some lines of php, another whole PivotX instance is not even necessary (but I'll admit that in this case you are doomed anyway 😅 ).Aside from the security issue, it also means you have to log out of one instance before using the other instance.
Otherwise the two instances will interfere with each other by login you with the user privileges of the instance you have just used.
You will end up with the wrong user name and settings to publish. So this behavior is also a bug in itself.
Fix
My proposed fix involves
isLoggedIn()
andfunction login($username, $password, $stay)
we make sure to check$_SESSION
user name actually exists in the db, and that the stored password actually matches the$_SESSION
password.This version will log you out if you change your password, which makes more sens as well.
Now we can login on two different instances without conflicts even when the usernames are exactly the same.
I did not push it as far as comparing the settings of the two users to be exactly the same,
from a security standpoint that would be useless, however,
someone using various instances may use the same passwords and username but different settings (pretty niche feature maybe).
The text was updated successfully, but these errors were encountered: