Files on Phabricator are always viewable to a user if they are attached to an object that they can view. It seems Phabricator does check if you can view a file before allowing you to attach it. If you don't have access to the file, it will just look like this {F99999999999} in plaintext. It seems Phabricator does not do this check when creating commits in Diffusion repositories. This means you can make a restricted file public simply by including the syntax to attach the file in the commit message which will then by synced to Phabricator, causing the file to be made public regardless of whether you had access in the first place. As file numbers are sequential, it is not to hard to come across a restricted file simply by enumeration (e.g. https://phabricator.wikimedia.org/F34911492).
Example of this occuring here: F21966, the file's policy was set to WMF-NDA, yet it is public by virture of being included in a commit, even though the author did not have access to the file.
I also confirmed this locally as well.