From reading the TeX source, it seems that the
input_ln procedure is responsible for removing trailing spaces from lines upon input (before category codes are considered). A very short excerpt from the code there is
if buffer[last-1]<>" " then last_nonblank:=last; end;
The test appears to target specifically spaces, and not tab characters. However, doing some tests, I see that TeX also removes tabs (regardless of catcodes). For instance, running
echo -e "\\\\catcode9=12\\\\show\\t%" | tex
the character <tab>, but omitting the
% there is no output.
So... Which part of TeX removes trailing tabs?