We give a polynomial time attack on the McEliece public key cryptosystem based on algebraic geometry codes. Roughly speaking, this attacks runs in O(n^4) operations in GF(q), where n denotes the code length. Compared to previous attacks, allows to recover a decoding algorithm for the public key even for codes from high genus curves. This is joint work of Alain Couvreur, Irene Marquez-Corbella and Ruud Pellikaan