Is gravity a source of infinite energy at a cosmological scale As I understand it, gravity cannot be attenuated by any medium (in the way that EM radiation can be, for instance).

Does this, then, not make it a source (theoretically, I am not talking of practicalities) of infinite energy - if we assume the universe itself is infinite and looks the same everywhere (ie there are objects with mass everywhere)?

Or is it more correct to say that gravity has a net contribution of nothing to the universe's energy density because the attractional energy is balanced by a negative potential energy?
Gravity travels at light speed (or less, possibly), so even in an infinite non-expanding universe of finite age you'd only be gravitationally interacting with a finite mass in a finite volume. Our universe is observed to be expanding, further inhibiting us from coming into contact with new objects.

Furthermore, a common assumption of cosmological models is that the universe is homogeneous and isotropic on large scales. Meaning it is pretty much identical in all directions. Observations support this assumption. One net effect of this is that the gravitational potential energy you experience from objects outside (roughly) your supercluster is zero (and really close to it from things outside your own galaxy, actually). They just balance each other out.