-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Change the way how password is stored in C++ engine. #14196
base: master
Are you sure you want to change the base?
Conversation
I have used GameConqueror to search the password in the memory. master branchWhen I have entered the password in the main menu but did not join the server yet, I could find one instance of the password formatted as wstring and no ASCII-formatted instance. After I have joined the server, I could find no wstring-formatted instance and two ASCII-formatted instances. After I have exited and was back in the main menu, I could find no wstring-formatted instances and three ASCII-formatted instances. After joining the server again, there were two ascii-formatted instances, and back in the main menu again, there were again three ascii-formatted instances. This pull requestLike in the master branch, when I have entered the password in the main menu but did not join the server yet, I could find one instance of the password formatted as wstring and no ASCII-formatted instance. This is the expected behaviour. After joining the server or after going back to the main menu I could no longer find the password formatted as wstring or ASCII. |
@HybridDog Thanks for the quick feedback and testing. |
180d83b
to
aec7ede
Compare
Again check for
Can be |
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.
structure looks fine in general
2cb9286
to
3ac47e2
Compare
For maintenance reasons, all previous commits merged into one. Rebased. Command to test reconnect added. Reconnect not working. I will have to store the password hash in |
@HybridDog Can you please recheck if the password is still unreachable by looking for it in memory? |
Updated How to test steps. |
The password still disappears from memory in the cases which I have mentioned above (#14196 (comment)) and when I register a new player instead of joining with an existing one. However, after joining a server, if I press Escape to reach the ingame menu, change the password there and then continue playing, I can find one wstring-formatted instance of the password in the memory and no ASCII-formatted instance. |
Sorry for changing my opinion after you've already put work into this, but the more code changes go into this PR the less I feel it's worth it. |
The main benefit is probably preventing leaks when sharing a dump or debug trace |
d6c265b
to
47a8ee1
Compare
@HybridDog Thanks for checking. Should be fixed now. |
c79abb9
to
74520fb
Compare
Windows build failed due to:
|
This seems like a good change in a lot of ways, but if the concern is that memory dumps include the password, this only partially mitigates that by instead storing a hashed password. Could the memory for the hashes be allocated separately and marked as inaccessible when not in use, as well as requesting it's not included in any core dump on supported systems? Libsodium does something like that, https://libsodium.gitbook.io/doc/memory_management https://github.com/jedisct1/libsodium/blob/1012bbc380c81bf7782a85d43c2c9ed7caf8c8b9/src/libsodium/sodium/utils.c I think windows mini dumps shouldn't include PAGE_NOACCESS pages, or at least shouldn't for most configurations https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_type |
@sfence rebase needed |
74520fb
to
8ce9138
Compare
8ce9138
to
2d73fea
Compare
2d73fea
to
21b30f5
Compare
@sfence if nobody answers, my suggestion is to add it as a point of the next meeting |
In the discussion about the implementation of
transfer_player
(#14129) was recognized that the password is stored as pure text in the Minetest engine during all game sessions. Because it allows potential attackers to easily find the password in a memory dump, this PR has been created.This PR should improve the safety of passwords.
This PR erases every password storage in C++ as soon as possible.
Password is no longer kept in
struct GameStartData
andclass Client
as pure text for all time the client is connected to the server.The New
class ClientAuth
accepts the password and player name and immediately calculates the hash and everything that can be necessary in the future for authorization and what requires the password to be known.I don't think so.
Probably not.
This improves safety on the client side. It can be marked as a bugfix, probably.
To do
This PR is a Ready for Review.
How to test
Basic check:
Reconnect check: