How can I give a file the com.apple.quarantine attribute on mac

I have used xattr -d com.apple.quarantine /Users/username/Desktop/app_name.app to remove the attribute but I don't know how to give the attribute again. Could you please help me?


You should be able to do this by replacing the -d (delete) flag with -w (write). So:

xattr -w com.apple.quarantine /Users/username/Desktop/app_name.app

A handy tip if you are unsure about a command is to look up the man page for it.

If you type man xattr it will give you a list of available options for that command with explanations. (to navigate the manual use the arrow keys and press the q key to quit.)


The attribute is not just a flag: it contains a sequence of meaningful bytes. (The -w option of xattr requires attribute data to write to the file.)

Here's an example of the contents from a file in my Downloads folder:

0083;5b4da585;Safari;D1E5E911-DF67-4DCA-8CD4-2AE126B44CEF

Unless you can recreate the correct data manually, or already have the old metadata for that file in a backup (in which case you might as well just restore the whole file), introducing the wrong quarantine data may cause unexpected problems.

This question appears to be similar, and describes how to set the correct metadata.

It is somewhat odd to re-introduce quarantine, as that suggests you no longer trust the file.