The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Steven Murdoch on Twitter: “However, the new “more secure” Universal Windows Platform (UWP) sandboxes the file picker in a separate process, allowing neat features like capability-based access control. It returns a file handle which, if the selected file exists, will not overwrite the existing content! 3/9”

Posted by jpluimers on 2026/04/07

Windows had its own aCropalypse in the Snipping tool, but other UWP based applications are vulnerable of that too because of this:

[Wayback/Archive] Steven Murdoch on Twitter: “However, the new “more secure” Universal Windows Platform (UWP) sandboxes the file picker in a separate process, allowing neat features like capability-based access control. It returns a file handle which, if the selected file exists, will not overwrite the existing content! 3/9”

It is part of this interesting [Wayback/Archive] Thread by @sjmurdoch on Thread Reader App with these two parts just after the above Tweet:

The old Win32 API for saving a file was (roughly) to show a file picker, get the filename the user selected, and then open the file. To open a file, the programmer must specify whether to overwrite the file or not, and example code usually does overwrite the file.
However, the new “more secure” Universal Windows Platform (UWP) sandboxes the file picker in a separate process, allowing neat features like capability-based access control. It returns a file handle which, if the selected file exists, will not overwrite the existing content!

The tread continued supporting this statement, that in the new situation you need to manually truncated the file, and referenced these links:

and had these images:

Screenshot of linked StackOverflow post.

Example code using FileIO.WriteBytesAsync()

Output file showing only 0x0A values.

Example code using WriteBytes()

Output file showing the beginning overwritten but text prese

Uno source code showing fileStream.SetLength(0)

and my question [Wayback/Archive] Jeroen Wiert Pluimers @wiert@mastodon.social on Twitter: “@sjmurdoch Are you sure, as a quick look at (WriteBytesTaskAsync)  (WriteTextTaskAsync) reveals the latter truncates but the former doesn’t. WriteText*/WriteLines* calls the latter. WriteBuffer*/WriteBytes* the former. Need to test this.”.

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.