A file sits in Downloads and you do not remember where it came from. The Mac often does.
mdls prints the Spotlight metadata of a file. Ask for the one attribute you want with -name.
mdls -name kMDItemWhereFroms ~/Downloads/example.pdf
The attribute describes where the file was obtained from. For a browser download you normally get the file URL and often the page that linked to it. In Finder you can see the same under Get Info, in the More Info section.
Add -raw when you want the value without the attribute name, for scripts. The man page notes that raw mode separates fields with an ASCII NUL character, so pipe it to xargs -0.
The caveat is that it is only there when the app that saved the file wrote it. Browsers usually do. Files fetched with curl, or copied from elsewhere, often have nothing, and then you get a null value.
A file with no clear origin is a mild security question, and knowing the page it came from helps you decide what to do with it. It does not prove that a file is safe, but it tells you where to start looking.
Further reading: mdls.1 man page, kMDItemWhereFroms (Apple Developer), On this site: mdfind -name searches by file name from the terminal, using Spotlight, On this site: mdutil -s tells you if Spotlight is indexing a volume