On July 5, 2006, Anderson was found in contempt of court by U.S. District Judge William Alsup for refusing to testify before a federal grand jury investigating perjury accusations against San Francisco Giants' player Barry Bonds. Bonds appeared before a grand jury investigating the BALCO steroids case in December 2003 and is reported to have denied knowingly using performance enhancing drugs. Anderson, denied bail, was immediately sent to the Federal Correctional Institution in Dublin, California. Anderson's attorney, Mark Geragos, said he would file an appeal based on his assertion that the subpoena to testify violated Anderson's plea bargain agreement in the BALCO case.
On July 20, 2006, Anderson was released when the grand jury's term expired without indicting Bonds. However, Anderson was immediately subpoenaed to testify before a new grand jury that took up the case. Anderson's attorney, Mark Geragos, stated that Anderson would still refuse to testify, and on August 28, Anderson was again found in contempt of court and sentenced to prison.
On November 15, 2007, a federal judge ordered Anderson released from prison. This order came just hours after Bonds was indicted by a federal grand jury on 4 counts of perjury and 1 count of obstruction of justice.