Distant stars hazardous to planetary systems, research suggests