I just had a thought; occlusion queries work by swapping out the mesh for the bounding box with the actual drawing disabled when the fragment count drops below a threshold (usually zero) and brought back if that box is seen. But what happens if the camera is inside the box at this point? (unlikely but very possible) Does the occlusion query process count fragments behind the near clip plane?
The near plane should clip the geometry before any fragments are produced, just like the left or right frustum planes, so they should not be counted.
If you enable GL_ARB_depth_clamp it should work, because it disables clipping on the near and far planes.