The top federal prosecutor in upstate New York is serving in the position unlawfully, a federal judge ruled Thursday.