'Collateral attack' is common law doctrine, similar to 'abuse of process' - indeed, it could have been located within 'abuse of process' doctrine without straining legal logic. Collateral attack prohibits the use of indirect (ie. 'collateral') procedures to challenge otherwise validly arrived-at legal results. As such it is a legal defence in that collateral procedure.
A good definition of collateral attack was recently repeated in Duhamel v. Canada (Attorney General) (Fed CA, 2022) [citing Danyluk v. Ainsworth Technologies Inc., 2001 SCC 44, at para 20]:
... Another aspect of the judicial policy favouring finality is the rule against collateral attack, i.e., that a judicial order pronounced by a court of competent jurisdiction should not be brought into question in subsequent proceedings except those provided by law for the express purpose of attacking it:" ...
It's a relatively new doctrine, and it's abstract features are not yet articulated well by the courts - as such, I won't attempt to sub-categorize the cases yet, only to present them as they occur. Given the nature of the doctrine, they can crop up practically anywhere in Canadian law.