Probe agencies left red-faced with court orders on 'illegal' arrests