Badly written programs are a common reason for security failures. Programs crash, or fail to perform as intended, when users provide invalid inputs, either deliberately or accidentally. One response by the educational community has been to teach robust programming, which aims to prevent abnormal termination or unexpected actions and requires code to handle bad (invalid or absurd) inputs in a way that is consistent with the developer's intent. For example, if an internal error occurs, the program might terminate gracefully rather than simply failing, providing enough information for the programmer to debug the program and avoiding giving the user additional access or information.
Citation:
Matt Bishop, Deb Frincke, "Teaching Robust Programming," IEEE Security and Privacy, vol. 2, no. 2, pp. 54-57, Mar. 2004, doi:10.1109/MSECP.2004.1281247