Mooseoft home

Mooseoft Chronicles

The disastrous bug

In rare cases, Mooseoft Encrypter accepted the right password and gave you back a blank file. Twenty-six years later, I finally understand how.

You could give the old Mooseoft Encrypter the right password, open the document you’d just decrypted, and find it completely blank.

It happened rarely. It’s haunted me ever since. Someone had trusted a program I wrote at seventeen with a file they cared enough about to encrypt. What were they supposed to do with a blank document and my assurance that they’d got the password right?

What survived

I threw away the CDs with the Delphi source code years ago. My friend Stefan had been babysitting the Mooseoft installer in his backups for 26 years. By the time I came to pick it up, it was old enough to drive itself home.

Thanks for looking after it, Stefan. I should take care of my computers and backups the way you do. Failing that, I should’ve sent you the source code too.

Together with GPT-6.2 Astra, I reverse engineered the old Windows program. We followed the code that opened, wrote and deleted files, then ran the original machine instructions against a little filesystem in memory. We could finally watch my program lose a file we could afford to lose.

What if something else was saving the file?

All 288 of our ordinary encrypt-and-decrypt tests passed. Things got interesting when we let another program change the document while Mooseoft had it open.

Imagine clicking Encrypt just as a text editor saves the same letter. An editor that saves in place can shorten the old file to zero bytes before it writes the new text. For a moment, there really is an empty file on disk, even though you can still see the whole letter on your screen.

We modelled that moment. Mooseoft had opened a 10,240-byte file, but by the time it made its first read, the other writer had emptied it. Mooseoft saw the end of the file, logged [OK] and left behind just the 32 bytes it used to check the password. With “Delete original” selected, it even asked Windows to delete the source. From my program’s point of view, it had successfully encrypted everything it had read. All zero bytes of it.

Later, when we gave Mooseoft that 32-byte file and the right password, the check passed. The program looked for more bytes to decrypt, reached the end of the file and handed us an empty document. I’d given it a way to recognise the password. I’d never given it a way to tell whether the rest of the file had arrived.

Only the 32-byte password header survives. A computer accepts the password and hands back a zero-byte document.

All 32 surviving bytes vouched for my password. I’d been rather hoping for the other 10,240.

When the disk says no

We got the same 32-byte copy with just Mooseoft running. A disk might have room for the password check and then fill up as Mooseoft starts writing the document itself. We simulated that failed write. This time the error stopped encryption before Mooseoft could delete the original. The trouble was that the unfinished copy already had its final .mes name. Days later, it would still accept your password and open as blank.

The outcome changed if the failure came one step earlier. In another test, the filesystem denied Mooseoft permission to create the encrypted copy at all. The encryption routine logged the error and returned to the code that had called it. If you’d chosen to delete the original after encryption, that code went ahead and asked Windows to delete it. It had never asked whether encryption had worked.

The encrypted copy cannot be created. With Delete original selected, Mooseoft still asks Windows to delete the source file.

My program remembered what I wanted done with the original. It just forgot to check whether it had made a copy.

We even found a case where a long path got shortened and the encrypted copy lost the .mes at the end of its name. That left Mooseoft opening the original file as the place to write the copy. There wasn’t much the “Don’t delete” setting could do for you at that point.

I still don’t have a damaged file or an error log from back then to tell me whether someone hit Save at just the wrong moment, a disk filled up, or something else happened to the copy. But 26 years later I can finally explain how a perfectly good password opened a perfectly blank document. I think that’s pretty cool. I wish I’d known it at seventeen.

What I want the Rust version to do

I can write a perfectly good file-deletion bug in Rust. The part I want to change is what has to happen before Mooseoft is allowed to say it’s finished.

For a start, I want Mooseoft to read one stable version of the document from beginning to end. If it can’t get that while your editor is saving, it should tell you the file is busy and let you try again.

The plan is to check that the destination and the original are different files, leave the original alone and write the encrypted copy to a temporary file. If a read or write fails, Rust’s Result gives us a way to carry that error all the way back to the button you clicked. You should see what went wrong and still have your original. The encrypted copy earns its final name only after we’ve finished writing it and verified it.

The new format also needs to let us check that the whole file is there. Even a genuinely empty document should have an authenticated end that Mooseoft can verify. That way, if the last part of an encrypted file goes missing, the app can tell you it’s incomplete and keep the partial result out of your documents.

I want one of the tests for the rebuild to fill the disk halfway through encrypting a letter. Checking that Mooseoft reports an error is the easy part. Then I want the test to open the original and read the letter back, right down to “Love, Mum.”