BGE: altering a cube's shape in realtime (python)
Using the example shown for KX_MeshProxy

from bge import logic

cont = logic.getCurrentController()
object = cont.owner

for mesh in object.meshes:
   for m_index in range(len(mesh.materials)):
      for v_index in range(mesh.getVertexArrayLength(m_index)):
         vertex = mesh.getVertex(m_index, v_index)
         # Do something with vertex here...
         # ... eg: color the vertex red.
         vertex.color = [1.0, 0.0, 0.0, 1.0]


mesh.getVertexArrayLength(matid) tells you how many vertices are in the mesh, you then loop through each by increasing the vertex index which is the second value to getVertex(matid, index)

Applying that to your sample -

mesh = own.meshes[0]
for v_index in range(mesh.getVertexArrayLength(0)):
    vert  = mesh.getVertex( 0, v_index)
    pos = vert.getXYZ()
    #alter pos
    vert.setXYZ(pos)