This paper studies the effects of desynchronization attacks such as delay and warping on the performance of watermark detection systems. First, we quantify the connection between attack channel estimation accuracy and detection performance. Second, we show how to design watermarks that minimize probability of error of the detector. Evaluation of the optimal likelihood ratio test is often computationally expensive, so as a practical alternative, we propose a family of quadratic detectors and construct the detector and family of watermarks that maximize the deflection criterion. For delay attacks, the deflection criterion is shown to increase quadratically with the duration of the host signal. For warping attacks, the deflection criterion increases proportionally to the duration of the signal and proportionally to the coherence time of the warping function. Finally, as an alternative to noncoherent watermark detection, we suggest the use of tracking techniques to estimate the warping function, followed by coherent detection.