I saw someone doing this in a php shell injection:
test | cat /var/backup/secret.txt
Why are they using
test |? How is that not useless here?
it's just a junk value, sometimes the command you're injecting to wants some specific data in a string, and some commands need at least one argument or it can cause a pipe fail and not execute the cat command.
In this case I guess it's just there because they were testing and didn't bother removing it. As you observed, cat isn't reading from stdin so whatever data is piped into cat is useless, the attacker is controlling the execution after the pipe command so anything that happens prior is usually irrelevant.