> It's not like there are pipes leading out of the brain
There are, in fact, “pipes” leading out of the brain. Cerebrospinal fluid is (and this is probably somewhat oversimplified) produced from material in the bloodstream in the ventricles in the brain, flows through the system of ventricles and then out of the brain into the subarachnoid space around the brain and spinal cord, and is then reabsorbed into the bloodstream.
And some people literally need an actual pipe implanted to assist with CSF drainage.
https://www.mayoclinic.org/tests-procedures/brain-shunt/abou...