A five-year-old boy has been seriously injured after a rock was thrown at his head in a bizarre train incident, with detectives now investigating.