Shadow foreign secretary accuses prime minister of putting UK security at risk in rush to fix economy