-
Notifications
You must be signed in to change notification settings - Fork 603
Fix Auth::User::absorb() IP list transfer logic #2194
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
Conversation
Detach IP from source list before reattaching to destination, and update ipcount correctly. Prevents list corruption and counter underflow.
This comment was marked as resolved.
This comment was marked as resolved.
|
Note: It seems that here there may be a null pointer deref, and this code block will just continuously loop if it ever happens? (I do not see how |
|
FWIW; these |
yadij
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"good enough for now".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that official code is buggy as claimed in the first paragraph of PR description. AFAICT, the ipcount increment bug originates in 2012 commit 742a021 while the list node moving bug goes all the way to 2010 commit 56a49fd.
I also share grave concerns expressed in #2194 (comment)
I can also add a speculation that the affected code never runs because if it were to run, ipcount would become inflated, and Auth::User::clearIp() would assert() during Auth::User object destruction.
In summary, both found and !found branches probably represent broken, untested, and currently unused code that will cause a lot of problems when/if it suddenly starts being used after some other code changes!
The absorb() method is called from src/auth/negotiate and src/auth/ntlm code. The calls only have cached_user as a precondition AFAICT. It may be very useful to know why this code never runs today (if it indeed never runs). @yadij, do you know whether this part of authentication code might run in some deployment environments today and, if not, why not?
PR description: Prevents ... and counter underflow.
@MegaManSec, did you mean "overflow" (from excessive increments)? Or perhaps there is both overflow and underflow here, depending on the corrupted list? Replace with "wrong ipcount levels" or something like that?
I think "counter mismatch" is a better phrase. I will update. |
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
|
@rousskov; I may have missed something, but AFAIK this code runs in all deployments using authentication. When the user logs in a second time it merges the second login details into the pre-existing details. That should be true even if the user-IP caching is disabled. FWIW, I have now opened PR #2221 to replace this |
Detach IP from source list before reattaching to destination, and decrement ipcount. This prevents list corruption, and counter mismatch.
To me, it looks like this absorb() code is supposed to run in many deployments using NTML and negotiate authentication (other schemes do not call absorb() AFAICT). Your answer partially supports that theory AFAICT. However, the bugs and concerns discussed in this PR suggest (but do not guarantee) that at least some critical parts of this code never run at all (e.g., because they would trigger an infinite loop or assertions if they do run). This is a big red flag for accepting PRs that improve this code -- if this code does not run, then those improvements are effectively untested.
I will continue this discussion there. If my "NTML and negotiate authentication" assumption is correct, then the changes in this PR can go in without testing if you are OK with it -- just clear this PR for merging. |
|
Recheck now that our CI issues with OpenBSD are fixed. |
Detach IP from source list before reattaching to destination and decrement ipcount. This prevents list corruption and counter mismatch.
Detach IP from source list before reattaching to destination and decrement ipcount. This prevents list corruption and counter mismatch.
Detach IP from source list before reattaching to destination and decrement ipcount. This prevents list corruption and counter mismatch.
|
queued for backport to v7 |
5 similar comments
|
queued for backport to v7 |
|
queued for backport to v7 |
|
queued for backport to v7 |
|
queued for backport to v7 |
|
queued for backport to v7 |
I assume you are referring to software that left repeated "queued for backport to v7" comments. I do not disagree with your assessment but cannot help with software that leaves those comments, and there are serious disagreements over how backporting should be automated. Anubis (i.e. the merge bot I am responsible for) does not do backporting (yet?). |
Detach IP from source list before reattaching to destination and
decrement ipcount. This prevents list corruption and counter mismatch.