While Apple’s new Swift Playground is an excellent feature that beginning developers are sure to love, one developer has discovered a highly dangerous flaw in the system, the run-as-you-type nature of Playground can erase your hard drive.
Protip: while in a Swift playground, for the love of God don't write system("cd ~; rm -rf *"). Runs-as-you-type has its downsides!
— Steve T-S (@stroughtonsmith) June 4, 2014
9to5Mac reports that developer Steve Stroughton-Smith has discovered that the app isn’t sandboxed, which means entered code can do pretty much anything it wants. If you enter the code shown in the above tweet, it will delete every file on your hard drive. The realtime nature of Playgrounds means that you don’t even have to press ENTER to start the erasing process!
Apple is sure to fix this issue, but until then, be very careful what you enter in the Playground, and also be wary of running any Swift scripts you may find on the web unless you know what they do.