Context. ASPIICS is a novel externally occulted solar coronagraph, which will be launched onboard the PROBA-3 mission of the European Space Agency. The external occulter will be placed on the first satellite ∼ 150 m ahead of the second satellite that will carry an optical instrument. During 6 hours per orbit, the satellites will fly in a precise formation, constituting a giant externally occulted coronagraph. Large distance between the external occulter and the primary objective will allow observations of the white-light solar corona starting from extremely low heights ∼ 1.1R ⊙ . Aims. To analyze influence of optical ghost images formed inside the telescope and develop an algorithm for their removal. Methods. We implement the optical layout of ASPIICS in Zemax and study the ghost behaviour in sequential and non-sequential regimes. We identify sources of the ghost contributions and analyze their geometrical behaviour. Finally we develop a mathematical model and software to calculate ghost images for any given input image.Results. We show that ghost light can be important in the outer part of the field of view, where the coronal signal is weak, since the energy of bright inner corona is redistributed to the outer corona. However the model allows to remove the ghost contribution. Due to a large distance between the external occulter and the primary objective, the primary objective does not produce a significant ghost. The use of the Lyot spot in ASPIICS is not necessary.