Getty
Exclusive

Kodak Black Failed Drug Test Due to MDMA ... Asks Judge for Hall Pass

Kodak Black's failed drug tests came back positive for pot and ecstasy ... and yet he's now asking a judge for permission to hit up a big concert where drug use might be rampant.

As we first told you, the rapper violated the terms of his supervised release in his federal gun case by failing drug tests earlier this year. According to new legal docs, he tested positive for marijuana in February and then MDMA in August.

The judge ordered Kodak to complete a 90-day treatment program ... and he recently got permission to spend 30 of those days outside of Florida, after claiming it would give him a better chance at success.

Now, Kodak has his eye on a multiday music festival in New York.

According to the docs, KB asked the court to let him attend the Rolling Loud NYC music fest this weekend, and says it's strictly for business.

The judge signed off on it and gave him permission to perform at the festival -- he'll be on stage Friday in Queens -- as long as he keeps in touch with his Supervised Release Officer.

We reached out to Kodak's lawyer ... so far, no word back.

Click here for info about our online advertising practices.