The characteristics of the soft component and the ionic-electronic nature in all-inorganic CsPbI3-xBrx perovskite typically lead to a significant number of halide vacancy defects and ions migration, resulting in a reduction in both photovoltaic efficiency and stability. Herein, we present a tailored approach in which both anion-fixation and undercoordinated-Pb passivation are achieved in situ during crystallization by employing a molecule derived from aniline, specifically 2-methoxy-5-trifluoromethylaniline (MFA), to address the above challenges. The incorporation of MFA into the perovskite film results in a pronounced inhibition of ion migration, a significant reduction in trap density, an enhancement in grain size, an extension of charge carrier lifetime, and a more favorable alignment of energy levels. These advantageous characteristics contribute to achieving a champion power conversion efficiency (PCE) of 22.14 % for the MFA-based CsPbI3-xBrx perovskite solar cells (PSCs), representing the highest efficiency reported thus far for this type of inorganic metal halide perovskite solar cells, to the best of our knowledge. Moreover, the resultant PSCs exhibits higher environmental stability and photostability. This strategy is anticipated to offer significant advantages for large-area fabrication, particularly in terms of simplicity.