Whether retrieving an item is legal or not can be seen by the GUI text that appears when targeting it - either "Legal Salvage" or "Illegal Salvage".
Cargo that a player both jettisons and abandons becomes legal salvage, while if they only jettison it it is illegal salvage for everyone but them. Cargo that is already marked as stolen can only be jettisoned.
Legally salvaged cargo functions just like purchased cargo and can be sold to Commodity Markets unless prohibited there.
Legal salvage can be found in Points of Interest on the surface of planets and moons.
Illegally salvaged cargo is marked as stolen and functions similarly to Illegal Goods - it can only be sold to Black Markets and you can get a fine or bounty for being fully scanned by law enforcement while carrying it.