Cocaine use disorder (CUD) is prevalent, and repetitive transcranial magnetic stimulation (rTMS) shows promise in reducing cravings. However, the association between a consistent CUD-specific functional connectivity signature and treatment response remains unclear. Here we identify a validated functional connectivity signature from functional magnetic resonance imaging to discriminate CUD, with successful independent replication. We found increased connectivity within the visual and dorsal attention networks and between the frontoparietal control and ventral attention networks, alongside reduced connectivity between the default mode and limbic networks in patients with CUD. These connections were associated with drug use history and cognitive impairments. Using data from a randomized clinical trial, we also established the prognostic value of these functional connectivities for rTMS treatment outcomes in CUD, especially involving the frontoparietal control and default mode networks. Our findings reveal insights into the neurobiological mechanisms of CUD and link functional connectivity biomarkers with rTMS treatment response, offering potential targets for future therapeutic development.