When a privateer or naval vessel spotted a tempting vessel—whatever flag she flew or often enough flying none at all—they gave chase. Sailing under false colors was a common ruse, both for predator and prey. The convention was a vessel must hoist her true colors before firing the first shot. Firing under a false flag could cost dearly in prize court proceedings, even result in restitution to the captured vessel’s owner.[16]

Source: Prize (law) – Wikipedia