...
Although this solution is reasonably secure, a determined attacker could create a symbolic link with the same creation and last-modified times as the original file. Also, there is a time-of-check-time-of-use (TOCTOU) race condition between when the file's attributes are read and when the file is first opened. Likewise, there is another TOCTOU between the second attributes are read and the file is reopened.
Compliant Solution (POSIX fileKey
Attribute)
...