-
Notifications
You must be signed in to change notification settings - Fork 124
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
mods(Safe I/O): Only allow creating files with whitelisted filetypes #682
Conversation
I wrote this on a system that is unable to compile Northstar and without having written C++ for like more than half a year, would be surprised if it even compiles xD |
@ASpoonPlaysGames is also working on that (#675), are you aware of that? 😄 |
ngl that PR is kinda dead, i've just not had the time to do much lately. Honestly this PR might be preferable to mine. |
@GeckoEidechse you created the branch on the main repo so we cannot update it 😢 |
This isn't directly related to the PR but I noticed while reviewing that the code immediately below directly locks and unlocks the mutex, but ideally it should be using |
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.
Code looks good I didn't test though.
If we plan on staying C++20 using !whitelist.contains(extention)
might be more readable than whitelist.find(extention) == whitelist.end()
but that is up to preference and shouldn't be blocking really
mfw when 3 people reviewed the PR and no one noticed that the return statements are missing in the check :clueless: |
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.
Only allow creating files with whitelisted filetypes to prevent writing
.bat
or.vb
files with Safe I/O that could then be called using some exploit (e.g. #674), we should prevent writing file types that by default are interpreted as executable.Whitelisting was chosen over blacklisting as we can always extend the list and don't have to worry about potentially forgetting to blacklist a certain filetype.
Of course this doesn't prevent writing a bash script to a
.txt
file and then somehow getting Windows to interpret it as a batch file.Reading files is not restricted to filetypes as we are primarily concerned with creating files here.
Supersedes #675
Completely untested atm.Testing instructions:
sv_cheats 1
)<profile folder>\save_data\GeckoEidechse.Safe-IO-Testing\
test1.txt
exists but notest2.bat
ortest3
.