Effective defect passivation of semiconductor surfaces and interfaces is indispensable for the development of high efficiency solar cells. In this study we systematically investigated the surface and grain boundary properties of CuInSe2 (CISe) with scanning tunneling microscopy (STM) and spectroscopy (STS) after different surface treatments such as potassium cyanide (KCN) etching, pre-electrolyte treatment with cadmium ions, and annealing in ultrahigh vacuum (UHV). We show that air exposed samples with a subsequent KCN etching step exhibits a highly defective surface. However, a Cd pre-electrolyte treatment passivates most of these defects, which manifests itself by a reduction of the high conductance in the STS measurements at positive sample biases. The origin of the improvement can be traced back to an increase in surface band bending, which leads to a type inversion, induced by a change in the concentration of Cu vacancies. We observe a defect passivation at the CISe surface and at the grain boundaries. Our results give a direct explanation of why the CdS buffer layer in CISe thin film solar cells is of utmost importance for high efficiency devices.