Re: How to rename dir / move file?
Posted: Tue Dec 16, 2014 4:58 am
Yeah, definitely make sure to do that.AndreyMust19 wrote:I think need close all opened files in that directory before?
Yeah, definitely make sure to do that.AndreyMust19 wrote:I think need close all opened files in that directory before?
Robin wrote:The thing is, os.execute is like the keys to the kingdom, and when you hand someone those, you can't really say "only come in Mondays and Tuesdays, and don't steal anything while you're in".
In this specific case, one thing I could do is:
Gone is your hard drive. And I could do anything there: make your computer part of a botnet, upload everything in your POETRY\PERSONAL\DRAFTS\ABOUT_MEGAN\ folder to 4chan. Anything. And this is far from the only way to do something like this, it's just the first thing that I came up with. Stuff like this is called code injection.Code: Select all
renameFile('oldfile', 'newfile"; format "C:\')
renameFile is now an unsafe function. In the vast majority of cases it'll be used in a way that isn't dangerous (hard-coded constants, filenames that already exist in the filesystem, etc), but there will be people who will use your function and not realise they just sold out their players to everyone with bad intentions and an internet connection.
---
This is why I made SELÖVE in the first place. By disallowing access to functionality like os.execute, it prevents things like this from ever being a problem.
Megan and I first met at a party at her sister's.Jasoco wrote:Please, tell us more about Megan, Robin.
Someone allows modding for their game, and is smart enough to make a sandbox and disallow os.execute in those mods, but allows the renameFile (because why shouldn't a game mod be able to rename files?) --- then anyone can make a malicious mod that makes the sandbox absolutely useless.Kadoba wrote:I'm aware of code injection but the only way I can think of it happening in this situation would be if the game supported user generated content and the programmer allowed that content to alter the filename values.
That's exactly why I have SELÖVE. Vanilla LÖVE doesn't want to change anything about the Lua standard library, and I respect that. But that does mean you should only play .loves from trusted sources or your box may already be owned.Kadoba wrote:Besides that, if os.execute itself is such an enormous vulnerability and you should never use it ever under any circumstances, then why can it even be called from vanilla LÖVE in the first place? I'm sure people download .love files all the time and run them without checking every line of code. Couldn't a malicious programmer even more easily throw a os.execute call into a .love file?
You are the best.Robin wrote:Megan and I first met at a party at her sister's.Jasoco wrote:Please, tell us more about Megan, Robin.
We hit it off, opened up, shared secrets, and talked about everything. Around us, the party waned, but we hid from sleep together, talking through the deepest hours of the night.
The dawn found us curled up on a couch, asleep but still together.
That experience, connecting with a stranger and falling recklessly in love is one of life's greatest joys.
And now that you're married, you'll never experience it again.
It's the price you pay for everlasting love. It's a small one, but I hope it stings a little.
Anyway, I wish you and Megan the best.
...Hey, man, you asked me to do a toast.
Code: Select all
os.rename(love.filesystem.getSaveDirectory()..'/'..'hello', love.filesystem.getSaveDirectory()..'/'..'hello2')
Code: Select all
love.system.getOS()
https://twitter.com/ID_AA_Carmack/statu ... 5781043200John Carmack wrote:I need to keep reminding myself that practically every write of a file should be to a temp file followed by a rename.
I'm talking specifically about running code in a sandbox. The thing is, this renameFile function breaks that sandbox, even though there's no reason it should. If they don't have direct access to os.execute, but do have access to renameFile, they can use that to gain access to os.execute indirectly.Germanunkol wrote:Robin, I'm confused.