I think more generally the terms originated with UK author Dr. Edward de Bono, in his book "Six Thinking Hats".
White hat thinking is "just the facts" with no judgement or emotion.
Black hat thinking is "megative reasons against" with no judgement or emotion. Just neutral facts that counter any idea.
Red hat thinking is "purely emotional" - anger, vitriol, criticism, invective. This sometimes has its place to relieve frustrations.
Yellow Hat thinking is "optmistic, positive". Done for a length of time it actually reinforces all the good aspects of an idea.
Green Hat thinking is "creative, idea generation, new ideas" and is often accompanied by lateral thinking for idea generation.
Blue hat thinking is "thinking about thinking" and might be used by a convenor, moderator, or someone running a meeting - to suggest which "hat" above should be the active mode.
This terminology above has been loosely adapted and bastardized to describe styles of hacking.
The other precedents for this terminology are
"white lists" (Personnel the Government and security agencies actively protect in society and trusted individuals).
"black lists" (personnel forbidden to be involved in a project - considered known enemies to be treated with caution).