Infomation Leak in Fileswitch
Timothy Baldwin (184) 242 posts |
Currently Fileswitch does not erase freshly allocated file buffers, and a consequence will write the previous contents of memory to the end of buffered files. This may leak private information to where it may be read by a third party. If writing to a disc using Filecore possibly secret junk will be written to the disc and can be read from the disc by bypassing the filing system. For example:
If writing to a Linux NFS server using Sunfish (or occasionally using RPCEmu HostFS) the junk will be at end files as seen by the Linux filing system API, the junk will be removed from the file (but may remain on the disc) when and if the file is closed in RISC OS. If the files are publicly accessible, for example via a web server, a lucky attacker may be able to read your passwords. To reproduce open, write to, and flush a file, but do not close a file:
Then examine the file without using it’s handle (H%), junk will be in the file after the text “TESTING”. For Filecore it is necessary to reset the computer without shutting down for this demonstration. Alas due to a bug in RPCEmu this bug does not reliably show, here is a workaround:
My suggested fix is to erase the buffer upon allocation to the file, junk may be appended from other parts of file but your secrets are now safe:
|
Jon Abbott (1421) 2651 posts |
ClaimBuffer will more than likely be using OS_Heap (possibly via OS_Module 6), in which case the “leak” is in the heap manager. I don’t believe it clears allocated memory which was probably done for speed. I’m sure this has been raised previously, although can’t find the thread. If a secure OS is now a thing then OS_Module 6 should probably clean any claimed area before passing it back. OS_Heap probably doesn’t need to clean as the app using it can decide if allocations need cleaning. Another option is to clean deallocated blocks, as it may not be so time sensitive. Generally a block is freed as the final stage, as opposed to allocation which is done as an early stage. |