Cheating or bug?

Yes. Although that question is incredibly off topic…

Walls in general can have a lot of edge cases that cause friend or foe to end up on an unexpected side. Gates are especially a bad offender for this since the way they work is more like a Sentry Forcefield than an unpathable structure.